Skip to content

Commit ecb96f5

Browse files
Karsten1987olivier-stassebmagyar
authored
Gazebo support (#85)
* [ros2_control_demo_robot] Add gazebo for rrbot position_only demo. * [ros2_control_demo_robot] Add missing launch file and controller position file. * [ros2_control_demo_robot] Makes flake8 happy for rrbot_system_position_only_gazebo.launch.py * [ros2_control_demo_robot] Fix year in Copyright notice of gazebo launch file. * [package.xml] Adding xacro dependency * [ros2_control_demo_hardware] Fix entity name when launching gazebo for rrbot. * [ros2_control_demo_robot] Change xacro parameter simu to use_simu * use generic dependency * organize urdf files to work with gazebo * start gazebo non-verbose * correctly format urdf xacro * use spawner script to load controller * fix python imports, run precommit Co-authored-by: Olivier Stasse <[email protected]> Co-authored-by: Bence Magyar <[email protected]>
1 parent 4cb4898 commit ecb96f5

13 files changed

+586
-222
lines changed

ros2_control_demo_robot/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,7 @@ if(BUILD_TESTING)
2323
find_package(ament_cmake_gtest REQUIRED)
2424
endif()
2525

26+
ament_environment_hooks("${CMAKE_CURRENT_SOURCE_DIR}/env-hooks/${PROJECT_NAME}.dsv.in")
27+
2628
## EXPORTS
2729
ament_package()
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
controller_manager:
2+
ros__parameters:
3+
update_rate: 100 # Hz
4+
5+
joint_trajectory_controller:
6+
type: joint_trajectory_controller/JointTrajectoryController
7+
8+
joint_state_broadcaster:
9+
type: joint_state_broadcaster/JointStateBroadcaster
10+
11+
joint_trajectory_controller:
12+
ros__parameters:
13+
joints:
14+
- joint1
15+
- joint2
16+
interface_name: position

ros2_control_demo_robot/description/rrbot/rrbot.gazebo.xacro renamed to ros2_control_demo_robot/description/rrbot/gazebo/rrbot.gazebo.xacro

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,8 @@ https://github.com/ros-simulation/gazebo_ros_demos/blob/kinetic-devel/rrbot_desc
99

1010
<!-- ros_control plugin -->
1111
<gazebo>
12-
<plugin name="gazebo_ros_control" filename="libgazebo_ros_control.so">
13-
<robotNamespace>/rrbot</robotNamespace>
14-
<robotSimType>gazebo_ros_control/DefaultRobotHWSim</robotSimType>
12+
<plugin name="gazebo_ros2_control" filename="libgazebo_ros2_control.so">
13+
<parameters>$(find ros2_control_demo_robot)/config/rrbot_gazebo_forward_controller_position.yaml</parameters>
1514
</plugin>
1615
</gazebo>
1716

@@ -71,7 +70,7 @@ https://github.com/ros-simulation/gazebo_ros_demos/blob/kinetic-devel/rrbot_desc
7170
<stddev>0.01</stddev>
7271
</noise>
7372
</ray>
74-
<plugin name="gazebo_ros_head_hokuyo_controller" filename="libgazebo_ros_gpu_laser.so">
73+
<plugin name="gazebo_ros_head_hokuyo_controller" filename="libgazebo_ros_ray_sensor.so">
7574
<topicName>/rrbot/laser/scan</topicName>
7675
<frameName>hokuyo_link</frameName>
7776
</plugin>

ros2_control_demo_robot/description/rrbot/meshes/hokuyo.dae

Lines changed: 253 additions & 0 deletions
Large diffs are not rendered by default.

ros2_control_demo_robot/description/rrbot/rrbot_system_position_only.ros2_control.xacro renamed to ros2_control_demo_robot/description/rrbot/ros2_control/rrbot_system_position_only.ros2_control.xacro

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,24 @@
11
<?xml version="1.0"?>
22
<robot xmlns:xacro="http://www.ros.org/wiki/xacro">
33

4-
<xacro:macro name="rrbot_system_position_only" params="name prefix slowdown:=2.0">
4+
<xacro:macro name="rrbot_system_position_only" params="name prefix use_sim:='false' slowdown:=2.0">
55

66
<ros2_control name="${name}" type="system">
7-
<hardware>
8-
<plugin>ros2_control_demo_hardware/RRBotSystemPositionOnlyHardware</plugin>
9-
<param name="example_param_hw_start_duration_sec">2.0</param>
10-
<param name="example_param_hw_stop_duration_sec">3.0</param>
11-
<param name="example_param_hw_slowdown">${slowdown}</param>
12-
</hardware>
7+
8+
<xacro:if value="$(arg use_sim)">
9+
<hardware>
10+
<plugin>gazebo_ros2_control/GazeboSystem</plugin>
11+
</hardware>
12+
</xacro:if>
13+
<xacro:unless value="$(arg use_sim)">
14+
<hardware>
15+
<plugin>ros2_control_demo_hardware/RRBotSystemPositionOnlyHardware</plugin>
16+
<param name="example_param_hw_start_duration_sec">2.0</param>
17+
<param name="example_param_hw_stop_duration_sec">3.0</param>
18+
<param name="example_param_hw_slowdown">${slowdown}</param>
19+
</hardware>
20+
</xacro:unless>
21+
1322
<joint name="joint1">
1423
<command_interface name="position">
1524
<param name="min">-1</param>

ros2_control_demo_robot/description/rrbot/rrbot.urdf.xacro

Lines changed: 0 additions & 204 deletions
This file was deleted.

ros2_control_demo_robot/description/rrbot_system_position_only.urdf.xacro renamed to ros2_control_demo_robot/description/rrbot/rrbot_system_position_only.urdf.xacro

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,22 @@ Copied and modified from ROS1 example:
55
https://github.com/ros-simulation/gazebo_ros_demos/blob/kinetic-devel/rrbot_description/urdf/rrbot.xacro
66
-->
77
<robot xmlns:xacro="http://www.ros.org/wiki/xacro" name="2dof_robot">
8+
<xacro:arg name="use_sim" default="false" />
89

910
<!-- Enable setting arguments from the launch file -->
1011
<xacro:arg name="slowdown" default="2.0" />
1112

1213
<!-- Import RRBot macro -->
13-
<xacro:include filename="$(find ros2_control_demo_robot)/description/rrbot/rrbot.urdf.xacro" />
14+
<xacro:include filename="$(find ros2_control_demo_robot)/description/rrbot/urdf/rrbot.urdf.xacro" />
1415

1516
<!-- Import all Gazebo-customization elements, including Gazebo colors -->
16-
<xacro:include filename="$(find ros2_control_demo_robot)/description/rrbot/rrbot.gazebo.xacro" />
17+
<xacro:include filename="$(find ros2_control_demo_robot)/description/rrbot/gazebo/rrbot.gazebo.xacro" />
1718

1819
<!-- Import Rviz colors -->
19-
<xacro:include filename="$(find ros2_control_demo_robot)/description/rrbot/rrbot.materials.xacro" />
20+
<xacro:include filename="$(find ros2_control_demo_robot)/description/rrbot/gazebo/rrbot.materials.xacro" />
2021

2122
<!-- Import RRBot ros2_control description -->
22-
<xacro:include filename="$(find ros2_control_demo_robot)/description/rrbot/rrbot_system_position_only.ros2_control.xacro" />
23+
<xacro:include filename="$(find ros2_control_demo_robot)/description/rrbot/ros2_control/rrbot_system_position_only.ros2_control.xacro" />
2324

2425
<!-- Used for fixing robot -->
2526
<link name="world"/>
@@ -33,6 +34,5 @@ https://github.com/ros-simulation/gazebo_ros_demos/blob/kinetic-devel/rrbot_desc
3334

3435
<xacro:rrbot_gazebo prefix="" />
3536

36-
<xacro:rrbot_system_position_only name="RRBotSystemPositionOnly" prefix="" slowdown="$(arg slowdown)" />
37-
37+
<xacro:rrbot_system_position_only name="RRBotSystemPositionOnly" prefix="" use_sim="$(arg use_sim)" slowdown="$(arg slowdown)" />
3838
</robot>

0 commit comments

Comments
 (0)