Skip to content

Commit 84d4b7d

Browse files
tomputer-gnevalsar
andauthored
Add articles on MoveIt manipulator planning and Gazebo simulation (#226)
- Add "Advanced MoveIt usage for Manipulator Motion Planning" to /wiki/planning/ - Add "Gazebo Classic Simulation of Graspable and Breakable Objects" to /wiki/simulation/ - Update navigation and index pages --------- Co-authored-by: Nevin Valsaraj <nevin.valsaraj32@gmail.com>
1 parent cdd79e2 commit 84d4b7d

File tree

9 files changed

+223
-0
lines changed

9 files changed

+223
-0
lines changed

_data/navigation.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,8 @@ wiki:
261261
url: /wiki/simulation/Spawning-and-Controlling-Vehicles-in-CARLA
262262
- title: NDT Matching with Autoware
263263
url: /wiki/simulation/NDT-Matching-with-Autoware/
264+
- title: Gazebo Classic Simulation of Graspable and Breakable Objects
265+
url: /wiki/simulation/gazebo-classic-simulation-of-graspable-and-breakable-objects
264266
- title: NVIDIA Isaac Sim Setup and ROS2 Workflow
265267
url: /wiki/simulation/simulation-isaacsim-setup/
266268
- title: Interfacing
@@ -394,6 +396,8 @@ wiki:
394396
url: /wiki/planning/frenet-frame-planning/
395397
- title: Move Base Flex
396398
url: /wiki/planning/move-base-flex/
399+
- title: Advanced MoveIt usage for Manipulator Motion Planning
400+
url: /wiki/planning/advanced-moveit-manipulator-planning/
397401
# Main links appear in the header.
398402
main:
399403
- title: Wiki
58.3 KB
Loading
52 KB
Loading
185 KB
Loading
103 KB
Loading
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
---
2+
# Jekyll 'Front Matter' goes here. Most are set by default, and should NOT be
3+
# overwritten except in special circumstances.
4+
# You should set the date the article was last updated like this:
5+
date: 2025-11-26 # YYYY-MM-DD
6+
# This will be displayed at the bottom of the article
7+
# You should set the article's title:
8+
title: Advanced MoveIt usage for Manipulator Motion Planning
9+
# The 'title' is automatically displayed at the top of the page
10+
# and used in other parts of the site.
11+
---
12+
13+
## Motivation
14+
15+
Every robotics project with manipulator arms requires careful selection of motion planning components, and a good understanding of when to use what planning approach. This guide intends to show our process for implementing motion planning for dual XArm 7 manipulators in our project, VADER.
16+
17+
* Firstly, depending on the current movement task at hand, some motion planning methods may be more beneficial than others. In this wiki, we primarily explore the RRTStar and the Cartesian movement planners.
18+
19+
* We experimented with different planner settings for the RRTStar planning algorithm, and implemented a custom cost objective function to use in this planner. We also picked better starting joint space configurations to avoid singularities when using the Cartesian planner.
20+
21+
* Finally, we describe our testing routines for the motion planner to ensure overall success and reason about common failure modes.
22+
23+
### Planner Usage
24+
25+
The primary task of our dual-manipulator project is to harvest and store green peppers autonomously. We have a left arm with a cutter attachment, and a right arm with a gripper attachment. The overall harvesting sequence requires the following movements of the manipulators:
26+
27+
* Restore both arms to known 'home' poses,
28+
* Move both arms to ~15cm away from a coarse pose estimation of the pepper to get a better pose estimate,
29+
* Move gripper fully into grasp position,
30+
* Move cutter fully into grasp position,
31+
* After harvest, the cutter goes to home pose while the gripper moves the pepper to a storage bin.
32+
33+
![VADER planning sequence](/assets/images/adv-moveit-manipulator-planning/vader_planning_seq.png)
34+
35+
The home pose of both arms, as well as the gripper pose when storing the pepper, are fixed. The coarse and fine pose estimates of the target pepper depends on the placement of the system, and are therefore fairly variable.
36+
37+
## RRTStar vs. Cartesian Planner
38+
39+
A mixture of these two planners are used during our harvesting process along different stages.
40+
41+
The RRTStar planner plans in joint space, and by default (we will talk about this further in the next section), the best solution is defined as minimizing the amount that each joint moves.
42+
43+
The Cartesian planner plans in a straight line from A to B, and computes the joint position at each waypoint given where the end effector should be. The translation and rotation are interpolated along the path.
44+
45+
| Type | RRTStar | Cartesian |
46+
|---|:---|:---|
47+
| Advantages | Consistently finds a viable solution, especially if using joint goals. Maneuvers freely in obstacle-rich environment to disentangle arms. | Very fast to compute & execute. Path deterministic and predictable. |
48+
| Drawbacks | Solution not deterministic and can travel too far in free space. Requires careful placement of collision objects to discourage winding paths. Slower to compute & execute. | Solution could cause singularities and controller error if running into joint limits. This means the solution success is dependent on the starting joint configuration. |
49+
| Usage | This is used in our Homing motions as well as the gripper move-to-storage motion. | This is used in our pregrasp, final grasp, retraction (after harvest), and lowering the pepper down to the final storage location. |
50+
| Example Path | ![RRTStar example path](/assets/images/adv-moveit-manipulator-planning/rrtstar.png) | ![Cartesian example path](/assets/images/adv-moveit-manipulator-planning/cartesian.png) |
51+
52+
We will talk about each of these planners in greater detail below.
53+
54+
## RRTStar settings and custom cost objectives
55+
56+
The `ompl_planning.yaml` file is where the planner settings are derived from - but that's not all you can specify! The best reference for all the available planner parameters are available from their source code [HERE](https://ompl.kavrakilab.org/RRTstar_8h_source.html), with plenty of default values that aren't shown in the configuration file. Even if your use case doesn't concern as many special settings as this covers, it is helpful to be aware of extra settings not present in the files by default.
57+
58+
### Creating a custom optimization objective for MoveIt
59+
60+
We wanted to implement our own cost objective function instead of the default minimize-path-length option. To define a custom objective for RRT (or for any planner), extend the `OptimizationObjective` class with your logic, where the motion cost between two states (joint configurations) is set.
61+
62+
Refer to our code being discussed in this section over [HERE](https://github.com/VADER-CMU/planning/blob/e2592fecca5f3a0815decf82948ffbcd02c4f1a4/vader_planner/src/utils/vader_cost_objective.cpp).
63+
64+
To create a task-space cost function, we fetched the Denavit-Hartenburg parameters from the official UFactory website, and implemented a simple forward kinematics class that transforms the joint positions into the end effector pose. Then, the `XarmTaskSpaceOptimizationObjective` class is defined with the motion cost between states equal to the L2 distance between the poses (currently not counting the rotation).
65+
66+
Finally, the `VADERCustomObjective` class is an instance of the `MultiOptimizationObjective` class from OMPL, which uses a weighted combination of different optimization classes. We can now use this objective in place of the default `PathLengthOptimizationObjective` (or, better yet, add the path length objective as one of the weighted sum classes in your custom objective).
67+
68+
### Using a custom objective
69+
70+
After building this objective, using it in your planner through MoveIt requires some changes to MoveIt's source code. This is because it takes an if-else list of acceptable objectives, and you have to add your own option directed at your custom class. Fork your copy of MoveIt, and modify `model_based_planning_context.cpp` and refer to [HERE](https://github.com/VADER-CMU/moveit/blob/master/moveit_planners/ompl/ompl_interface/src/model_based_planning_context.cpp#L326-L331) for our changes.
71+
72+
Finally after all that, change your configuration under `ompl_planning.yaml` like so, matching the string to what you specified above:
73+
74+
```yaml
75+
# ompl_planning.yaml
76+
...
77+
VADER:
78+
type: geometric::RRTstar
79+
...
80+
optimization_objective: VADERCustomObjective
81+
xarm7:
82+
default_planner_config: VADER
83+
planner_configs:
84+
- VADER
85+
```
86+
87+
The efficacy of the multi optimization objective depends on your weighted sum of objectives, among other factors, but now you have full control over your desired behavior of the RRT planner!
88+
89+
## Planning in Cartesian space
90+
91+
Besides RRT, Cartesian space planning can also be done in native MoveIt with `move_group.computeCartesianPath()`. You can specify just a goal pose, or an entire preset vector of waypoints, and it outputs a trajectory and the resulting 'fraction' of the path covered by the plan - in general, any fraction lower than 1.0 indicates planning failure, since it wasn't able to account for the full motion.
92+
93+
A few things to be aware when using the Cartesian planner are:
94+
95+
* Beware of joint limits in your configuration. One major failure mode of the Cartesian planner is starting in a joint configuration with inevitable singularities due to joints reaching their lower or upper joint limits, at which point the planner will fail. If you can start with a known good joint configuration, where none of the joints are approaching their limits and it's unlikely the goal state involves self collision or singularities, it would result in much higher success rates.
96+
97+
* If you are using intermediate waypoints, use `tf::Quaternion::slerp()` to interpolate between rotations by a ratio.
98+
99+
## Testing, testing, testing
100+
101+
To help in testing the robustness and failure modes of our planning and state machine subsystems, we created a Simulation Director system to test the entire system (minus Perception parts) in an RViz/Gazebo simulation.
102+
103+
For each simulated run, a randomized pepper ground truth pose is generated, and noise added. We run the entire system given this pose estimate, and watch how the RRT and Cartesian planners fail in which circumstances (due to reachability, planner failure, etc.). An example result of 100 aggregated runs is shown below, and higher failure rates at either ends of the horizontal workspace are observed.
104+
105+
![Simulation testing results](/assets/images/adv-moveit-manipulator-planning/simulation_testing.png)
106+
107+
This helped us quantify exactly how the overall system may fail due to lack of reachability for either arms, and how to position our platform in front of peppers during the Fall Validation Demo.
108+
109+
## Conclusion
110+
111+
With the use of a combination of the two planners, as well as repeated testing, we were able to create a robust planning subsystem for our dual-armed system. We hope our findings are useful for future teams using MoveIt for articulated arms!

wiki/planning/index.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ We are actively seeking contributions to expand the resources available in this
1111

1212
## Key Subsections and Highlights
1313

14+
- **[Advanced MoveIt usage for Manipulator Motion Planning](/wiki/planning/advanced-moveit-manipulator-planning/)**
15+
Discusses motion planning for dual XArm 7 manipulators using RRTStar and Cartesian planners. Includes details on custom cost objectives and testing in simulation.
16+
1417
- **[A* Implementation Guide](/wiki/planning/astar_planning_implementation_guide/)**
1518
A step-by-step tutorial on implementing the A* algorithm for robot motion planning. Covers key concepts such as heuristic design, map representation, and non-holonomic motion primitives for Ackermann vehicles.
1619

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
---
2+
# Jekyll 'Front Matter' goes here. Most are set by default, and should NOT be
3+
# overwritten except in special circumstances.
4+
# You should set the date the article was last updated like this:
5+
date: 2025-05-02 # YYYY-MM-DD
6+
# This will be displayed at the bottom of the article
7+
# You should set the article's title:
8+
title: Gazebo Classic Simulation of Graspable and Breakable Objects
9+
# The 'title' is automatically displayed at the top of the page
10+
# and used in other parts of the site.
11+
---
12+
13+
## Motivation
14+
15+
In order to fulfill our SVD demonstration requirements, a simulator was required to test out bimanual manipulation due to the lack of a second physical arm. While an out-of-the-box solution for a Gazebo Classic simulator is already provided by the xarm-ros repository, which additionally provided the option of attaching one of their officially supported end effectors to the end effector of a single simulated arm, several functionalities were required that needed to be addressed:
16+
17+
* The simulation must include a detachable mechanism, which enables the pepper peduncle to be cut, freeing the pepper from the anchor in world position.
18+
19+
* The end effectors should be attached to the last joint of both arms. The control interface of either end effector should not affect the implementation of the motor control module (and should behave as if the real motors are attached). The planner should take the end effectors into account when planning.
20+
21+
* The pepper should be robustly grasped by the gripper end effector and not cause physics engine glitches or randomly fall from the hand.
22+
23+
### Alternatives
24+
25+
Our team had several choices to start exploring:
26+
27+
* Using a completely new simulator (such as Mujoco). This is discouraged since a partially working solution was already implemented in Gazebo Classic, and creating a simulation from scratch would result in significantly more work than previously expected, causing major hiccups in progress.
28+
29+
* Migrating the existing simulation stack to Ignition Gazebo, which replaces the Gazebo Classic engine. This was an option to be considered due to the fact that the Ignition Gazebo simulator officially features a world in which objects may be detached when a message is published (https://gazebosim.org/api/sim/9/detachablejoints.html). This is explored briefly, but was later abandoned due to 1) the amount of work potentially required to convert all files currently working with Gazebo Classic into Ignition Gazebo standards, and 2) the additional time and logistics required to create a custom plugin that senses the force being applied to the peduncle/fruit, and publishing a message based on the force reaching a limit. Additionally, due to the fact that we are using ROS 1 (Noetic), Ignition Gazebo is only somewhat supported (see https://gazebosim.org/docs/latest/ros_installation/).
30+
31+
* Using Gazebo Classic. While the engine is due for deprecation around January 2025, the community support for Gazebo Classic is overwhelmingly more comprehensive than other options, and the xarm_ros repository files already work with Gazebo Classic. Furthermore, with the files associated with their officially supported gripper, development can be significantly improved by referring to existing known solutions for end effectors and grasping. This was the option our team ended up pursuing.
32+
33+
## Development Journey
34+
35+
First of all, the end effectors had to be included in the scene and attached to the arms, and to do this, we leveraged the [Solidworks to URDF extension](https://wiki.ros.org/sw_urdf_exporter) to export our CAD assembly into an URDF file. The documentation to do this is available at [this Notion guide](https://www.notion.so/Turning-Assemblies-into-URDF-for-RViz-Gazebo-1b6cedb4810780728bdec28add6a1891?pvs=4).
36+
37+
In short, the assembly was significantly simplified, a base link (where the end effector attaches to the arm) is specified, revolute joints were defined and tested, and the files were exported (URDF and STL).
38+
39+
When the URDF files are exported and work as expected, the file structures in xarm_ros were then mimicked with the newly created gripper/cutter URDFs. This included defining several xacro files, including transmission, gazebo, urdf definitions, as well as an overall xacro file importing other xacro files. Additionally, joint controllers were defined in xarm_controller (PID position controllers) in order to move the joints inside Gazebo using gazebo_ros_control. This was verified by publishing to the joint controller channels with desired joint angles and verifying that the joints move in rviz and gazebo (since this infrastructure was already set up).
40+
41+
## Gazebo Classic plugins
42+
43+
To address the other two points regarding the simulator design, two plugins were found to solve 1) detachable joints and 2) object grasping stability.
44+
45+
After some research, a native plugin called libBreakableJointPlugin was found, which allows the definition of a breaking force threshold (beyond which the fixed joint breaks). Some manual tuning was done to ensure when the cutter blades collide into the peduncle the force threshold was met, and to ensure that other forces such as small bumps into the plant or gravity did not trigger this threshold.
46+
47+
```xml
48+
<joint name="breakable" type="revolute">
49+
<parent>peduncle</parent>
50+
<child>fruit</child>
51+
<axis>
52+
<xyz>0 0 1</xyz>
53+
<limit>
54+
<lower>0.0</lower>
55+
<upper>0.0</upper>
56+
</limit>
57+
<use_parent_model_frame>true</use_parent_model_frame>
58+
</axis>
59+
<physics>
60+
<ode>
61+
<erp>1</erp>
62+
<cfm>1</cfm>
63+
</ode>
64+
</physics>
65+
<sensor name="force_torque" type="force_torque">
66+
<always_on>true</always_on>
67+
<update_rate>1000</update_rate>
68+
<plugin name="breakable" filename="libBreakableJointPlugin.so">
69+
<breaking_force_N>10</breaking_force_N>
70+
</plugin>
71+
</sensor>
72+
</joint>
73+
```
74+
75+
Secondly, referring to the existing code in xarm_ros, a third-party library called [libgazebo_grasp_fix](https://github.com/JenniferBuehler/gazebo-pkgs/wiki/The-Gazebo-grasp-fix-plugin) was found, which fixes the object to the gripper given threshold conditions and lets go of the object when the force applied on the object is less than a threshold. This allowed the specification of multiple links (in our case, the gripper fingers and base) to be considered, along with some other options:
76+
77+
```xml
78+
<xacro:macro name="vader_gripper_grasp_fix" params="prefix:='' arm_name:='xarm' palm_link:='link_base'">
79+
<gazebo>
80+
<plugin name="gazebo_grasp_fix" filename="libgazebo_grasp_fix.so">
81+
<arm>
82+
<arm_name>${arm_name}</arm_name>
83+
<palm_link>${palm_link}</palm_link>
84+
<gripper_link>thumb_1</gripper_link>
85+
<gripper_link>fing_1</gripper_link>
86+
<gripper_link>fing_2</gripper_link>
87+
</arm>
88+
<forces_angle_tolerance>110</forces_angle_tolerance>
89+
<update_rate>30</update_rate>
90+
<grip_count_threshold>2</grip_count_threshold>
91+
<max_grip_count>3</max_grip_count>
92+
<release_tolerance>0.01</release_tolerance>
93+
<disable_collisions_on_attach>false</disable_collisions_on_attach>
94+
<contact_topic>__default_topic__</contact_topic>
95+
</plugin>
96+
</gazebo>
97+
</xacro:macro>
98+
```
99+
100+
## Conclusion
101+
102+
With these plugins and a large amount of infrastructure work, Gazebo Classic was successfully configured to simulate a breakable pepper, import URDFs of both end effectors, and allow stable grasp of the pepper in the gripper hand. See [our teaser](https://youtu.be/Uqwh7hMD_l8?si=i2ckLbr7Mejvx8_g&t=135) for a demonstration of the results!

wiki/simulation/index.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ This section focuses on **simulation tools, techniques, and environments** for r
99

1010
## Key Subsections and Highlights
1111

12+
- **[Gazebo Classic Simulation of Graspable and Breakable Objects](/wiki/simulation/gazebo-classic-simulation-of-graspable-and-breakable-objects/)**
13+
Details the setup of a Gazebo Classic simulator for bimanual manipulation, featuring breakable joints and robust grasping plugins.
14+
1215
- **[Building a Light-Weight Custom Simulator](/wiki/simulation/Building-a-Light-Weight-Custom-Simulator/)**
1316
Discusses the design and implementation of a minimal simulator for testing reinforcement learning algorithms. Focuses on simplicity, customizability, and minimal noise. Highlights considerations like minimizing external disturbances, reducing development effort, and maintaining a reliable architecture.
1417

0 commit comments

Comments
 (0)