From 2a7dfc95bcef1590306513f5cf7a82c4dd4303ad Mon Sep 17 00:00:00 2001 From: Olivier Stasse Date: Sat, 6 Feb 2021 11:20:14 +0100 Subject: [PATCH 1/7] [ros2_control_demo_robot] Add gazebo for rrbot position_only demo. --- .../description/rrbot/rrbot.gazebo.xacro | 5 ++-- ...ot_system_position_only.ros2_control.xacro | 24 ++++++++++++------- .../rrbot_system_position_only.urdf.xacro | 5 ++-- ros2_control_demo_robot/package.xml | 1 + 4 files changed, 22 insertions(+), 13 deletions(-) diff --git a/ros2_control_demo_robot/description/rrbot/rrbot.gazebo.xacro b/ros2_control_demo_robot/description/rrbot/rrbot.gazebo.xacro index bdbc2a7f8..347d6f61f 100644 --- a/ros2_control_demo_robot/description/rrbot/rrbot.gazebo.xacro +++ b/ros2_control_demo_robot/description/rrbot/rrbot.gazebo.xacro @@ -9,9 +9,8 @@ https://github.com/ros-simulation/gazebo_ros_demos/blob/kinetic-devel/rrbot_desc - - /rrbot - gazebo_ros_control/DefaultRobotHWSim + + $(find ros2_control_demo_robot)/controllers/rrbot_gazebo_forward_controller_position.yaml diff --git a/ros2_control_demo_robot/description/rrbot/rrbot_system_position_only.ros2_control.xacro b/ros2_control_demo_robot/description/rrbot/rrbot_system_position_only.ros2_control.xacro index a97ecdeeb..821ee5ba3 100644 --- a/ros2_control_demo_robot/description/rrbot/rrbot_system_position_only.ros2_control.xacro +++ b/ros2_control_demo_robot/description/rrbot/rrbot_system_position_only.ros2_control.xacro @@ -1,15 +1,24 @@ - + - - ros2_control_demo_hardware/RRBotSystemPositionOnlyHardware - 2.0 - 3.0 - 2.0 - + + + + gazebo_ros2_control/GazeboSystem + + + + + ros2_control_demo_hardware/RRBotSystemPositionOnlyHardware + 2.0 + 3.0 + 2.0 + + + -1 @@ -29,4 +38,3 @@ - diff --git a/ros2_control_demo_robot/description/rrbot_system_position_only.urdf.xacro b/ros2_control_demo_robot/description/rrbot_system_position_only.urdf.xacro index c25494ab7..a4a42a527 100644 --- a/ros2_control_demo_robot/description/rrbot_system_position_only.urdf.xacro +++ b/ros2_control_demo_robot/description/rrbot_system_position_only.urdf.xacro @@ -5,7 +5,8 @@ Copied and modified from ROS1 example: https://github.com/ros-simulation/gazebo_ros_demos/blob/kinetic-devel/rrbot_description/urdf/rrbot.xacro --> - + + @@ -34,6 +35,6 @@ https://github.com/ros-simulation/gazebo_ros_demos/blob/kinetic-devel/rrbot_desc - + diff --git a/ros2_control_demo_robot/package.xml b/ros2_control_demo_robot/package.xml index b0c761395..0210c4d6e 100644 --- a/ros2_control_demo_robot/package.xml +++ b/ros2_control_demo_robot/package.xml @@ -14,6 +14,7 @@ hardware_interface pluginlib rclcpp + gazebo_ros2_control ros2_control_demo_hardware From 67be5c547c3239e7fb2afe31be18ed9b5b9131ce Mon Sep 17 00:00:00 2001 From: Olivier Stasse Date: Sat, 6 Feb 2021 11:23:49 +0100 Subject: [PATCH 2/7] [ros2_control_demo_robot] Add missing launch file and controller position file. --- ...ot_gazebo_forward_controller_position.yaml | 16 +++++ ...rbot_system_position_only_gazebo.launch.py | 62 +++++++++++++++++++ 2 files changed, 78 insertions(+) create mode 100644 ros2_control_demo_robot/controllers/rrbot_gazebo_forward_controller_position.yaml create mode 100644 ros2_control_demo_robot/launch/rrbot_system_position_only_gazebo.launch.py diff --git a/ros2_control_demo_robot/controllers/rrbot_gazebo_forward_controller_position.yaml b/ros2_control_demo_robot/controllers/rrbot_gazebo_forward_controller_position.yaml new file mode 100644 index 000000000..5df0e5d8e --- /dev/null +++ b/ros2_control_demo_robot/controllers/rrbot_gazebo_forward_controller_position.yaml @@ -0,0 +1,16 @@ +controller_manager: + ros__parameters: + update_rate: 100 # Hz + + joint_trajectory_controller: + type: joint_trajectory_controller/JointTrajectoryController + + joint_state_controller: + type: joint_state_controller/JointStateController + +joint_trajectory_controller: + ros__parameters: + joints: + - joint1 + - joint2 + interface_name: position diff --git a/ros2_control_demo_robot/launch/rrbot_system_position_only_gazebo.launch.py b/ros2_control_demo_robot/launch/rrbot_system_position_only_gazebo.launch.py new file mode 100644 index 000000000..6c119f550 --- /dev/null +++ b/ros2_control_demo_robot/launch/rrbot_system_position_only_gazebo.launch.py @@ -0,0 +1,62 @@ +# Copyright 2020 Open Source Robotics Foundation, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import os + +from ament_index_python.packages import get_package_share_directory + + +from launch import LaunchDescription +from launch.actions import IncludeLaunchDescription +from launch.launch_description_sources import PythonLaunchDescriptionSource + +from launch_ros.actions import Node + +import xacro + + +def generate_launch_description(): + gazebo = IncludeLaunchDescription( + PythonLaunchDescriptionSource([os.path.join( + get_package_share_directory('gazebo_ros'), 'launch'), '/gazebo.launch.py']), + ) + + ros2_control_demos_path = os.path.join( + get_package_share_directory('ros2_control_demos')) + + robot_description_path = os.path.join( + get_package_share_directory('ros2_control_demo_robot'), + 'description', + 'rrbot_system_position_only.urdf.xacro') + robot_description_config = xacro.process_file(robot_description_path, + mappings={'simu' : 'true'}) + robot_description = {'robot_description': robot_description_config.toxml()} + + node_robot_state_publisher = Node( + package='robot_state_publisher', + executable='robot_state_publisher', + output='screen', + parameters=[robot_description] + ) + + spawn_entity = Node(package='gazebo_ros', executable='spawn_entity.py', + arguments=['-topic', 'robot_description', + '-entity', 'cartpole'], + output='screen') + + return LaunchDescription([ + gazebo, + node_robot_state_publisher, + spawn_entity, + ]) From da5f235cbc37b6ff62effa89d9cd5b60babb7f4d Mon Sep 17 00:00:00 2001 From: Olivier Stasse Date: Sat, 6 Feb 2021 17:43:40 +0100 Subject: [PATCH 3/7] [ros2_control_demo_robot] Makes flake8 happy for rrbot_system_position_only_gazebo.launch.py --- .../launch/rrbot_system_position_only_gazebo.launch.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/ros2_control_demo_robot/launch/rrbot_system_position_only_gazebo.launch.py b/ros2_control_demo_robot/launch/rrbot_system_position_only_gazebo.launch.py index 6c119f550..0ebe3dc47 100644 --- a/ros2_control_demo_robot/launch/rrbot_system_position_only_gazebo.launch.py +++ b/ros2_control_demo_robot/launch/rrbot_system_position_only_gazebo.launch.py @@ -32,15 +32,13 @@ def generate_launch_description(): get_package_share_directory('gazebo_ros'), 'launch'), '/gazebo.launch.py']), ) - ros2_control_demos_path = os.path.join( - get_package_share_directory('ros2_control_demos')) - robot_description_path = os.path.join( get_package_share_directory('ros2_control_demo_robot'), 'description', 'rrbot_system_position_only.urdf.xacro') - robot_description_config = xacro.process_file(robot_description_path, - mappings={'simu' : 'true'}) + robot_description_config = xacro.process_file( + robot_description_path, + mappings={'simu': 'true'}) robot_description = {'robot_description': robot_description_config.toxml()} node_robot_state_publisher = Node( From b18c7803fcb05797b1e96a657d7bb71ca0546e69 Mon Sep 17 00:00:00 2001 From: Olivier Stasse Date: Mon, 8 Feb 2021 14:43:42 +0100 Subject: [PATCH 4/7] [ros2_control_demo_robot] Fix year in Copyright notice of gazebo launch file. --- .../launch/rrbot_system_position_only_gazebo.launch.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ros2_control_demo_robot/launch/rrbot_system_position_only_gazebo.launch.py b/ros2_control_demo_robot/launch/rrbot_system_position_only_gazebo.launch.py index 0ebe3dc47..9923e1c8a 100644 --- a/ros2_control_demo_robot/launch/rrbot_system_position_only_gazebo.launch.py +++ b/ros2_control_demo_robot/launch/rrbot_system_position_only_gazebo.launch.py @@ -1,4 +1,4 @@ -# Copyright 2020 Open Source Robotics Foundation, Inc. +# Copyright 2021 Open Source Robotics Foundation, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. From e6497f1e570cd3e4e2afeb1d4deeaaf6161c1bf3 Mon Sep 17 00:00:00 2001 From: Olivier Stasse Date: Fri, 12 Feb 2021 07:07:43 +0100 Subject: [PATCH 5/7] [package.xml] Adding xacro dependency --- ros2_control_demo_robot/package.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ros2_control_demo_robot/package.xml b/ros2_control_demo_robot/package.xml index 0210c4d6e..4322595a3 100644 --- a/ros2_control_demo_robot/package.xml +++ b/ros2_control_demo_robot/package.xml @@ -16,6 +16,8 @@ rclcpp gazebo_ros2_control + xacro + ros2_control_demo_hardware ament_cmake_gtest From e230567def6007d9b3bfb0c0198f964b2a8cec60 Mon Sep 17 00:00:00 2001 From: Olivier Stasse Date: Fri, 12 Feb 2021 07:10:10 +0100 Subject: [PATCH 6/7] [ros2_control_demo_hardware] Fix entity name when launching gazebo for rrbot. --- .../launch/rrbot_system_position_only_gazebo.launch.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ros2_control_demo_robot/launch/rrbot_system_position_only_gazebo.launch.py b/ros2_control_demo_robot/launch/rrbot_system_position_only_gazebo.launch.py index 9923e1c8a..2ff1fd6f9 100644 --- a/ros2_control_demo_robot/launch/rrbot_system_position_only_gazebo.launch.py +++ b/ros2_control_demo_robot/launch/rrbot_system_position_only_gazebo.launch.py @@ -50,7 +50,7 @@ def generate_launch_description(): spawn_entity = Node(package='gazebo_ros', executable='spawn_entity.py', arguments=['-topic', 'robot_description', - '-entity', 'cartpole'], + '-entity', 'rrbot_system_position'], output='screen') return LaunchDescription([ From 5e726d4f7000c2162c1e647d43d20339fee46f58 Mon Sep 17 00:00:00 2001 From: Olivier Stasse Date: Fri, 12 Feb 2021 07:14:24 +0100 Subject: [PATCH 7/7] [ros2_control_demo_robot] Change xacro parameter simu to use_simu --- .../rrbot/rrbot_system_position_only.ros2_control.xacro | 6 +++--- .../description/rrbot_system_position_only.urdf.xacro | 4 ++-- .../launch/rrbot_system_position_only_gazebo.launch.py | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/ros2_control_demo_robot/description/rrbot/rrbot_system_position_only.ros2_control.xacro b/ros2_control_demo_robot/description/rrbot/rrbot_system_position_only.ros2_control.xacro index 821ee5ba3..633b05e6e 100644 --- a/ros2_control_demo_robot/description/rrbot/rrbot_system_position_only.ros2_control.xacro +++ b/ros2_control_demo_robot/description/rrbot/rrbot_system_position_only.ros2_control.xacro @@ -1,16 +1,16 @@ - + - + gazebo_ros2_control/GazeboSystem - + ros2_control_demo_hardware/RRBotSystemPositionOnlyHardware 2.0 diff --git a/ros2_control_demo_robot/description/rrbot_system_position_only.urdf.xacro b/ros2_control_demo_robot/description/rrbot_system_position_only.urdf.xacro index a4a42a527..9f6c0f5a5 100644 --- a/ros2_control_demo_robot/description/rrbot_system_position_only.urdf.xacro +++ b/ros2_control_demo_robot/description/rrbot_system_position_only.urdf.xacro @@ -5,7 +5,7 @@ Copied and modified from ROS1 example: https://github.com/ros-simulation/gazebo_ros_demos/blob/kinetic-devel/rrbot_description/urdf/rrbot.xacro --> - + @@ -35,6 +35,6 @@ https://github.com/ros-simulation/gazebo_ros_demos/blob/kinetic-devel/rrbot_desc - + diff --git a/ros2_control_demo_robot/launch/rrbot_system_position_only_gazebo.launch.py b/ros2_control_demo_robot/launch/rrbot_system_position_only_gazebo.launch.py index 2ff1fd6f9..0114209d5 100644 --- a/ros2_control_demo_robot/launch/rrbot_system_position_only_gazebo.launch.py +++ b/ros2_control_demo_robot/launch/rrbot_system_position_only_gazebo.launch.py @@ -38,7 +38,7 @@ def generate_launch_description(): 'rrbot_system_position_only.urdf.xacro') robot_description_config = xacro.process_file( robot_description_path, - mappings={'simu': 'true'}) + mappings={'use_sim': 'true'}) robot_description = {'robot_description': robot_description_config.toxml()} node_robot_state_publisher = Node(