Is it possible to warp models (robots) into a certain pose? I.e., is it possible to directly set link positions? #300
-
I searched the documentation and I found methods for reading the current pose/velocity/acceleration as well as setting targets for each. However, I didn't find a way to directly set the position of a joint that would effectively teleport the model into the desired pose. My use-case is to programmatically set a robot's pose (panda in my case) into a specific joint configuration before the simulation starts. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
Hello, I believe you are looking for When resetting positions, I also recommend setting velocities to Remember to run a paused Gazebo step for this to take effect. In case your model uses plugins that update only when the simulation is running, e.g. If you are using Python bindings, it might look something like this: robot_name = 'panda'
joint_positions = (0.0, 0.0, 0.0, -1.57, 0.0, 1.57, 0.79, 0.04, 0.04)
robot = world.get_model(robot_name).to_gazebo()
if not robot.reset_joint_positions(joint_positions):
raise RuntimeError("Failed to reset robot joint positions")
if not robot.reset_joint_velocities([0.0] * len(joint_positions)):
raise RuntimeError("Failed to reset robot joint velocities")
if not gazebo.run(paused=True):
raise RuntimeError("Failed to execute a paused Gazebo run") Edit: Updated Python snippet to include |
Beta Was this translation helpful? Give feedback.
Hello, I believe you are looking for
Model::resetJointPositions()
. Alternatively, there isJoint::resetPosition()
if you need to access a single joint (which you can also do withModel::resetJointPositions()
by passingjointNames
argument).When resetting positions, I also recommend setting velocities to
0.0
for the affected joints (Model::resetJointVelocities()
), especially if the robot was in motion. Without this, I have experienced occasional/unpredictable segfault during subsequent GazeboPostUpdate
call - even if the robot was seemingly static (not sure if it still occurs).Remember to run a paused Gazebo step for this to take effect. In case your model uses plugins that update only …