Skip to content

Commit d0a4b36

Browse files
committed
Add a mujoco simulation
1 parent b939a08 commit d0a4b36

File tree

28 files changed

+763
-13
lines changed

28 files changed

+763
-13
lines changed

ar4_description/urdf/ar4_in_world.urdf.xacro

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
<?xml version="1.0"?>
22
<robot name="ar4_in_world" xmlns:xacro="http://www.ros.org/wiki/xacro">
3-
<!-- standing ar4 robot in world -->
4-
5-
<xacro:include filename="$(find ar4_description)/urdf/ar4.urdf.xacro" />
63

74
<link name="world" />
85

6+
<xacro:include filename="$(find ar4_description)/urdf/ar4.urdf.xacro" />
7+
98
<joint name="joint_world" type="fixed">
109
<parent link="world" />
1110
<child link="base_link" />

ar4_gazebo_sim/urdf/gz_ar4.urdf.xacro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<!-- base model -->
55
<xacro:include filename="$(find ar4_description)/urdf/ar4_in_world.urdf.xacro" />.
66

7-
<!-- ros2_control extensions -->
7+
<!-- gazebo extensions -->
88
<xacro:include filename="$(find ar4_gazebo_sim)/urdf/includes/gazebo.xacro" />
99

1010
<!-- ros2_control extensions -->

ar4_mujoco_bringup/CMakeLists.txt

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# BSD 3-Clause License
2+
#
3+
# Copyright 2025 Ekumen, Inc.
4+
# All rights reserved.
5+
#
6+
# Redistribution and use in source and binary forms, with or without
7+
# modification, are permitted provided that the following conditions are met:
8+
#
9+
# 1. Redistributions of source code must retain the above copyright notice, this
10+
# list of conditions and the following disclaimer.
11+
#
12+
# 2. Redistributions in binary form must reproduce the above copyright notice,
13+
# this list of conditions and the following disclaimer in the documentation
14+
# and/or other materials provided with the distribution.
15+
#
16+
# 3. Neither the name of the copyright holder nor the names of its
17+
# contributors may be used to endorse or promote products derived from
18+
# this software without specific prior written permission.
19+
#
20+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23+
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24+
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25+
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26+
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27+
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28+
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29+
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30+
31+
cmake_minimum_required(VERSION 3.7)
32+
project(ar4_mujoco_bringup)
33+
34+
find_package(ament_cmake REQUIRED)
35+
36+
install(DIRECTORY launch DESTINATION share/${PROJECT_NAME}/)
37+
38+
ament_package()

ar4_mujoco_bringup/LICENSE

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
BSD 3-Clause License
2+
3+
Copyright (c) 2025, Ekumen Inc.
4+
All rights reserved.
5+
6+
Redistribution and use in source and binary forms, with or without
7+
modification, are permitted provided that the following conditions are met:
8+
9+
1. Redistributions of source code must retain the above copyright notice, this
10+
list of conditions and the following disclaimer.
11+
12+
2. Redistributions in binary form must reproduce the above copyright notice,
13+
this list of conditions and the following disclaimer in the documentation
14+
and/or other materials provided with the distribution.
15+
16+
3. Neither the name of the copyright holder nor the names of its
17+
contributors may be used to endorse or promote products derived from
18+
this software without specific prior written permission.
19+
20+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# BSD 3-Clause License
2+
#
3+
# Copyright 2025 Ekumen, Inc.
4+
# All rights reserved.
5+
#
6+
# Redistribution and use in source and binary forms, with or without
7+
# modification, are permitted provided that the following conditions are met:
8+
#
9+
# 1. Redistributions of source code must retain the above copyright notice, this
10+
# list of conditions and the following disclaimer.
11+
#
12+
# 2. Redistributions in binary form must reproduce the above copyright notice,
13+
# this list of conditions and the following disclaimer in the documentation
14+
# and/or other materials provided with the distribution.
15+
#
16+
# 3. Neither the name of the copyright holder nor the names of its
17+
# contributors may be used to endorse or promote products derived from
18+
# this software without specific prior written permission.
19+
#
20+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23+
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24+
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25+
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26+
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27+
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28+
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29+
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30+
31+
"""launch file for integrating Gazebo with MoveIt for the AR4 robot."""
32+
33+
from launch import LaunchDescription
34+
from launch_ros.actions import SetParameter
35+
from launch_ros.substitutions import FindPackageShare
36+
from launch.actions import IncludeLaunchDescription
37+
from launch.launch_description_sources import PythonLaunchDescriptionSource
38+
from launch.substitutions import PathJoinSubstitution
39+
40+
41+
def generate_launch_description():
42+
use_sim_time_param = SetParameter(name="use_sim_time", value=True)
43+
44+
common_stack_include = IncludeLaunchDescription(
45+
PythonLaunchDescriptionSource(
46+
PathJoinSubstitution(
47+
[
48+
FindPackageShare("ar4_common"),
49+
"launch",
50+
"main.launch.py",
51+
]
52+
)
53+
)
54+
)
55+
56+
gz_sim_include = IncludeLaunchDescription(
57+
PythonLaunchDescriptionSource(
58+
PathJoinSubstitution(
59+
[
60+
FindPackageShare("ar4_mujoco_sim"),
61+
"launch",
62+
"main.launch.py",
63+
]
64+
)
65+
)
66+
)
67+
68+
return LaunchDescription(
69+
[
70+
use_sim_time_param,
71+
common_stack_include,
72+
gz_sim_include,
73+
]
74+
)

ar4_mujoco_bringup/package.xml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0"?>
2+
<package format="3">
3+
<name>ar4_mujoco_bringup</name>
4+
<version>0.0.1</version>
5+
<description>Launch AR4 software against a Mujoco simulation of the robot</description>
6+
<author email="glpuga@ekumenlabs.com">Gerardo Puga</author>
7+
<maintainer email="glpuga@ekumenlabs.com">Gerardo Puga</maintainer>
8+
<license file="LICENSE">BSD-3-Clause</license>
9+
10+
<buildtool_depend>ament_cmake</buildtool_depend>
11+
12+
<exec_depend>ar4_common</exec_depend>
13+
<exec_depend>ar4_mujoco_sim</exec_depend>
14+
<exec_depend>ros2launch</exec_depend>
15+
16+
<export>
17+
<build_type>ament_cmake</build_type>
18+
</export>
19+
</package>

ar4_mujoco_sim/CMakeLists.txt

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# BSD 3-Clause License
2+
#
3+
# Copyright 2025 Ekumen, Inc.
4+
# All rights reserved.
5+
#
6+
# Redistribution and use in source and binary forms, with or without
7+
# modification, are permitted provided that the following conditions are met:
8+
#
9+
# 1. Redistributions of source code must retain the above copyright notice, this
10+
# list of conditions and the following disclaimer.
11+
#
12+
# 2. Redistributions in binary form must reproduce the above copyright notice,
13+
# this list of conditions and the following disclaimer in the documentation
14+
# and/or other materials provided with the distribution.
15+
#
16+
# 3. Neither the name of the copyright holder nor the names of its
17+
# contributors may be used to endorse or promote products derived from
18+
# this software without specific prior written permission.
19+
#
20+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23+
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24+
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25+
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26+
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27+
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28+
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29+
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30+
31+
cmake_minimum_required(VERSION 3.7)
32+
project(ar4_mujoco_sim)
33+
34+
find_package(ament_cmake REQUIRED)
35+
36+
install(DIRECTORY launch mjcf urdf DESTINATION share/${PROJECT_NAME}/)
37+
38+
ament_package()

ar4_mujoco_sim/LICENSE

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
BSD 3-Clause License
2+
3+
Copyright (c) 2025, Ekumen Inc.
4+
All rights reserved.
5+
6+
Redistribution and use in source and binary forms, with or without
7+
modification, are permitted provided that the following conditions are met:
8+
9+
1. Redistributions of source code must retain the above copyright notice, this
10+
list of conditions and the following disclaimer.
11+
12+
2. Redistributions in binary form must reproduce the above copyright notice,
13+
this list of conditions and the following disclaimer in the documentation
14+
and/or other materials provided with the distribution.
15+
16+
3. Neither the name of the copyright holder nor the names of its
17+
contributors may be used to endorse or promote products derived from
18+
this software without specific prior written permission.
19+
20+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

ar4_mujoco_sim/README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Description
2+
A Gazebo simulation of the AR4 Package.
3+
4+
To build the package, run
5+
`colcon build`
6+
7+
To run the simulation, source and run
8+
`ros2 launch ar4_mujoco_sim ar4_sim.launch.py`
9+
10+
#### Launch file arguments
11+
- 'rsp':
12+
- Run [`robot state publisher`](https://github.com/ros/robot_state_publisher) node. (default: 'false')
13+
- 'rviz':
14+
- Start RViz. (default: 'false')
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
#!/usr/bin/env python3
2+
3+
# BSD 3-Clause License
4+
#
5+
# Copyright 2025 Ekumen, Inc.
6+
# All rights reserved.
7+
#
8+
# Redistribution and use in source and binary forms, with or without
9+
# modification, are permitted provided that the following conditions are met:
10+
#
11+
# 1. Redistributions of source code must retain the above copyright notice, this
12+
# list of conditions and the following disclaimer.
13+
#
14+
# 2. Redistributions in binary form must reproduce the above copyright notice,
15+
# this list of conditions and the following disclaimer in the documentation
16+
# and/or other materials provided with the distribution.
17+
#
18+
# 3. Neither the name of the copyright holder nor the names of its
19+
# contributors may be used to endorse or promote products derived from
20+
# this software without specific prior written permission.
21+
#
22+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
25+
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
26+
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27+
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
28+
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29+
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30+
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31+
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32+
33+
34+
from ament_index_python.packages import get_package_share_directory
35+
from launch import LaunchDescription
36+
from launch_ros.actions import Node
37+
import xacro
38+
39+
import os
40+
41+
42+
def get_robot_description():
43+
return
44+
45+
46+
def generate_launch_description():
47+
this_pkg_share = get_package_share_directory("ar4_mujoco_sim")
48+
49+
robot_description_file = os.path.join(
50+
this_pkg_share,
51+
"urdf",
52+
"mj_ar4.urdf.xacro",
53+
)
54+
55+
robot_description_urdf = xacro.process_file(robot_description_file).toprettyxml(
56+
indent=" "
57+
)
58+
59+
mujoco_model = os.path.join(
60+
this_pkg_share,
61+
"mjcf",
62+
"scene.xml",
63+
)
64+
65+
controller_config_file = os.path.join(
66+
get_package_share_directory("ar4_moveit_config"),
67+
"config",
68+
"ros2_controllers.yaml",
69+
)
70+
71+
mujoco_ros2_control_params = {
72+
"robot_description": robot_description_urdf,
73+
"mujoco_model_path": mujoco_model,
74+
}
75+
76+
mujoco_sim_node = Node(
77+
package="mujoco_ros2_control",
78+
executable="mujoco_ros2_control",
79+
output="screen",
80+
parameters=[
81+
mujoco_ros2_control_params,
82+
controller_config_file,
83+
],
84+
)
85+
86+
# this nodes is launched with the HAL-specific nodes because we need to load
87+
# the simulation specific version
88+
robot_state_publisher_node = Node(
89+
package="robot_state_publisher",
90+
executable="robot_state_publisher",
91+
name="robot_state_publisher",
92+
output="screen",
93+
parameters=[
94+
{
95+
"robot_description": robot_description_urdf,
96+
}
97+
],
98+
)
99+
100+
spawn_joint_state_broadcaster_controller = Node(
101+
package="controller_manager",
102+
executable="spawner",
103+
arguments=["joint_state_broadcaster"],
104+
output="screen",
105+
)
106+
107+
spawn_joint_trajectory_controller = Node(
108+
package="controller_manager",
109+
executable="spawner",
110+
arguments=["arm_controller"],
111+
output="screen",
112+
)
113+
114+
return LaunchDescription(
115+
[
116+
mujoco_sim_node,
117+
robot_state_publisher_node,
118+
spawn_joint_state_broadcaster_controller,
119+
spawn_joint_trajectory_controller,
120+
]
121+
)

0 commit comments

Comments
 (0)