Skip to content

Commit 5da58fe

Browse files
authored
Fix index bug in _get_info_about_joint
1 parent ee09ccc commit 5da58fe

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

pyrep/joints.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -135,12 +135,11 @@ def spherical(self, name: str) -> SphericalJoint:
135135
"""
136136
Retrieves the joint with next parameters:
137137
* Joint type: Spherical
138-
* Joint mode: Force
138+
* Joint mode: Passive
139139
"""
140140
joint = self._get_joint_with_param(
141141
name,
142-
[vc.sim_joint_revolute_subtype, # bug in v-rep: return revolute, instead spherical
143-
vc.sim_joint_revolute_subtype], # bug in v-rep: return revolute, instead spherical
142+
[vc.sim_joint_spherical_subtype],
144143
vc.sim_jointmode_passive)
145144
return SphericalJoint(joint)
146145

@@ -192,16 +191,14 @@ def with_velocity_control(self, name: str) -> JointWithVelocityControl:
192191
"""
193192
joint = self._get_joint_with_param(
194193
name, [vc.sim_joint_revolute_subtype, vc.sim_joint_prismatic_subtype],
195-
vc.sim_jointmode_motion) # bug in v-rep: return motion, instead force
194+
vc.sim_jointmode_force)
196195
return JointWithVelocityControl(joint)
197196

198197
def _get_joint_with_param(self, name, types, mode) -> AnyJoint:
199198
handle = self._get_object_handle(name)
200199
if handle is not None:
201200
type, curr_mode, limit, range = self._get_info_about_joint(handle)
202-
if type == types[0] or \
203-
type == types[1] and \
204-
curr_mode == mode:
201+
if type in types and curr_mode == mode:
205202
return AnyJoint(self._id, handle)
206203
else:
207204
raise MatchObjTypeError("Joint with name: \"" + name +
@@ -214,8 +211,10 @@ def _get_info_about_joint(self, handle):
214211
data_type_code = 16
215212
code, handles, types_and_mode, limits_and_ranges, string_data = v.simxGetObjectGroupData(
216213
self._id, obj_type_code, data_type_code, self._def_op_mode)
217-
if handles.__contains__(handle):
218-
return types_and_mode[0], types_and_mode[1], limits_and_ranges[0], limits_and_ranges[1]
214+
if code == v.simx_return_ok:
215+
index = handles.index(handle)
216+
index = index * 2
217+
return types_and_mode[index], types_and_mode[index+1], limits_and_ranges[index], limits_and_ranges[index+1]
219218
else:
220219
return None
221220

0 commit comments

Comments
 (0)