MoveIt 2
Practical
Terminal window
Terminal window
MoveIt 2 is the motion planning framework for ROS 2, providing manipulation capabilities including motion planning, kinematics, collision detection, and trajectory execution. It’s the third most popular package in the ROS ecosystem and is developed by PickNik Robotics.
Prerequisites
Kinematics Forward and inverse kinematics concepts
TF2 ROS 2 transform library
Why MoveIt 2 Matters
- Motion planning: Automatically find collision-free paths for robot arms
- Inverse kinematics: Multiple solver options (KDL, TRAC-IK, pick_ik)
- Collision detection: Real-time checking against world and self-collision
- Teleoperation: MoveIt Servo enables real-time joystick/VR control
- Task composition: MoveIt Task Constructor for complex pick-and-place sequences
Architecture
┌─────────────────────────────────────────────────────────────────┐│ User Application ││ (Python API / C++ API / RViz) │└────────────────────────────┬────────────────────────────────────┘ │┌────────────────────────────▼────────────────────────────────────┐│ move_group Node ││ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ ││ │ Planning │ │ Kinematics │ │ Collision │ ││ │ Plugin │ │ Plugin │ │ Checker │ ││ │ (OMPL/STOMP) │ │ (KDL/TRAC) │ │ (FCL) │ ││ └──────────────┘ └──────────────┘ └──────────────┘ ││ │ ││ ┌──────────────────────────▼──────────────────────────────┐ ││ │ Planning Scene Monitor │ ││ │ (Robot State + World Geometry) │ ││ └──────────────────────────────────────────────────────────┘ │└────────────────────────────┬────────────────────────────────────┘ │┌────────────────────────────▼────────────────────────────────────┐│ ros2_control ││ (Joint Trajectory Controller) │└────────────────────────────┬────────────────────────────────────┘ │ ┌────────▼────────┐ │ Robot / Sim │ └─────────────────┘Planning Pipeline
Goal Pose → IK Solver → Joint Goal → Motion Planner → Trajectory → Controller ↓ ↓ Planning Scene ──────────── Collision CheckingInstallation
# Jazzy (recommended LTS)sudo apt install ros-jazzy-moveit
# Humblesudo apt install ros-humble-moveitBasic Motion Planning
import rclpyfrom moveit.planning import MoveItPyfrom geometry_msgs.msg import PoseStamped
def main(): rclpy.init()
# Initialize MoveItPy moveit = MoveItPy(node_name="moveit_py") arm = moveit.get_planning_component("arm")
# Set target pose target_pose = PoseStamped() target_pose.header.frame_id = "base_link" target_pose.pose.position.x = 0.5 target_pose.pose.position.y = 0.0 target_pose.pose.position.z = 0.4 target_pose.pose.orientation.w = 1.0
arm.set_goal_state( pose_stamped=target_pose, pose_link="gripper_link" )
# Plan and execute plan_result = arm.plan() if plan_result: arm.execute()
if __name__ == "__main__": main()# Move to predefined pose from SRDFarm.set_goal_state(configuration_name="home")plan_result = arm.plan()if plan_result: arm.execute()# Set specific joint valuesjoint_values = { "joint_1": 0.0, "joint_2": -0.785, "joint_3": 0.0, "joint_4": -2.356, "joint_5": 0.0, "joint_6": 1.571,}arm.set_goal_state(joint_values=joint_values)Motion Planners
MoveIt supports multiple planning backends via plugins:
| Planner | Library | Use Case |
|---|---|---|
| RRT, RRT*, PRM | OMPL | General-purpose sampling-based |
| STOMP | MoveIt | Trajectory optimization, smooth paths |
| Pilz | MoveIt | Industrial linear/circular motions |
| cuMotion | NVIDIA Isaac | GPU-accelerated, cluttered environments |
IK Solvers
| Solver | Characteristics |
|---|---|
| KDL | Default, Newton-based, struggles near joint limits |
| TRAC-IK | More reliable near joint limits, combines KDL + SQP |
| pick_ik | Modern solver, gradient descent + evolutionary algorithms |
MoveIt Servo (Real-time Control)
Stream velocity commands for teleoperation:
from geometry_msgs.msg import TwistStamped
# Publish Cartesian velocity commandstwist = TwistStamped()twist.header.frame_id = "base_link"twist.header.stamp = node.get_clock().now().to_msg()twist.twist.linear.x = 0.1 # 10 cm/s forward
servo_publisher.publish(twist)MoveIt Servo accepts:
geometry_msgs/TwistStamped— Cartesian velocitiescontrol_msgs/JointJog— Joint velocitiesgeometry_msgs/PoseStamped— Pose targets
MoveIt Task Constructor
Framework for composing complex manipulation sequences:
┌─────────────────┐│ Current State │ (Generator)└────────┬────────┘ ▼┌─────────────────┐│ Move to Pre-grasp│ (Connector)└────────┬────────┘ ▼┌─────────────────┐│ Close Gripper │ (Propagator)└────────┬────────┘ ▼┌─────────────────┐│ Lift Object │ (Propagator)└────────┬────────┘ ▼┌─────────────────┐│ Move to Place │ (Connector)└────────┬────────┘ ▼┌─────────────────┐│ Open Gripper │ (Propagator)└─────────────────┘Configuration Files
MoveIt requires several configuration files, generated by the Setup Assistant:
| File | Purpose |
|---|---|
*.urdf | Robot geometry (links, joints, meshes) |
*.srdf | Planning groups, poses, collision pairs |
kinematics.yaml | IK solver configuration |
ompl_planning.yaml | OMPL planner parameters |
joint_limits.yaml | Velocity/acceleration limits |
moveit_controllers.yaml | ros2_control integration |
NVIDIA cuMotion Integration
GPU-accelerated motion planning via Isaac ROS:
# Install cuMotion MoveIt pluginsudo apt install ros-humble-isaac-ros-cumotion-moveitKey advantages:
- Plans thousands of trajectories in parallel on GPU
- Sub-second planning in cluttered environments
- Smooth, time-optimal trajectories
Common Issues
| Problem | Cause | Solution |
|---|---|---|
| ”No IK solution found” | Target unreachable or in collision | Check workspace limits, verify pose is reachable |
| ”Planning failed” | Obstacles blocking path | Update planning scene, try different planner |
| Jerky motion | Joint limits too aggressive | Tune joint_limits.yaml |
| Slow planning | Complex environment | Use cuMotion or tune planner parameters |
Related Terms
Kinematics Forward and inverse kinematics
TF2 Transform library for coordinate frames
Nav2 Navigation stack for mobile robots
Learn More
- MoveIt 2 Getting Started — Official tutorial
- MoveIt Setup Assistant — Configure your robot
- MoveIt Servo Tutorial — Real-time control
- Pick and Place with MTC — Task Constructor tutorial