Moving Joints
There are two ways to move joints in the simulation: the Joint GUI (graphical, interactive) and the move_joints CLI node (scriptable, one-shot commands).
Both publish JointTrajectory messages to the joint_trajectory_controller.
Joint GUI (interactive)
Section titled “Joint GUI (interactive)”The Joint GUI launches automatically with the simulation. It provides sliders for each joint discovered from the robot’s URDF.
Controls
Section titled “Controls”| Button | Action |
|---|---|
| Send | Publishes the current slider positions as a trajectory command |
| Sync | Reads current joint positions from /joint_states and moves sliders to match |
| Reset | Zeros all sliders |
You can also:
- Change the Duration (seconds) for how long the trajectory takes
- Select which Topic to publish on (auto-discovered from available
JointTrajectorytopics) - Click Refresh to re-scan for topics
How it works
Section titled “How it works”- On launch, the GUI parses the URDF file for all
revolutejoints, reading theirlowerandupperlimits - It subscribes to
/joint_statesto discover which joints are actually active and their starting positions - When you hit Send, it publishes a
JointTrajectorymessage to the selected topic with positions offset by each joint’s origin angle
move_joints node (CLI)
Section titled “move_joints node (CLI)”The move_joints node sends a single trajectory command and exits. It’s useful for scripting or quick tests.
ros2 run sim_common move_joints --ros-args \ -p joints:="['shoulder_1', 'elbow_1', 'wrist_1', 'wrist_2']" \ -p positions:="[0.5, 0.5, 0.2, 0.0]" \ -p duration:=2.0Parameters
Section titled “Parameters”| Parameter | Required | Default | Description |
|---|---|---|---|
joints | Yes | — | List of joint names to move |
positions | Yes | — | Target positions (radians), one per joint |
duration | No | 2.0 | Seconds to reach the target |
topic | No | See below | Trajectory topic to publish on |
Default topic: /joint_trajectory_controller/joint_trajectory
Behavior
Section titled “Behavior”The node:
- Creates a publisher on the trajectory topic
- Waits (polling every 0.5s) until at least one subscriber is connected
- Publishes the trajectory message
- Logs the command and exits
This means the joint trajectory controller must be running before move_joints can send its command. If you run it right after launching the simulation, it will wait automatically until the controller is ready.
Example: move two joints
Section titled “Example: move two joints”ros2 run sim_common move_joints --ros-args \ -p joints:="['shoulder_1', 'elbow_1']" \ -p positions:="[1.0, -0.5]" \ -p duration:=3.0Example: move a single joint slowly
Section titled “Example: move a single joint slowly”ros2 run sim_common move_joints --ros-args \ -p joints:="['wrist_1']" \ -p positions:="[0.8]" \ -p duration:=5.0