Skip to content

Commit d778d5d

Browse files
Fix set joint position (#289)
* set robot joint fix step then enable dynamics * doc string fix * for set joint position set step then enable dynamics * give the user an option to change disable_dynamics option * give the user an option to change disable_dynamics option
1 parent d4c2ea4 commit d778d5d

File tree

3 files changed

+9
-10
lines changed

3 files changed

+9
-10
lines changed

pyrep/objects/joint.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def set_joint_position(self, position: float,
4444
when the joint mode is in Force mode. It will disable dynamics,
4545
move the joint, and then re-enable dynamics.
4646
47-
:param positions: A list of positions of the joints (angular or linear
47+
:param position: Position of a joint (angular or linear
4848
values depending on the joint type).
4949
"""
5050
if not disable_dynamics:
@@ -65,11 +65,11 @@ def set_joint_position(self, position: float,
6565
sim.simSetJointPosition(self._handle, position)
6666
self.set_joint_target_position(position)
6767

68+
with utils.step_lock:
69+
sim.simExtStep(True) # Have to step for changes to take effect
6870
# Re-enable the dynamics
6971
sim.simSetModelProperty(self._handle, prior)
7072
self.set_model(is_model)
71-
with utils.step_lock:
72-
sim.simExtStep(True) # Have to step for changes to take effect
7373

7474
def get_joint_target_position(self) -> float:
7575
"""Retrieves the target position of a joint.

pyrep/robots/configuration_paths/arm_configuration_path.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,18 +52,18 @@ def step(self) -> bool:
5252
self._path_done = done
5353
return done
5454

55-
def set_to_start(self) -> None:
55+
def set_to_start(self, disable_dynamics=False) -> None:
5656
"""Sets the arm to the beginning of this path.
5757
"""
5858
start_config = self._path_points[:len(self._arm.joints)]
59-
self._arm.set_joint_positions(start_config)
59+
self._arm.set_joint_positions(start_config, disable_dynamics=disable_dynamics)
6060
self._path_done = False
6161

62-
def set_to_end(self) -> None:
62+
def set_to_end(self, disable_dynamics=False) -> None:
6363
"""Sets the arm to the end of this path.
6464
"""
6565
final_config = self._path_points[-len(self._arm.joints):]
66-
self._arm.set_joint_positions(final_config)
66+
self._arm.set_joint_positions(final_config, disable_dynamics=disable_dynamics)
6767

6868
def visualize(self) -> None:
6969
"""Draws a visualization of the path in the scene.

pyrep/robots/robot_component.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,12 +109,11 @@ def set_joint_positions(self, positions: List[float],
109109
for jh, p in zip(self._joint_handles, positions)]
110110
[j.set_joint_target_position(p) # type: ignore
111111
for j, p in zip(self.joints, positions)]
112-
112+
with utils.step_lock:
113+
sim.simExtStep(True) # Have to step for changes to take effect
113114
# Re-enable the dynamics
114115
sim.simSetModelProperty(self._handle, prior)
115116
self.set_model(is_model)
116-
with utils.step_lock:
117-
sim.simExtStep(True) # Have to step for changes to take effect
118117

119118
def get_joint_target_positions(self) -> List[float]:
120119
"""Retrieves the target positions of the joints.

0 commit comments

Comments
 (0)