# Build a MuJoCo + ROS2 Robotic Arm Workflow for Embodied AI

**URL:** <https://discourse.openrobotics.org/t/build-a-mujoco-ros2-robotic-arm-workflow-for-embodied-ai/55012>\
**Category:** ROS General\
**Tags:** ros2, simulation, mujoco\
**Created:** [May 22, 2026, 10:19am UTC](https://discourse.openrobotics.org/t/build-a-mujoco-ros2-robotic-arm-workflow-for-embodied-ai/55012 "2026-05-22T10:19:28Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Agilex\_Robotics](https://sea2.discourse-cdn.com/flex022/user_avatar/discourse.openrobotics.org/agilex_robotics/32/10554_2.png) [@Agilex\_Robotics](https://discourse.openrobotics.org/u/Agilex_Robotics)\
**Post date:** [May 22, 2026, 10:19am UTC](https://discourse.openrobotics.org/t/build-a-mujoco-ros2-robotic-arm-workflow-for-embodied-ai/55012/1 "2026-05-22T10:19:28Z")

</div>

# MuJoCo Simulation and ROS2 Control Workflow | Piper Robotic Arm for Embodied AI

This project is a **MuJoCo-based simulation foundation** for the **Piper robotic arm**. It is designed to provide a general-purpose MuJoCo simulation environment for the Piper arm, with support for robot control testing and simulation workflow development.

**Project has already completed**

- the launch of the C++ based simulation environment
- control testing of the simulated robot using a test ROS 2 control plugin

**Recommended Environment**

- **Operating System** : Ubuntu 22.04 or compatible Linux distribution
- **ROS Version** : ROS 2 Humble
- **Compiler** : C++17 or later

**Reference & Resources**

- **Reference Project** : `https://github.com/unitreerobotics/unitree_mujoco`
- **PiPER robotic arm platform** : `https://global.agilex.ai/products/piper`

The following sections provide step-by-step guidance for building the current version of the **Piper MuJoCo simulation environment** and using the **ROS 2 test plugin** to control the robot in simulation.

![2026-05-06 15-21-26](https://us1.discourse-cdn.com/flex022/uploads/ros/original/3X/3/e/3e8d4b40ff8eb8970e64f8a638220d98e06e4007.gif)

* * *

## 1.Project File Structure

```auto
agilex@agilex-Bellator-N176B:~/project/agilex_arm_mujoco$ tree -L 3
├── agilex_arm
│ └── agilex_piper
│ ├── assets
│ ├── piper_body.xml
│ ├── piper.png
│ ├── piper.xml
│ └── scene.xml
├── images
│ ├── mujoco_piper.png
│ └── piper.png
├── README_EN.md
├── readme.md
└── simulate
    ├── CMakeLists.txt
    ├── config.yaml
    ├── mujoco
    │ ├── bin
    │ ├── include
    │ ├── lib
    │ ├── model
    │ ├── sample
    │ ├── simulate
    │ └── THIRD_PARTY_NOTICES
    └── src
        ├── lodepng
        ├── main.cc
        ├── param.h
        ├── plugin_manager.cc
        ├── plugin_manager.h
        ├── ros2_control_plugin.cc
        ├── ros2_control_plugin.h
        └── sim_plugin.h

```

* * *

## 2.Project Setup & Build

### 2.1 Build the `agilex_arm_mujoco` Project

The build process for the `agilex_arm_mujoco` project follows the same workflow as the `unitree_mujoco` project.  
This section provides a step-by-step guide to setting up the simulation base, including optional instructions for enabling the ROS 2 control plugin.

#### Step 1.Clone the Repository

First, create a working directory and clone the project repository:

```bash
mkdir agilex_arm && cd agilex_arm
git clone https://github.com/yanyuze1/agilex_arm_mujoco.git

```

> By default, the project includes MuJoCo 3.3.0 for ROS 2 control testing.  
> If you want to use a different MuJoCo version, download and replace it manually before building.

#### Step 2. Two Build Modes

The agilex\_arm\_mujoco project supports two build modes:

- **Option 1: Build without the ROS 2 plugin**
- **Option 2: Build with the ROS 2 plugin enabled**

Choose the mode based on your development needs.

**Option 1: Without the ROS 2 Plugin**

- **Step 1** : Edit `agilex_mujoco/simulate/CMakeLists.txt`, change the default enabled ros2 plugin mode to `OFF`

```bash
# from
option(AGILEX_ENABLE_ROS2_CONTROL "Build ROS2 control plugin" ON)
# change to
option(AGILEX_ENABLE_ROS2_CONTROL "Build ROS2 control plugin" OFF)

```

- **Step 2** : Build the Project. After editing the file, build the simulation base:

```bash
cd agilex_arm_mujoco/simulate
mkdir build && cd build
cmake ..
make -j4

```

**Option 2: With the ROS 2 Plugin Enabled**

If you want to test robot control through the ROS 2 plugin, keep the default configuration and build the required ROS 2 dependencies first.

- **Step 1** : Clone the Dependency Workspace  
Create or enter the `agilex_arm` directory and clone the repository:

```bash
cd agilex_arm
git clone https://github.com/yanyuze1/agilex_ws.git

```

- **Step 2: Build ROS 2 Dependencies**  
Build the required packages in the ROS 2 workspace:

```bash
cd agilex_ws
colcon build --symlink-install --packages-up-to mujoco_ros2_control agilex_piper_mujoco
source install/setup.bash

```

- **Step 3: Build the Simulation Base**  
After the dependency build is complete, compile the simulation project:

```bash
cd agilex_mujoco/simulate
mkdir build && cd build
cmake ..
make -j4

```

* * *

### 2.2 Run the agilex\_arm\_mujoco Project

The agilex\_arm\_mujoco project provides two runtime modes:

- **Start the simulation base only**
- **Start the simulation base with the ROS 2 plugin enabled**

Choose the mode according to your development and testing needs.

#### 2.2.1 Start the Simulation Base Only

If you only want to launch the simulation environment without ROS 2 integration, use the following command:

```bash
./agilex_mujoco -h
./agilex_mujoco -r piper -s scene.xml
./agilex_mujoco -r piper -s scene.xml -p ros2_control

```

After successful execution, the MuJoCo simulation environment will launch automatically, displaying the Piper robotic arm in the MuJoCo simulation scene.

 ![image](https://us1.discourse-cdn.com/flex022/uploads/ros/original/3X/a/5/a51857eebeb7863d79d3da66aff711d4e53ccd2e.jpeg)

#### 2.2.2 Start the Simulation Base with the ROS 2 Plugin Enabled

If you only want to launch the simulation environment with ROS 2 integration, use the following command:

```bash
cd agilex_ws
source install/setup.bash
ros2 launch agilex_piper_mujoco bringup_agilex_mujoco_cartesian_motion_controller.launch.py agilex_mujoco_exec:=/home/agilex/project/piper/agilex_mujoco/simulate/build/agilex_mujoco # The current project uses absolute paths. Please modify them according to your own local path.

```

When the launch is successful, a MuJoCo simulation window will open and display the Piper robotic arm in the simulation environment.

Once the environment is fully loaded, you can start sending ROS 2 control commands.

 ![image](https://us1.discourse-cdn.com/flex022/uploads/ros/original/3X/a/4/a48d7977aaef02a6ee0bba6aaa5453ade5b2439d.jpeg)

**Usage Situation**

**1. Send a Target End-Effector Pose**  
Use the following command to publish a target pose for the end effector:

```bash
ros2 topic pub --once /agilex_piper_cartesian_motion_controller/target_frame \
  geometry_msgs/msg/PoseStamped "{
    header: {frame_id: 'base_link'},
    pose: {
      position: {x: 0.2, y: 0.0, z: 0.2},
      orientation: {x: 0.0, y: 1.0, z: 0.0, w: 0.0}
    }
  }"

```

![2026-05-06 16-15-04](https://us1.discourse-cdn.com/flex022/uploads/ros/original/3X/6/b/6bea9c948746cc8857da1cad9dc345907fff3e3e.gif)

**2. Control the Gripper**

```bash
# Open the Gripper
ros2 topic pub --once /agilex_piper_gripper_position_controller/commands \
  std_msgs/msg/Float64MultiArray "{data: [0.035, -0.035]}"

# Close the Gripper
ros2 topic pub --once /agilex_piper_gripper_position_controller/commands \
  std_msgs/msg/Float64MultiArray "{data: [0.0, 0.0]}"

```

![2026-05-06 16-17-31](https://us1.discourse-cdn.com/flex022/uploads/ros/original/3X/c/0/c03191728c101769f4ced0c7cddd821072c761f9.gif)

**3. Check the Robot State**  
To view the current end-effector pose, use:

```bash
ros2 topic echo /agilex_piper_cartesian_motion_controller/current_pose

```

 ![image](https://us1.discourse-cdn.com/flex022/uploads/ros/original/3X/f/d/fd358b46b60fe56cd19010ed4eeb4f737024dadc.png)

## 3.Afterword

This project is built upon and integrated from several open-source repositories. The main credit goes to the original authors and the open-source community.

We would like to sincerely thank the open-source community for making these technologies accessible through shared code and practical experience.

## 💬 MuJoCo + ROS2 Robotic Manipulation FAQ

### 1. Why use MuJoCo for the Piper robotic arm instead of Gazebo or Isaac Sim?

MuJoCo provides a lightweight and high-performance physics simulation workflow, making it ideal for rapid robotics prototyping, control validation, and future reinforcement learning research. Compared with heavier simulators, it can run efficiently on more accessible hardware.

### 2. Can this simulation workflow be transferred to a real Piper robotic arm?

Yes. The ROS2 control architecture is designed to align simulation and real hardware interfaces, making future sim-to-real deployment more practical.

### 3. Why build a custom MuJoCo + ROS2 workflow instead of using existing robotics simulators?

This project focuses on providing a simpler and more flexible robotics development workflow with lower hardware requirements and easier customization for developers and researchers.

### 4. Is this MuJoCo robotic arm project suitable for reinforcement learning (RL)?

Yes. The simulation framework can serve as a foundation for reinforcement learning workflows such as PPO training, imitation learning, grasping policy development, and sim-to-real robotic manipulation research.

### 5. How does ROS2 Control work with MuJoCo simulation?

The project integrates ROS2 Control plugins into the MuJoCo simulation environment, allowing developers to send ROS2 motion commands directly to the simulated robotic arm and receive real-time robot state feedback.

### Still Have Question?

If you encounter any issues with environment installation, parameter configuration, or RL training, feel free to leave your questions for further discussion.

---

<div class="post-metadata">

**Author:** ![christian](https://sea2.discourse-cdn.com/flex022/user_avatar/discourse.openrobotics.org/christian/32/14876_2.png) [@christian](https://discourse.openrobotics.org/u/christian)\
**Post date:** [May 22, 2026, 11:29am UTC](https://discourse.openrobotics.org/t/build-a-mujoco-ros2-robotic-arm-workflow-for-embodied-ai/55012/2 "2026-05-22T11:29:18Z")

</div>

Are you aware of [`mujoco_ros2_control`](https://github.com/ros-controls/mujoco_ros2_control)? It integrates directly as a `hardware_interface::SystemInterface` into the ros2\_control stack. With the MuJoCo models that you provide in [unitree\_mujoco/unitree\_robots at main · unitreerobotics/unitree\_mujoco · GitHub](https://github.com/unitreerobotics/unitree_mujoco/tree/main/unitree_robots), you should be able to replicate this natively in the ROS 2 control stack.

---

<div class="post-metadata">

**Author:** ![Agilex\_Robotics](https://sea2.discourse-cdn.com/flex022/user_avatar/discourse.openrobotics.org/agilex_robotics/32/10554_2.png) [@Agilex\_Robotics](https://discourse.openrobotics.org/u/Agilex_Robotics)\
**Post date:** [May 26, 2026, 1:53am UTC](https://discourse.openrobotics.org/t/build-a-mujoco-ros2-robotic-arm-workflow-for-embodied-ai/55012/3 "2026-05-26T01:53:48Z")

</div>

Thank you for pointing out this! We will review your suggestion and work on further improvements.

---

<div class="post-metadata">

**Author:** ![scastro](https://sea2.discourse-cdn.com/flex022/user_avatar/discourse.openrobotics.org/scastro/32/13805_2.png) [@scastro](https://discourse.openrobotics.org/u/scastro)\
**Post date:** [May 26, 2026, 1:59am UTC](https://discourse.openrobotics.org/t/build-a-mujoco-ros2-robotic-arm-workflow-for-embodied-ai/55012/4 "2026-05-26T01:59:25Z")

</div>

It seems this repo uses an older version from Google Summer of Code:

> **[agilex\_ws/src/mujoco\_ros2\_control at main · yanyuze1/agilex\_ws](https://github.com/yanyuze1/agilex_ws/tree/main/src/mujoco_ros2_control)**
>
> main/src/mujoco\_ros2\_control

Copied from [GitHub - moveit/mujoco\_ros2\_control · GitHub](https://github.com/moveit/mujoco_ros2_control)

---

<div class="post-metadata">

**Author:** ![azeey](https://sea2.discourse-cdn.com/flex022/user_avatar/discourse.openrobotics.org/azeey/32/6795_2.png) [@azeey](https://discourse.openrobotics.org/u/azeey)\
**Post date:** [May 26, 2026, 1:16pm UTC](https://discourse.openrobotics.org/t/build-a-mujoco-ros2-robotic-arm-workflow-for-embodied-ai/55012/5 "2026-05-26T13:16:20Z")

</div>

FYI, Gazebo is also adding support for MuJoCo as part of this year’s roadmap. Tracking issue: [MuJoCo physics engine plugin · Issue #299 · gazebosim/gz-physics · GitHub](https://github.com/gazebosim/gz-physics/issues/299)

---

<div class="post-metadata">

**Author:** ![Agilex\_Robotics](https://sea2.discourse-cdn.com/flex022/user_avatar/discourse.openrobotics.org/agilex_robotics/32/10554_2.png) [@Agilex\_Robotics](https://discourse.openrobotics.org/u/Agilex_Robotics)\
**Post date:** [May 27, 2026, 6:48am UTC](https://discourse.openrobotics.org/t/build-a-mujoco-ros2-robotic-arm-workflow-for-embodied-ai/55012/6 "2026-05-27T06:48:05Z")

</div>

Thanks for pointing that out! While this repo builds on the older GSoC version of `mujoco_ros2_control`, we’ve adapted and tested it thoroughly for our use case, and it has no significant impact on core functionality or simulation behavior.

---

<div class="post-metadata">

**Author:** ![saikishor](https://sea2.discourse-cdn.com/flex022/user_avatar/discourse.openrobotics.org/saikishor/32/26420_2.png) [@saikishor](https://discourse.openrobotics.org/u/saikishor)\
**Post date:** [May 27, 2026, 7:34am UTC](https://discourse.openrobotics.org/t/build-a-mujoco-ros2-robotic-arm-workflow-for-embodied-ai/55012/7 "2026-05-27T07:34:58Z")

</div>

The [mujoco\_ros2\_control](https://github.com/ros-controls/mujoco_ros2_simulation) should be pretty much direct to integrate, similar to the other simulations. Moreover, they are also available as binaries from Humble to Rolling.

---

<div class="post-metadata">

**Author:** ![DC-Engineer.com](https://sea2.discourse-cdn.com/flex022/user_avatar/discourse.openrobotics.org/dc-engineer.com/32/33987_2.png) [@DC-Engineer.com](https://discourse.openrobotics.org/u/DC-Engineer.com)\
**Post date:** [May 29, 2026, 7:38am UTC](https://discourse.openrobotics.org/t/build-a-mujoco-ros2-robotic-arm-workflow-for-embodied-ai/55012/8 "2026-05-29T07:38:30Z")

</div>

Thanks for posting! I’ve got ROS2 control with MuJoCo on my radar as a skill I need to learn.
