From 44924701170e1cf06ab356235eaa0bd251b35daf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20Fr=C3=B6hlich?= Date: Mon, 2 Dec 2024 09:42:02 +0100 Subject: [PATCH 1/3] Add missing bridge for simulation time (#443) (cherry picked from commit 301ca580d0772b9952579a783632500eeca7e53b) # Conflicts: # gz_ros2_control_demos/launch/cart_example_position.launch.py # gz_ros2_control_demos/launch/cart_example_velocity.launch.py # gz_ros2_control_demos/launch/diff_drive_example.launch.py # gz_ros2_control_demos/launch/gripper_mimic_joint_example_effort.launch.py --- .../launch/cart_example_position.launch.py | 117 ++++++++++++++++ .../launch/cart_example_velocity.launch.py | 126 ++++++++++++++++++ .../launch/diff_drive_example.launch.py | 116 ++++++++++++++++ ...ipper_mimic_joint_example_effort.launch.py | 119 +++++++++++++++++ gz_ros2_control_tests/tests/position_test.py | 9 ++ .../launch/ackermann_drive_example.launch.py | 9 ++ .../launch/cart_example_effort.launch.py | 9 ++ .../launch/pendulum_example_effort.launch.py | 9 ++ .../pendulum_example_position.launch.py | 9 ++ 9 files changed, 523 insertions(+) create mode 100644 gz_ros2_control_demos/launch/cart_example_position.launch.py create mode 100644 gz_ros2_control_demos/launch/cart_example_velocity.launch.py create mode 100644 gz_ros2_control_demos/launch/diff_drive_example.launch.py create mode 100644 gz_ros2_control_demos/launch/gripper_mimic_joint_example_effort.launch.py diff --git a/gz_ros2_control_demos/launch/cart_example_position.launch.py b/gz_ros2_control_demos/launch/cart_example_position.launch.py new file mode 100644 index 00000000..c4a78b35 --- /dev/null +++ b/gz_ros2_control_demos/launch/cart_example_position.launch.py @@ -0,0 +1,117 @@ +# 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. +# 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. + +from launch import LaunchDescription +from launch.actions import DeclareLaunchArgument, IncludeLaunchDescription +from launch.actions import RegisterEventHandler +from launch.event_handlers import OnProcessExit +from launch.launch_description_sources import PythonLaunchDescriptionSource +from launch.substitutions import Command, FindExecutable, LaunchConfiguration, PathJoinSubstitution + +from launch_ros.actions import Node +from launch_ros.substitutions import FindPackageShare + + +def generate_launch_description(): + # Launch Arguments + use_sim_time = LaunchConfiguration('use_sim_time', default=True) + + # Get URDF via xacro + robot_description_content = Command( + [ + PathJoinSubstitution([FindExecutable(name='xacro')]), + ' ', + PathJoinSubstitution( + [FindPackageShare('gz_ros2_control_demos'), + 'urdf', 'test_cart_position.xacro.urdf'] + ), + ] + ) + robot_description = {'robot_description': robot_description_content} + robot_controllers = PathJoinSubstitution( + [ + FindPackageShare('gz_ros2_control_demos'), + 'config', + 'cart_controller_position.yaml', + ] + ) + + node_robot_state_publisher = Node( + package='robot_state_publisher', + executable='robot_state_publisher', + output='screen', + parameters=[robot_description] + ) + + gz_spawn_entity = Node( + package='ros_gz_sim', + executable='create', + output='screen', + arguments=['-topic', 'robot_description', + '-name', 'cart', '-allow_renaming', 'true'], + ) + + joint_state_broadcaster_spawner = Node( + package='controller_manager', + executable='spawner', + arguments=['joint_state_broadcaster', + ], + ) + joint_trajectory_controller_spawner = Node( + package='controller_manager', + executable='spawner', + arguments=[ + 'joint_trajectory_controller', + '--param-file', + robot_controllers, + ], + ) + + # Bridge + bridge = Node( + package='ros_gz_bridge', + executable='parameter_bridge', + arguments=['/clock@rosgraph_msgs/msg/Clock[gz.msgs.Clock'], + output='screen' + ) + + return LaunchDescription([ + # Launch gazebo environment + IncludeLaunchDescription( + PythonLaunchDescriptionSource( + [PathJoinSubstitution([FindPackageShare('ros_gz_sim'), + 'launch', + 'gz_sim.launch.py'])]), + launch_arguments=[('gz_args', [' -r -v 4 empty.sdf'])]), + RegisterEventHandler( + event_handler=OnProcessExit( + target_action=gz_spawn_entity, + on_exit=[joint_state_broadcaster_spawner], + ) + ), + RegisterEventHandler( + event_handler=OnProcessExit( + target_action=joint_state_broadcaster_spawner, + on_exit=[joint_trajectory_controller_spawner], + ) + ), + bridge, + node_robot_state_publisher, + gz_spawn_entity, + # Launch Arguments + DeclareLaunchArgument( + 'use_sim_time', + default_value=use_sim_time, + description='If true, use simulated clock'), + ]) diff --git a/gz_ros2_control_demos/launch/cart_example_velocity.launch.py b/gz_ros2_control_demos/launch/cart_example_velocity.launch.py new file mode 100644 index 00000000..4f0a0405 --- /dev/null +++ b/gz_ros2_control_demos/launch/cart_example_velocity.launch.py @@ -0,0 +1,126 @@ +# 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. +# 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. + +from launch import LaunchDescription +from launch.actions import DeclareLaunchArgument, IncludeLaunchDescription +from launch.actions import RegisterEventHandler +from launch.event_handlers import OnProcessExit +from launch.launch_description_sources import PythonLaunchDescriptionSource +from launch.substitutions import Command, FindExecutable, LaunchConfiguration, PathJoinSubstitution + +from launch_ros.actions import Node +from launch_ros.substitutions import FindPackageShare + + +def generate_launch_description(): + # Launch Arguments + use_sim_time = LaunchConfiguration('use_sim_time', default=True) + + # Get URDF via xacro + robot_description_content = Command( + [ + PathJoinSubstitution([FindExecutable(name='xacro')]), + ' ', + PathJoinSubstitution( + [FindPackageShare('gz_ros2_control_demos'), + 'urdf', 'test_cart_velocity.xacro.urdf'] + ), + ] + ) + robot_description = {'robot_description': robot_description_content} + robot_controllers = PathJoinSubstitution( + [ + FindPackageShare('gz_ros2_control_demos'), + 'config', + 'cart_controller_velocity.yaml', + ] + ) + + node_robot_state_publisher = Node( + package='robot_state_publisher', + executable='robot_state_publisher', + output='screen', + parameters=[robot_description] + ) + + gz_spawn_entity = Node( + package='ros_gz_sim', + executable='create', + output='screen', + arguments=['-topic', 'robot_description', + '-name', 'cart', '-allow_renaming', 'true'], + ) + + joint_state_broadcaster_spawner = Node( + package='controller_manager', + executable='spawner', + arguments=['joint_state_broadcaster'], + ) + velocity_controller_spawner = Node( + package='controller_manager', + executable='spawner', + arguments=[ + 'velocity_controller', + '--param-file', + robot_controllers, + ], + ) + imu_sensor_broadcaster_spawner = Node( + package='controller_manager', + executable='spawner', + arguments=[ + 'imu_sensor_broadcaster', + '--param-file', + robot_controllers, + ], + ) + + # Bridge + bridge = Node( + package='ros_gz_bridge', + executable='parameter_bridge', + arguments=['/clock@rosgraph_msgs/msg/Clock[gz.msgs.Clock'], + output='screen' + ) + + return LaunchDescription([ + # Launch gazebo environment + IncludeLaunchDescription( + PythonLaunchDescriptionSource( + [PathJoinSubstitution([FindPackageShare('ros_gz_sim'), + 'launch', + 'gz_sim.launch.py'])]), + launch_arguments=[('gz_args', [' -r -v 3 empty.sdf'])]), + RegisterEventHandler( + event_handler=OnProcessExit( + target_action=gz_spawn_entity, + on_exit=[joint_state_broadcaster_spawner], + ) + ), + RegisterEventHandler( + event_handler=OnProcessExit( + target_action=joint_state_broadcaster_spawner, + on_exit=[velocity_controller_spawner, + imu_sensor_broadcaster_spawner], + ) + ), + bridge, + node_robot_state_publisher, + gz_spawn_entity, + # Launch Arguments + DeclareLaunchArgument( + 'use_sim_time', + default_value=use_sim_time, + description='If true, use simulated clock'), + ]) diff --git a/gz_ros2_control_demos/launch/diff_drive_example.launch.py b/gz_ros2_control_demos/launch/diff_drive_example.launch.py new file mode 100644 index 00000000..21c5afb7 --- /dev/null +++ b/gz_ros2_control_demos/launch/diff_drive_example.launch.py @@ -0,0 +1,116 @@ +# Copyright 2022 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. + +from launch import LaunchDescription +from launch.actions import DeclareLaunchArgument, IncludeLaunchDescription +from launch.actions import RegisterEventHandler +from launch.event_handlers import OnProcessExit +from launch.launch_description_sources import PythonLaunchDescriptionSource +from launch.substitutions import Command, FindExecutable, LaunchConfiguration, PathJoinSubstitution + +from launch_ros.actions import Node +from launch_ros.substitutions import FindPackageShare + + +def generate_launch_description(): + # Launch Arguments + use_sim_time = LaunchConfiguration('use_sim_time', default=True) + + # Get URDF via xacro + robot_description_content = Command( + [ + PathJoinSubstitution([FindExecutable(name='xacro')]), + ' ', + PathJoinSubstitution( + [FindPackageShare('gz_ros2_control_demos'), + 'urdf', 'test_diff_drive.xacro.urdf'] + ), + ] + ) + robot_description = {'robot_description': robot_description_content} + robot_controllers = PathJoinSubstitution( + [ + FindPackageShare('gz_ros2_control_demos'), + 'config', + 'diff_drive_controller_velocity.yaml', + ] + ) + + node_robot_state_publisher = Node( + package='robot_state_publisher', + executable='robot_state_publisher', + output='screen', + parameters=[robot_description] + ) + + gz_spawn_entity = Node( + package='ros_gz_sim', + executable='create', + output='screen', + arguments=['-topic', 'robot_description', '-name', + 'diff_drive', '-allow_renaming', 'true'], + ) + + joint_state_broadcaster_spawner = Node( + package='controller_manager', + executable='spawner', + arguments=['joint_state_broadcaster'], + ) + diff_drive_base_controller_spawner = Node( + package='controller_manager', + executable='spawner', + arguments=[ + 'diff_drive_base_controller', + '--param-file', + robot_controllers, + ], + ) + + # Bridge + bridge = Node( + package='ros_gz_bridge', + executable='parameter_bridge', + arguments=['/clock@rosgraph_msgs/msg/Clock[gz.msgs.Clock'], + output='screen' + ) + + return LaunchDescription([ + # Launch gazebo environment + IncludeLaunchDescription( + PythonLaunchDescriptionSource( + [PathJoinSubstitution([FindPackageShare('ros_gz_sim'), + 'launch', + 'gz_sim.launch.py'])]), + launch_arguments=[('gz_args', [' -r -v 4 empty.sdf'])]), + RegisterEventHandler( + event_handler=OnProcessExit( + target_action=gz_spawn_entity, + on_exit=[joint_state_broadcaster_spawner], + ) + ), + RegisterEventHandler( + event_handler=OnProcessExit( + target_action=joint_state_broadcaster_spawner, + on_exit=[diff_drive_base_controller_spawner], + ) + ), + bridge, + node_robot_state_publisher, + gz_spawn_entity, + # Launch Arguments + DeclareLaunchArgument( + 'use_sim_time', + default_value=use_sim_time, + description='If true, use simulated clock'), + ]) diff --git a/gz_ros2_control_demos/launch/gripper_mimic_joint_example_effort.launch.py b/gz_ros2_control_demos/launch/gripper_mimic_joint_example_effort.launch.py new file mode 100644 index 00000000..e074e869 --- /dev/null +++ b/gz_ros2_control_demos/launch/gripper_mimic_joint_example_effort.launch.py @@ -0,0 +1,119 @@ +# Copyright 2022 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. +# +# Author: Denis Stogl (Stogl Robotics Consulting) +# + +from launch import LaunchDescription +from launch.actions import DeclareLaunchArgument, IncludeLaunchDescription +from launch.actions import RegisterEventHandler +from launch.event_handlers import OnProcessExit +from launch.launch_description_sources import PythonLaunchDescriptionSource +from launch.substitutions import Command, FindExecutable, LaunchConfiguration, PathJoinSubstitution + +from launch_ros.actions import Node +from launch_ros.substitutions import FindPackageShare + + +def generate_launch_description(): + # Launch Arguments + use_sim_time = LaunchConfiguration('use_sim_time', default=True) + + # Get URDF via xacro + robot_description_content = Command( + [ + PathJoinSubstitution([FindExecutable(name='xacro')]), + ' ', + PathJoinSubstitution( + [FindPackageShare('gz_ros2_control_demos'), + 'urdf', 'test_gripper_mimic_joint_effort.xacro.urdf'] + ), + ] + ) + robot_description = {'robot_description': robot_description_content} + robot_controllers = PathJoinSubstitution( + [ + FindPackageShare('gz_ros2_control_demos'), + 'config', + 'gripper_controller_effort.yaml', + ] + ) + + node_robot_state_publisher = Node( + package='robot_state_publisher', + executable='robot_state_publisher', + output='screen', + parameters=[robot_description] + ) + + gz_spawn_entity = Node( + package='ros_gz_sim', + executable='create', + output='screen', + arguments=['-topic', 'robot_description', '-name', + 'gripper', '-allow_renaming', 'true'], + ) + + joint_state_broadcaster_spawner = Node( + package='controller_manager', + executable='spawner', + arguments=['joint_state_broadcaster'], + ) + gripper_controller_spawner = Node( + package='controller_manager', + executable='spawner', + arguments=[ + 'gripper_controller', + '--param-file', + robot_controllers, + ], + ) + + # Bridge + bridge = Node( + package='ros_gz_bridge', + executable='parameter_bridge', + arguments=['/clock@rosgraph_msgs/msg/Clock[gz.msgs.Clock'], + output='screen' + ) + + return LaunchDescription([ + # Launch gazebo environment + IncludeLaunchDescription( + PythonLaunchDescriptionSource( + [PathJoinSubstitution([FindPackageShare('ros_gz_sim'), + 'launch', + 'gz_sim.launch.py'])]), + launch_arguments=[('gz_args', [' -r -v 4 empty.sdf'])]), + RegisterEventHandler( + event_handler=OnProcessExit( + target_action=gz_spawn_entity, + on_exit=[joint_state_broadcaster_spawner], + ) + ), + RegisterEventHandler( + event_handler=OnProcessExit( + target_action=joint_state_broadcaster_spawner, + on_exit=[gripper_controller_spawner], + ) + ), + bridge, + node_robot_state_publisher, + gz_spawn_entity, + # Launch Arguments + DeclareLaunchArgument( + 'use_sim_time', + default_value=use_sim_time, + description='If true, use simulated clock'), + ]) diff --git a/gz_ros2_control_tests/tests/position_test.py b/gz_ros2_control_tests/tests/position_test.py index 7080c719..66a200fe 100755 --- a/gz_ros2_control_tests/tests/position_test.py +++ b/gz_ros2_control_tests/tests/position_test.py @@ -93,8 +93,17 @@ def generate_test_description(): output='screen' ) + # Bridge + bridge = Node( + package='ros_gz_bridge', + executable='parameter_bridge', + arguments=['/clock@rosgraph_msgs/msg/Clock[gz.msgs.Clock'], + output='screen' + ) + ld = launch.LaunchDescription([ included_launch, + bridge, gz_spawn_entity, node_robot_state_publisher, RegisterEventHandler( diff --git a/ign_ros2_control_demos/launch/ackermann_drive_example.launch.py b/ign_ros2_control_demos/launch/ackermann_drive_example.launch.py index dc55b619..a4996042 100644 --- a/ign_ros2_control_demos/launch/ackermann_drive_example.launch.py +++ b/ign_ros2_control_demos/launch/ackermann_drive_example.launch.py @@ -75,6 +75,14 @@ def generate_launch_description(): output='screen' ) + # Bridge + bridge = Node( + package='ros_gz_bridge', + executable='parameter_bridge', + arguments=['/clock@rosgraph_msgs/msg/Clock[gz.msgs.Clock'], + output='screen' + ) + return LaunchDescription([ bridge, # Launch gazebo environment @@ -96,6 +104,7 @@ def generate_launch_description(): on_exit=[load_ackermann_controller], ) ), + bridge, node_robot_state_publisher, gz_spawn_entity, # Launch Arguments diff --git a/ign_ros2_control_demos/launch/cart_example_effort.launch.py b/ign_ros2_control_demos/launch/cart_example_effort.launch.py index 4bd27da5..4f28e1c1 100644 --- a/ign_ros2_control_demos/launch/cart_example_effort.launch.py +++ b/ign_ros2_control_demos/launch/cart_example_effort.launch.py @@ -71,6 +71,14 @@ def generate_launch_description(): output='screen' ) + # Bridge + bridge = Node( + package='ros_gz_bridge', + executable='parameter_bridge', + arguments=['/clock@rosgraph_msgs/msg/Clock[gz.msgs.Clock'], + output='screen' + ) + return LaunchDescription([ # Launch gazebo environment IncludeLaunchDescription( @@ -90,6 +98,7 @@ def generate_launch_description(): on_exit=[load_joint_effort_controller], ) ), + bridge, node_robot_state_publisher, ignition_spawn_entity, # Launch Arguments diff --git a/ign_ros2_control_demos/launch/pendulum_example_effort.launch.py b/ign_ros2_control_demos/launch/pendulum_example_effort.launch.py index cd2eaf16..13adde63 100644 --- a/ign_ros2_control_demos/launch/pendulum_example_effort.launch.py +++ b/ign_ros2_control_demos/launch/pendulum_example_effort.launch.py @@ -67,6 +67,14 @@ def generate_launch_description(): output='screen' ) + # Bridge + bridge = Node( + package='ros_gz_bridge', + executable='parameter_bridge', + arguments=['/clock@rosgraph_msgs/msg/Clock[gz.msgs.Clock'], + output='screen' + ) + return LaunchDescription([ # Launch gazebo environment IncludeLaunchDescription( @@ -87,6 +95,7 @@ def generate_launch_description(): on_exit=[load_joint_effort_controller], ) ), + bridge, node_robot_state_publisher, gz_spawn_entity, # Launch Arguments diff --git a/ign_ros2_control_demos/launch/pendulum_example_position.launch.py b/ign_ros2_control_demos/launch/pendulum_example_position.launch.py index 18a6b8f9..31fe1e80 100644 --- a/ign_ros2_control_demos/launch/pendulum_example_position.launch.py +++ b/ign_ros2_control_demos/launch/pendulum_example_position.launch.py @@ -67,6 +67,14 @@ def generate_launch_description(): output='screen' ) + # Bridge + bridge = Node( + package='ros_gz_bridge', + executable='parameter_bridge', + arguments=['/clock@rosgraph_msgs/msg/Clock[gz.msgs.Clock'], + output='screen' + ) + return LaunchDescription([ # Launch gazebo environment IncludeLaunchDescription( @@ -87,6 +95,7 @@ def generate_launch_description(): on_exit=[load_tricycle_controller], ) ), + bridge, node_robot_state_publisher, gz_spawn_entity, # Launch Arguments From d6ba4d93086f59b71cca6789f23c402891bf5ca6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Hern=C3=A1ndez=20Cordero?= Date: Mon, 2 Dec 2024 09:51:16 +0100 Subject: [PATCH 2/3] Fixed merge MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Alejandro Hernández Cordero --- .../launch/cart_example_position.launch.py | 117 ---------------- .../launch/cart_example_velocity.launch.py | 126 ------------------ .../launch/diff_drive_example.launch.py | 116 ---------------- ...ipper_mimic_joint_example_effort.launch.py | 119 ----------------- .../launch/ackermann_drive_example.launch.py | 8 -- .../launch/cart_example_position.launch.py | 9 ++ .../launch/cart_example_velocity.launch.py | 9 ++ .../launch/diff_drive_example.launch.py | 14 -- .../gripper_mimic_joint_example.launch.py | 9 ++ 9 files changed, 27 insertions(+), 500 deletions(-) delete mode 100644 gz_ros2_control_demos/launch/cart_example_position.launch.py delete mode 100644 gz_ros2_control_demos/launch/cart_example_velocity.launch.py delete mode 100644 gz_ros2_control_demos/launch/diff_drive_example.launch.py delete mode 100644 gz_ros2_control_demos/launch/gripper_mimic_joint_example_effort.launch.py diff --git a/gz_ros2_control_demos/launch/cart_example_position.launch.py b/gz_ros2_control_demos/launch/cart_example_position.launch.py deleted file mode 100644 index c4a78b35..00000000 --- a/gz_ros2_control_demos/launch/cart_example_position.launch.py +++ /dev/null @@ -1,117 +0,0 @@ -# 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. -# 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. - -from launch import LaunchDescription -from launch.actions import DeclareLaunchArgument, IncludeLaunchDescription -from launch.actions import RegisterEventHandler -from launch.event_handlers import OnProcessExit -from launch.launch_description_sources import PythonLaunchDescriptionSource -from launch.substitutions import Command, FindExecutable, LaunchConfiguration, PathJoinSubstitution - -from launch_ros.actions import Node -from launch_ros.substitutions import FindPackageShare - - -def generate_launch_description(): - # Launch Arguments - use_sim_time = LaunchConfiguration('use_sim_time', default=True) - - # Get URDF via xacro - robot_description_content = Command( - [ - PathJoinSubstitution([FindExecutable(name='xacro')]), - ' ', - PathJoinSubstitution( - [FindPackageShare('gz_ros2_control_demos'), - 'urdf', 'test_cart_position.xacro.urdf'] - ), - ] - ) - robot_description = {'robot_description': robot_description_content} - robot_controllers = PathJoinSubstitution( - [ - FindPackageShare('gz_ros2_control_demos'), - 'config', - 'cart_controller_position.yaml', - ] - ) - - node_robot_state_publisher = Node( - package='robot_state_publisher', - executable='robot_state_publisher', - output='screen', - parameters=[robot_description] - ) - - gz_spawn_entity = Node( - package='ros_gz_sim', - executable='create', - output='screen', - arguments=['-topic', 'robot_description', - '-name', 'cart', '-allow_renaming', 'true'], - ) - - joint_state_broadcaster_spawner = Node( - package='controller_manager', - executable='spawner', - arguments=['joint_state_broadcaster', - ], - ) - joint_trajectory_controller_spawner = Node( - package='controller_manager', - executable='spawner', - arguments=[ - 'joint_trajectory_controller', - '--param-file', - robot_controllers, - ], - ) - - # Bridge - bridge = Node( - package='ros_gz_bridge', - executable='parameter_bridge', - arguments=['/clock@rosgraph_msgs/msg/Clock[gz.msgs.Clock'], - output='screen' - ) - - return LaunchDescription([ - # Launch gazebo environment - IncludeLaunchDescription( - PythonLaunchDescriptionSource( - [PathJoinSubstitution([FindPackageShare('ros_gz_sim'), - 'launch', - 'gz_sim.launch.py'])]), - launch_arguments=[('gz_args', [' -r -v 4 empty.sdf'])]), - RegisterEventHandler( - event_handler=OnProcessExit( - target_action=gz_spawn_entity, - on_exit=[joint_state_broadcaster_spawner], - ) - ), - RegisterEventHandler( - event_handler=OnProcessExit( - target_action=joint_state_broadcaster_spawner, - on_exit=[joint_trajectory_controller_spawner], - ) - ), - bridge, - node_robot_state_publisher, - gz_spawn_entity, - # Launch Arguments - DeclareLaunchArgument( - 'use_sim_time', - default_value=use_sim_time, - description='If true, use simulated clock'), - ]) diff --git a/gz_ros2_control_demos/launch/cart_example_velocity.launch.py b/gz_ros2_control_demos/launch/cart_example_velocity.launch.py deleted file mode 100644 index 4f0a0405..00000000 --- a/gz_ros2_control_demos/launch/cart_example_velocity.launch.py +++ /dev/null @@ -1,126 +0,0 @@ -# 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. -# 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. - -from launch import LaunchDescription -from launch.actions import DeclareLaunchArgument, IncludeLaunchDescription -from launch.actions import RegisterEventHandler -from launch.event_handlers import OnProcessExit -from launch.launch_description_sources import PythonLaunchDescriptionSource -from launch.substitutions import Command, FindExecutable, LaunchConfiguration, PathJoinSubstitution - -from launch_ros.actions import Node -from launch_ros.substitutions import FindPackageShare - - -def generate_launch_description(): - # Launch Arguments - use_sim_time = LaunchConfiguration('use_sim_time', default=True) - - # Get URDF via xacro - robot_description_content = Command( - [ - PathJoinSubstitution([FindExecutable(name='xacro')]), - ' ', - PathJoinSubstitution( - [FindPackageShare('gz_ros2_control_demos'), - 'urdf', 'test_cart_velocity.xacro.urdf'] - ), - ] - ) - robot_description = {'robot_description': robot_description_content} - robot_controllers = PathJoinSubstitution( - [ - FindPackageShare('gz_ros2_control_demos'), - 'config', - 'cart_controller_velocity.yaml', - ] - ) - - node_robot_state_publisher = Node( - package='robot_state_publisher', - executable='robot_state_publisher', - output='screen', - parameters=[robot_description] - ) - - gz_spawn_entity = Node( - package='ros_gz_sim', - executable='create', - output='screen', - arguments=['-topic', 'robot_description', - '-name', 'cart', '-allow_renaming', 'true'], - ) - - joint_state_broadcaster_spawner = Node( - package='controller_manager', - executable='spawner', - arguments=['joint_state_broadcaster'], - ) - velocity_controller_spawner = Node( - package='controller_manager', - executable='spawner', - arguments=[ - 'velocity_controller', - '--param-file', - robot_controllers, - ], - ) - imu_sensor_broadcaster_spawner = Node( - package='controller_manager', - executable='spawner', - arguments=[ - 'imu_sensor_broadcaster', - '--param-file', - robot_controllers, - ], - ) - - # Bridge - bridge = Node( - package='ros_gz_bridge', - executable='parameter_bridge', - arguments=['/clock@rosgraph_msgs/msg/Clock[gz.msgs.Clock'], - output='screen' - ) - - return LaunchDescription([ - # Launch gazebo environment - IncludeLaunchDescription( - PythonLaunchDescriptionSource( - [PathJoinSubstitution([FindPackageShare('ros_gz_sim'), - 'launch', - 'gz_sim.launch.py'])]), - launch_arguments=[('gz_args', [' -r -v 3 empty.sdf'])]), - RegisterEventHandler( - event_handler=OnProcessExit( - target_action=gz_spawn_entity, - on_exit=[joint_state_broadcaster_spawner], - ) - ), - RegisterEventHandler( - event_handler=OnProcessExit( - target_action=joint_state_broadcaster_spawner, - on_exit=[velocity_controller_spawner, - imu_sensor_broadcaster_spawner], - ) - ), - bridge, - node_robot_state_publisher, - gz_spawn_entity, - # Launch Arguments - DeclareLaunchArgument( - 'use_sim_time', - default_value=use_sim_time, - description='If true, use simulated clock'), - ]) diff --git a/gz_ros2_control_demos/launch/diff_drive_example.launch.py b/gz_ros2_control_demos/launch/diff_drive_example.launch.py deleted file mode 100644 index 21c5afb7..00000000 --- a/gz_ros2_control_demos/launch/diff_drive_example.launch.py +++ /dev/null @@ -1,116 +0,0 @@ -# Copyright 2022 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. - -from launch import LaunchDescription -from launch.actions import DeclareLaunchArgument, IncludeLaunchDescription -from launch.actions import RegisterEventHandler -from launch.event_handlers import OnProcessExit -from launch.launch_description_sources import PythonLaunchDescriptionSource -from launch.substitutions import Command, FindExecutable, LaunchConfiguration, PathJoinSubstitution - -from launch_ros.actions import Node -from launch_ros.substitutions import FindPackageShare - - -def generate_launch_description(): - # Launch Arguments - use_sim_time = LaunchConfiguration('use_sim_time', default=True) - - # Get URDF via xacro - robot_description_content = Command( - [ - PathJoinSubstitution([FindExecutable(name='xacro')]), - ' ', - PathJoinSubstitution( - [FindPackageShare('gz_ros2_control_demos'), - 'urdf', 'test_diff_drive.xacro.urdf'] - ), - ] - ) - robot_description = {'robot_description': robot_description_content} - robot_controllers = PathJoinSubstitution( - [ - FindPackageShare('gz_ros2_control_demos'), - 'config', - 'diff_drive_controller_velocity.yaml', - ] - ) - - node_robot_state_publisher = Node( - package='robot_state_publisher', - executable='robot_state_publisher', - output='screen', - parameters=[robot_description] - ) - - gz_spawn_entity = Node( - package='ros_gz_sim', - executable='create', - output='screen', - arguments=['-topic', 'robot_description', '-name', - 'diff_drive', '-allow_renaming', 'true'], - ) - - joint_state_broadcaster_spawner = Node( - package='controller_manager', - executable='spawner', - arguments=['joint_state_broadcaster'], - ) - diff_drive_base_controller_spawner = Node( - package='controller_manager', - executable='spawner', - arguments=[ - 'diff_drive_base_controller', - '--param-file', - robot_controllers, - ], - ) - - # Bridge - bridge = Node( - package='ros_gz_bridge', - executable='parameter_bridge', - arguments=['/clock@rosgraph_msgs/msg/Clock[gz.msgs.Clock'], - output='screen' - ) - - return LaunchDescription([ - # Launch gazebo environment - IncludeLaunchDescription( - PythonLaunchDescriptionSource( - [PathJoinSubstitution([FindPackageShare('ros_gz_sim'), - 'launch', - 'gz_sim.launch.py'])]), - launch_arguments=[('gz_args', [' -r -v 4 empty.sdf'])]), - RegisterEventHandler( - event_handler=OnProcessExit( - target_action=gz_spawn_entity, - on_exit=[joint_state_broadcaster_spawner], - ) - ), - RegisterEventHandler( - event_handler=OnProcessExit( - target_action=joint_state_broadcaster_spawner, - on_exit=[diff_drive_base_controller_spawner], - ) - ), - bridge, - node_robot_state_publisher, - gz_spawn_entity, - # Launch Arguments - DeclareLaunchArgument( - 'use_sim_time', - default_value=use_sim_time, - description='If true, use simulated clock'), - ]) diff --git a/gz_ros2_control_demos/launch/gripper_mimic_joint_example_effort.launch.py b/gz_ros2_control_demos/launch/gripper_mimic_joint_example_effort.launch.py deleted file mode 100644 index e074e869..00000000 --- a/gz_ros2_control_demos/launch/gripper_mimic_joint_example_effort.launch.py +++ /dev/null @@ -1,119 +0,0 @@ -# Copyright 2022 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. -# -# Author: Denis Stogl (Stogl Robotics Consulting) -# - -from launch import LaunchDescription -from launch.actions import DeclareLaunchArgument, IncludeLaunchDescription -from launch.actions import RegisterEventHandler -from launch.event_handlers import OnProcessExit -from launch.launch_description_sources import PythonLaunchDescriptionSource -from launch.substitutions import Command, FindExecutable, LaunchConfiguration, PathJoinSubstitution - -from launch_ros.actions import Node -from launch_ros.substitutions import FindPackageShare - - -def generate_launch_description(): - # Launch Arguments - use_sim_time = LaunchConfiguration('use_sim_time', default=True) - - # Get URDF via xacro - robot_description_content = Command( - [ - PathJoinSubstitution([FindExecutable(name='xacro')]), - ' ', - PathJoinSubstitution( - [FindPackageShare('gz_ros2_control_demos'), - 'urdf', 'test_gripper_mimic_joint_effort.xacro.urdf'] - ), - ] - ) - robot_description = {'robot_description': robot_description_content} - robot_controllers = PathJoinSubstitution( - [ - FindPackageShare('gz_ros2_control_demos'), - 'config', - 'gripper_controller_effort.yaml', - ] - ) - - node_robot_state_publisher = Node( - package='robot_state_publisher', - executable='robot_state_publisher', - output='screen', - parameters=[robot_description] - ) - - gz_spawn_entity = Node( - package='ros_gz_sim', - executable='create', - output='screen', - arguments=['-topic', 'robot_description', '-name', - 'gripper', '-allow_renaming', 'true'], - ) - - joint_state_broadcaster_spawner = Node( - package='controller_manager', - executable='spawner', - arguments=['joint_state_broadcaster'], - ) - gripper_controller_spawner = Node( - package='controller_manager', - executable='spawner', - arguments=[ - 'gripper_controller', - '--param-file', - robot_controllers, - ], - ) - - # Bridge - bridge = Node( - package='ros_gz_bridge', - executable='parameter_bridge', - arguments=['/clock@rosgraph_msgs/msg/Clock[gz.msgs.Clock'], - output='screen' - ) - - return LaunchDescription([ - # Launch gazebo environment - IncludeLaunchDescription( - PythonLaunchDescriptionSource( - [PathJoinSubstitution([FindPackageShare('ros_gz_sim'), - 'launch', - 'gz_sim.launch.py'])]), - launch_arguments=[('gz_args', [' -r -v 4 empty.sdf'])]), - RegisterEventHandler( - event_handler=OnProcessExit( - target_action=gz_spawn_entity, - on_exit=[joint_state_broadcaster_spawner], - ) - ), - RegisterEventHandler( - event_handler=OnProcessExit( - target_action=joint_state_broadcaster_spawner, - on_exit=[gripper_controller_spawner], - ) - ), - bridge, - node_robot_state_publisher, - gz_spawn_entity, - # Launch Arguments - DeclareLaunchArgument( - 'use_sim_time', - default_value=use_sim_time, - description='If true, use simulated clock'), - ]) diff --git a/ign_ros2_control_demos/launch/ackermann_drive_example.launch.py b/ign_ros2_control_demos/launch/ackermann_drive_example.launch.py index a4996042..5abdd038 100644 --- a/ign_ros2_control_demos/launch/ackermann_drive_example.launch.py +++ b/ign_ros2_control_demos/launch/ackermann_drive_example.launch.py @@ -75,14 +75,6 @@ def generate_launch_description(): output='screen' ) - # Bridge - bridge = Node( - package='ros_gz_bridge', - executable='parameter_bridge', - arguments=['/clock@rosgraph_msgs/msg/Clock[gz.msgs.Clock'], - output='screen' - ) - return LaunchDescription([ bridge, # Launch gazebo environment diff --git a/ign_ros2_control_demos/launch/cart_example_position.launch.py b/ign_ros2_control_demos/launch/cart_example_position.launch.py index ffbeae6a..aca8fff9 100644 --- a/ign_ros2_control_demos/launch/cart_example_position.launch.py +++ b/ign_ros2_control_demos/launch/cart_example_position.launch.py @@ -72,6 +72,14 @@ def generate_launch_description(): output='screen' ) + # Bridge + bridge = Node( + package='ros_gz_bridge', + executable='parameter_bridge', + arguments=['/clock@rosgraph_msgs/msg/Clock[gz.msgs.Clock'], + output='screen' + ) + return LaunchDescription([ # Launch gazebo environment IncludeLaunchDescription( @@ -98,4 +106,5 @@ def generate_launch_description(): 'use_sim_time', default_value=use_sim_time, description='If true, use simulated clock'), + bridge, ]) diff --git a/ign_ros2_control_demos/launch/cart_example_velocity.launch.py b/ign_ros2_control_demos/launch/cart_example_velocity.launch.py index d69b4130..f68e81fd 100644 --- a/ign_ros2_control_demos/launch/cart_example_velocity.launch.py +++ b/ign_ros2_control_demos/launch/cart_example_velocity.launch.py @@ -77,6 +77,14 @@ def generate_launch_description(): output='screen' ) + # Bridge + bridge = Node( + package='ros_gz_bridge', + executable='parameter_bridge', + arguments=['/clock@rosgraph_msgs/msg/Clock[gz.msgs.Clock'], + output='screen' + ) + return LaunchDescription([ # Launch gazebo environment IncludeLaunchDescription( @@ -109,4 +117,5 @@ def generate_launch_description(): 'use_sim_time', default_value=use_sim_time, description='If true, use simulated clock'), + bridge, ]) diff --git a/ign_ros2_control_demos/launch/diff_drive_example.launch.py b/ign_ros2_control_demos/launch/diff_drive_example.launch.py index d0147161..7f742ac1 100644 --- a/ign_ros2_control_demos/launch/diff_drive_example.launch.py +++ b/ign_ros2_control_demos/launch/diff_drive_example.launch.py @@ -1,17 +1,3 @@ -# Copyright 2022 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 diff --git a/ign_ros2_control_demos/launch/gripper_mimic_joint_example.launch.py b/ign_ros2_control_demos/launch/gripper_mimic_joint_example.launch.py index bf12d3d8..5c3b92b8 100644 --- a/ign_ros2_control_demos/launch/gripper_mimic_joint_example.launch.py +++ b/ign_ros2_control_demos/launch/gripper_mimic_joint_example.launch.py @@ -75,6 +75,14 @@ def generate_launch_description(): output='screen' ) + # Bridge + bridge = Node( + package='ros_gz_bridge', + executable='parameter_bridge', + arguments=['/clock@rosgraph_msgs/msg/Clock[ignition.msgs.Clock'], + output='screen' + ) + return LaunchDescription([ # Launch gazebo environment IncludeLaunchDescription( @@ -101,4 +109,5 @@ def generate_launch_description(): 'use_sim_time', default_value=use_sim_time, description='If true, use simulated clock'), + bridge, ]) From 0da08d53696877351d0d2b59fd37f117ff2bba41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Hern=C3=A1ndez=20Cordero?= Date: Mon, 2 Dec 2024 09:53:05 +0100 Subject: [PATCH 3/3] Restore license MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Alejandro Hernández Cordero --- .../launch/diff_drive_example.launch.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/ign_ros2_control_demos/launch/diff_drive_example.launch.py b/ign_ros2_control_demos/launch/diff_drive_example.launch.py index 7f742ac1..d0147161 100644 --- a/ign_ros2_control_demos/launch/diff_drive_example.launch.py +++ b/ign_ros2_control_demos/launch/diff_drive_example.launch.py @@ -1,3 +1,17 @@ +# Copyright 2022 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