From 2779f45b34679a97654e68fa6087e4eedfebc876 Mon Sep 17 00:00:00 2001 From: Hongzhuo Liang Date: Fri, 27 Aug 2021 22:10:13 +0200 Subject: [PATCH 1/5] set robot joint fix step then enable dynamics --- pyrep/robots/robot_component.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pyrep/robots/robot_component.py b/pyrep/robots/robot_component.py index c97a63f..7eab824 100644 --- a/pyrep/robots/robot_component.py +++ b/pyrep/robots/robot_component.py @@ -109,12 +109,11 @@ def set_joint_positions(self, positions: List[float], for jh, p in zip(self._joint_handles, positions)] [j.set_joint_target_position(p) # type: ignore for j, p in zip(self.joints, positions)] - + with utils.step_lock: + sim.simExtStep(True) # Have to step for changes to take effect # Re-enable the dynamics sim.simSetModelProperty(self._handle, prior) self.set_model(is_model) - with utils.step_lock: - sim.simExtStep(True) # Have to step for changes to take effect def get_joint_target_positions(self) -> List[float]: """Retrieves the target positions of the joints. From 8036a203c99a0d2cdfd01c6982648b770e794f59 Mon Sep 17 00:00:00 2001 From: Hongzhuo Liang Date: Fri, 27 Aug 2021 22:10:27 +0200 Subject: [PATCH 2/5] doc string fix --- pyrep/objects/joint.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyrep/objects/joint.py b/pyrep/objects/joint.py index 13f1dc4..9f9c092 100644 --- a/pyrep/objects/joint.py +++ b/pyrep/objects/joint.py @@ -44,7 +44,7 @@ def set_joint_position(self, position: float, when the joint mode is in Force mode. It will disable dynamics, move the joint, and then re-enable dynamics. - :param positions: A list of positions of the joints (angular or linear + :param position: Position of a joint (angular or linear values depending on the joint type). """ if not disable_dynamics: From d8b79e07ae832ada9f5730d3194effbdf3c06c7f Mon Sep 17 00:00:00 2001 From: Hongzhuo Liang Date: Fri, 27 Aug 2021 23:45:24 +0200 Subject: [PATCH 3/5] for set joint position set step then enable dynamics --- pyrep/objects/joint.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyrep/objects/joint.py b/pyrep/objects/joint.py index 9f9c092..4ab0d6d 100644 --- a/pyrep/objects/joint.py +++ b/pyrep/objects/joint.py @@ -65,11 +65,11 @@ def set_joint_position(self, position: float, sim.simSetJointPosition(self._handle, position) self.set_joint_target_position(position) + with utils.step_lock: + sim.simExtStep(True) # Have to step for changes to take effect # Re-enable the dynamics sim.simSetModelProperty(self._handle, prior) self.set_model(is_model) - with utils.step_lock: - sim.simExtStep(True) # Have to step for changes to take effect def get_joint_target_position(self) -> float: """Retrieves the target position of a joint. From 430f58135513a331abdea12135b28078552add8f Mon Sep 17 00:00:00 2001 From: Hongzhuo Liang Date: Thu, 2 Sep 2021 19:44:34 +0200 Subject: [PATCH 4/5] give the user an option to change disable_dynamics option --- pyrep/robots/configuration_paths/arm_configuration_path.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyrep/robots/configuration_paths/arm_configuration_path.py b/pyrep/robots/configuration_paths/arm_configuration_path.py index cb82328..e587561 100644 --- a/pyrep/robots/configuration_paths/arm_configuration_path.py +++ b/pyrep/robots/configuration_paths/arm_configuration_path.py @@ -59,11 +59,11 @@ def set_to_start(self) -> None: self._arm.set_joint_positions(start_config) self._path_done = False - def set_to_end(self) -> None: + def set_to_end(self, disable_dynamics=False) -> None: """Sets the arm to the end of this path. """ final_config = self._path_points[-len(self._arm.joints):] - self._arm.set_joint_positions(final_config) + self._arm.set_joint_positions(final_config, disable_dynamics=disable_dynamics) def visualize(self) -> None: """Draws a visualization of the path in the scene. From da0824eef7b254cc307a04a6178ec9458ef61891 Mon Sep 17 00:00:00 2001 From: Hongzhuo Liang Date: Thu, 2 Sep 2021 19:47:52 +0200 Subject: [PATCH 5/5] give the user an option to change disable_dynamics option --- pyrep/robots/configuration_paths/arm_configuration_path.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyrep/robots/configuration_paths/arm_configuration_path.py b/pyrep/robots/configuration_paths/arm_configuration_path.py index e587561..49bb13f 100644 --- a/pyrep/robots/configuration_paths/arm_configuration_path.py +++ b/pyrep/robots/configuration_paths/arm_configuration_path.py @@ -52,11 +52,11 @@ def step(self) -> bool: self._path_done = done return done - def set_to_start(self) -> None: + def set_to_start(self, disable_dynamics=False) -> None: """Sets the arm to the beginning of this path. """ start_config = self._path_points[:len(self._arm.joints)] - self._arm.set_joint_positions(start_config) + self._arm.set_joint_positions(start_config, disable_dynamics=disable_dynamics) self._path_done = False def set_to_end(self, disable_dynamics=False) -> None: