ROS 2 Learning Path  ยท  Illustrated Educational Book

Chapter 13: MoveIt 2 โ€” When ARCHO Raises Its Arm

From following a single point to planning the motion of a multi-axis arm
Prerequisite: Chapter 4 (URDF/Xacro), Chapter 5 (TF2)
Ongoing project: the ARCHO robot with a pick-up arm
Tools: MoveIt 2 and OMPL
Reading time: 140โ€“160 minutes
What's in this chapter 13.1MoveIt: the brain of a robotic arm 13.2Forward Kinematics: if I know the joint angles 13.3Inverse Kinematics: if I know the target 13.4Workspace, Singularity, and multiple solutions 13.5Planning Scene: ARCHO's digital memory of the world 13.6Collision Detection: the guard before every move 13.7Configuration Space: where MoveIt actually searches 13.8OMPL: RRT, RRTConnect, and PRM 13.9From Path to executable Trajectory 13.10Summary, glossary, and exercises

13.1MoveIt: the brain of a robotic arm

Suppose you're working on a version of ARCHO that, besides wheels, also has a pick-up arm โ€” for grabbing boxes off a shelf. So far, with Nav2, we've seen how ARCHO moves through space. But when it comes to moving the arm, the problem is entirely different: if Nav2 is the brain behind the mobile robot's motion, MoveIt 2 is the brain of the robotic arm.

๐Ÿง  Why you can't just say "go there"

If you only say "the tip of the arm must be here" with no further checking, the arm might collide with the table, the shelf, or even itself on its way to that point. MoveIt eliminates exactly this risk โ€” before any actual movement, it simulates and checks the entire path in its mind (in memory).

13.2Forward Kinematics: if I know the joint angles

Suppose you have this arm:

Base โ†’ Joint1 โ†’ Joint2 โ†’ Joint3 โ†’ Gripper

Now a simple question: if I know the angle of all three joints, exactly where in space is the tip of the arm (the Gripper)?

flowchart LR A["Joint Angles
Joint1=20ยฐ, Joint2=35ยฐ, Joint3=-15ยฐ"] --> B["Forward Kinematics"] --> C["End Effector Position
X, Y, Z"] style B fill:#eef0ff,stroke:#3d4bf5
๐Ÿง  Analogy: your own hand

If I know the angle of your shoulder, elbow, and wrist, I can calculate the exact location of your fingertip โ€” that's exactly FK. This calculation is simple because we just "move forward": motor angle โ†’ link angle โ†’ link position โ†’ tip of the arm. There is always exactly one answer.

FK is exactly what TF2 (Chapter 5) actually uses: when TF says "the joints have these angles," it's FK that calculates the real position of gripper_link or camera_link in space. RViz, Gazebo, and Collision Detection all constantly rely on FK.

13.3Inverse Kinematics: if I know the target

Now flip the question around: if I know where the tip of the arm needs to be (say, X=0.50, Y=0.20, Z=0.80), how many degrees must each joint turn?

flowchart LR A["Target Pose
X, Y, Z"] --> B["Inverse Kinematics"] --> C["Joint Angles"] style B fill:#f4effe,stroke:#8b5cf6
๐Ÿ”ง Why IK is harder than FK

When you say "pick up the cup on the table," your brain itself calculates the shoulder, elbow, and wrist angles โ€” that's IK. But unlike FK, IK may have several solutions (say, elbow-up or elbow-down, both reaching the target), no solution at all (the target is out of reach), or even infinitely many solutions.

Why does IK matter more than FK? Because a human (or a production-line operator) always specifies a goal โ€” "tighten this screw," not "rotate Joint1 by 13 degrees." MoveIt performs this translation from goal to joint angles for you.

Forward KinematicsInverse Kinematics
InputJoint anglesTarget position (Pose)
OutputPosition of the arm tipJoint angles
Number of solutionsAlways exactly oneZero, one, several, or infinite
Computational difficultySimple and directUsually requires a numerical solver
Common useRViz, TF, Robot State, GazeboMoveIt, Pick & Place, Manipulation

In real 6- or 7-axis arms, there is usually no simple closed-form formula for IK, and numerical solvers such as KDL, TRAC-IK, or IKFast are used, any of which MoveIt can employ as a plugin.

โš ๏ธ The biggest beginner mistake

Don't think FK means "moving the arm" or IK means "moving the motor." Neither does that โ€” they only calculate. Actually executing the motion is the job of ros2_control and the Controllers (Chapter 8).

13.4Workspace, Singularity, and multiple solutions

๐Ÿ“– What is Workspace

Workspace means all the points the arm can actually reach. If the target is outside this range, IK responds: Unreachable โ€” meaning reaching it is simply not possible, no matter how clear the path is.

๐Ÿ“– What is Singularity

When the arm becomes fully extended and straight, movement in certain directions suddenly becomes difficult or even impossible โ€” this is called a Singularity. MoveIt tries to steer paths around configurations that approach this state.

IK caseCause
Multiple solutions (e.g. elbow-up/down)The arm's geometry allows several different configurations to reach one target
No solution (No IK Solution)The target is too far, a Joint Limit prevents it, or there's an obstacle in the way

13.5Planning Scene: ARCHO's digital memory of the world

If MoveIt only had IK, it might choose the best mathematical answer โ€” even if its path passes right through a box on the table. So the question is: how does MoveIt even know that box exists?

๐Ÿ“– Definition of Planning Scene

The Planning Scene is a complete digital model of the world ARCHO moves through: the robot itself, the table, the floor, the wall, boxes, tools, humans, fixed equipment, shelves, and the conveyor belt. MoveIt always checks this world in memory before every move.

๐ŸŒ The Planning Scene isn't static

Suppose a worker places a new box on the table next to ARCHO. The Planning Scene updates immediately, and from that moment on, MoveIt's new paths automatically route around that box โ€” without anyone writing a single new line of code.

Attached Object: when the arm makes itself bigger

When ARCHO picks up a box, from that moment the box is effectively treated as part of the robot itself โ€” this is called an Attached Object. If MoveIt forgets this, it might think the arm is still narrow, while with the box in hand its actual width has grown from, say, 40 centimeters to 80 centimeters โ€” and this is exactly what causes the box to hit a wall, even if the arm itself passed by it completely unscathed.

13.6Collision Detection: the guard before every move

Before executing any path, MoveIt asks: "Does the arm collide with anything at any moment along this path?" And this check isn't just at the start and end of the path โ€” it's performed at hundreds or thousands of intermediate points along the way. If the start and end are clear but a collision occurs mid-path, that path is rejected.

Collision typeMeaningExample
Self CollisionThe robot collides with itselfThe Gripper hits the Upper Arm due to excessive elbow bending
World CollisionCollision with the environmentTable, wall, human, box, shelf
๐Ÿ”ง Why MoveIt doesn't check every link pair against each other

Two adjacent joints like Joint1 and Joint2 are naturally always close to each other, and constantly checking their collision is pointless and slow. MoveIt builds a Self-Collision Matrix that specifies which pairs don't need checking at all โ€” which makes the computation dramatically faster.

Remember in Chapter 4 we said URDF has two sections, visual and collision? MoveIt only uses the collision section โ€” a simple box instead of the precise screws, edges, and logo of the visual model, because that's enough for collision checking and much faster.

Allowed Collision Matrix

Sometimes a collision is completely natural and necessary โ€” for example, the Gripper must touch an object in order to grasp it. MoveIt marks these exceptions with a matrix: Gripper โ†” Object โ†’ Allowed, but Gripper โ†” Table โ†’ Not Allowed.

Constraints: extra restrictions on the path

Constraint typeExample
Orientation ConstraintA cup of water must always stay upright
Position ConstraintThe arm may only move within a specified region
Joint ConstraintJoint3 must never exceed 90 degrees
Workspace ConstraintThe arm is only allowed to move within a specified volume

13.7Configuration Space: where MoveIt actually searches

Suppose ARCHO's arm has 6 joints, and each joint has only 100 possible states. If MoveIt tried to test every combination, it would have to check 100โถ โ€” one trillion states โ€” completely impossible.

๐Ÿง  Perhaps the most important concept in all of Motion Planning

Many people think MoveIt finds a path inside the three-dimensional space of the room. That's wrong. MoveIt actually searches inside the Configuration Space (C-Space) โ€” the space of joint angles. If you have 6 joints, every configuration of the arm is a single point in a 6-dimensional space, not a point in the room.

Inside C-Space, some points are Free Space (allowed and collision-free) and some are Collision Space (not allowed because they collide with the table, wall, or the arm itself). The goal of the Motion Planner is to find a path from the Start point to the Goal point that stays entirely within Free Space.

13.8OMPL: RRT, RRTConnect, and PRM

๐Ÿ“– What is OMPL

Open Motion Planning Library โ€” MoveIt doesn't write its own path-planning algorithms; instead it uses this open-source library. OMPL's input: Planning Scene + Robot Model + Goal. Output: a Trajectory.

RRT (Rapidly-exploring Random Tree)

Instead of examining the whole space, RRT grows a tree from the start point, like the roots of a plant. Each new branch is a new random configuration of the arm. If a branch hits an obstacle, it's discarded and the tree grows in another direction. When a branch reaches the Goal, that branch becomes the final path.

RRTConnect

An improved version: instead of one tree, two trees grow simultaneously โ€” one from Start and one from Goal. When these two trees meet, a path has been found. This is usually the fastest planner available in MoveIt.

PRM (Probabilistic Roadmap)

First, thousands of random points are generated in C-Space and connected to each other โ€” like building a road map. Then a suitable path is simply chosen along that road network.

RRT / RRTConnectPRM
MethodStarts fresh from scratch each timeFirst builds a fixed "road network," then uses it repeatedly
Best suited forConstantly changing environmentsStatic, repetitive environments
RRTConnect: two trees Start Goal PRM: random road map
Left side: RRTConnect grows two trees from Start and Goal. Right side: PRM first builds a fixed network of random points.

13.9From Path to executable Trajectory

The Planner only finds a Path โ€” a sequence of joint angles with no information about time at all. This raw path usually has sharp corners that aren't suitable for physical execution, so MoveIt smooths it out with Path Smoothing.

๐Ÿ“– The difference between Path and Trajectory

A Path is just the route. A Trajectory means route + time โ€” for example, "second zero: Joint1=0ยฐ, second one: Joint1=20ยฐ, second two: Joint1=35ยฐ." This final Trajectory is what the Controller (Chapter 8) actually executes.

When building the final Trajectory, MoveIt also respects several constraints:

ConstraintMeaning
Velocity LimitNo joint's speed exceeds its allowed limit
Acceleration LimitNo sudden acceleration
JerkEven a sudden change in acceleration is limited in professional industrial robots

The central coordinator of all this is a Node known as move_group:

flowchart LR A["RViz / User"] --> B["move_group"] --> C["OMPL Planner"] --> D["Trajectory"] --> E["ros2_control"] --> F["Robot"] style B fill:#eef0ff,stroke:#3d4bf5
โš ๏ธ The Planner doesn't always find the "best" path

RRT and RRTConnect find a good, safe path, not necessarily the mathematically optimal path in the world โ€” because finding the absolutely optimal path could take hours. MoveIt has a limited Planning Time (say, 5 seconds); if no path is found by then, it returns Planning Failed.

13.10Chapter 13 summary

Now you know what happens behind the scenes when ARCHO raises its arm to pick up a box: FK calculates where the arm currently is, IK calculates what joint angles are needed to reach the target, the Planning Scene keeps the surrounding world in memory, Collision Detection verifies the safety of the path, and OMPL finds a safe route through the multi-dimensional Configuration Space, which is finally turned into an executable Trajectory.

โœ… Learning checkpoint
  • I can explain the difference between FK and IK using an example from my own hand.
  • I know why IK may have several solutions, no solution, or infinitely many solutions.
  • I can explain what the Planning Scene is and why it isn't static.
  • I know why MoveIt searches in the space of joint angles, not the physical space of the room.
  • I can explain the difference between RRTConnect and PRM and say which environment each suits better.
  • I know the difference between Path and Trajectory.
๐ŸŒ Connection to the main project

ARCHO Project now has a complete MoveIt configuration that, using the Planning Scene, Collision Detection, and the RRTConnect algorithm, can guide its pick-up arm to grab a box from the shelf without colliding with the environment.

What the next chapter adds

In Chapter 14 we move away from a single ARCHO and enter the world of multi-robot systems: Namespaces, TF Prefixes, and coordinating multiple ARCHOs working simultaneously in a warehouse.

Chapter 13 glossary

MoveIt 2
The primary ROS 2 framework for motion planning of robotic arms.
Forward Kinematics (FK)
Calculating the position of the arm tip from the joint angles.
Inverse Kinematics (IK)
Calculating the joint angles needed to reach a target position.
End Effector
The last part of the arm that performs the actual work; e.g. a Gripper or Welding Torch.
Singularity
A geometric configuration in which the arm's movement in certain directions suddenly becomes difficult or impossible.
Planning Scene
A digital, up-to-date model of everything around the robot that it might collide with.
Attached Object
An object the robot has grasped and, from that moment, is treated as part of the robot itself.
Configuration Space (C-Space)
The multi-dimensional space made up of all the robot's joint angles, which is where MoveIt searches.
OMPL
Open Motion Planning Library; the library that runs MoveIt's actual path-planning algorithms.
RRT / RRTConnect
Path-planning algorithms based on growing a random tree in Configuration Space.

Chapter 13 common mistakes โ€” recap