Gazebo
Moving Joints
Control robot joints using the GUI or CLI
There are two ways to move joints in the simulation: the Joint GUI and the move_joints CLI node. Both publish JointTrajectory messages to the joint_trajectory_controller.
Joint GUI
The Joint GUI launches automatically with the simulation. It provides sliders for each joint discovered from the robot's URDF.
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
- 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)
The move_joints node sends a single trajectory command and exits. It's useful for deterministic move sequences and scripting.
Usage
$ ros2 run sim_common move_joints --ros-args \
-p joints:="['joint1', 'joint2', 'joint3', 'joint4']" \
-p positions:="[0.1, 0.5, 0.2, 0.0]" \
-p duration:=2.0Parameters
| 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 | /joint_trajectory_controller/joint_trajectory | Trajectory topic to publish on |
How it works
- Creates a publisher on the trajectory topic
- Waits 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.
Examples
$ ros2 run sim_common move_joints --ros-args \
-p joints:="['shoulder_1', 'elbow_1']" \
-p positions:="[1.0, -0.5]" \
-p duration:=3.0$ ros2 run sim_common move_joints --ros-args \
-p joints:="['wrist_1']" \
-p positions:="[0.8]" \
-p duration:=5.0