From 37c4dc787c7fbdd6e45cd84656f30a9a8bc7d5ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dr=2E=20Denis=20=C5=A0togl?= Date: Thu, 28 Mar 2024 21:36:55 +0100 Subject: [PATCH] Working version. --- example_9/CMakeLists.txt | 2 +- ...c.launch.py => rrbot_gazebo_sim.launch.py} | 43 +++++++---- .../launch/rrbot_gazebo_sim.launch.xml | 64 +++++++++++++++++ .../description/gazebo/rrbot.gazebo.xacro | 7 +- .../ros2_control/rrbot.ros2_control.xacro | 8 +-- example_9/description/urdf/rrbot.urdf.xacro | 6 +- example_9/package.xml | 2 +- example_9/worlds/empty.world | 72 +++++++++++++++++++ 8 files changed, 179 insertions(+), 25 deletions(-) rename example_9/bringup/launch/{rrbot_gazebo_classic.launch.py => rrbot_gazebo_sim.launch.py} (79%) create mode 100644 example_9/bringup/launch/rrbot_gazebo_sim.launch.xml create mode 100644 example_9/worlds/empty.world diff --git a/example_9/CMakeLists.txt b/example_9/CMakeLists.txt index 1c6980484..ab585baee 100644 --- a/example_9/CMakeLists.txt +++ b/example_9/CMakeLists.txt @@ -49,7 +49,7 @@ install( DESTINATION include/ros2_control_demo_example_9 ) install( - DIRECTORY description/launch description/ros2_control description/urdf description/gazebo + DIRECTORY description/launch description/ros2_control description/urdf description/gazebo worlds DESTINATION share/ros2_control_demo_example_9 ) install( diff --git a/example_9/bringup/launch/rrbot_gazebo_classic.launch.py b/example_9/bringup/launch/rrbot_gazebo_sim.launch.py similarity index 79% rename from example_9/bringup/launch/rrbot_gazebo_classic.launch.py rename to example_9/bringup/launch/rrbot_gazebo_sim.launch.py index 1fd754f77..ba378abcb 100644 --- a/example_9/bringup/launch/rrbot_gazebo_classic.launch.py +++ b/example_9/bringup/launch/rrbot_gazebo_sim.launch.py @@ -36,13 +36,6 @@ def generate_launch_description(): # Initialize Arguments gui = LaunchConfiguration("gui") - gazebo = IncludeLaunchDescription( - PythonLaunchDescriptionSource( - [PathJoinSubstitution([FindPackageShare("gazebo_ros"), "launch", "gazebo.launch.py"])] - ), - launch_arguments={"verbose": "false"}.items(), - ) - # Get URDF via xacro robot_description_content = Command( [ @@ -52,13 +45,10 @@ def generate_launch_description(): [FindPackageShare("ros2_control_demo_example_9"), "urdf", "rrbot.urdf.xacro"] ), " ", - "use_gazebo_classic:=true", + "use_gazebo_sim:=true", ] ) robot_description = {"robot_description": robot_description_content} - rviz_config_file = PathJoinSubstitution( - [FindPackageShare("ros2_control_demo_description"), "rrbot/rviz", "rrbot.rviz"] - ) node_robot_state_publisher = Node( package="robot_state_publisher", @@ -67,10 +57,30 @@ def generate_launch_description(): parameters=[robot_description], ) + # Start Gazebo + gazebo_world = PathJoinSubstitution( + [FindPackageShare("ros2_control_demo_example_9"), "worlds", "empty.world"] + ) + gazebo = IncludeLaunchDescription( + PythonLaunchDescriptionSource( + [PathJoinSubstitution([FindPackageShare("ros_gz_sim"), "launch", "gz_sim.launch.py"])] + ), + launch_arguments=[("gz_args", [" -r -v 4 ", gazebo_world])], + ) + spawn_entity = Node( - package="gazebo_ros", - executable="spawn_entity.py", - arguments=["-topic", "robot_description", "-entity", "rrbot_system_position"], + package="ros_gz_sim", + executable="create", + arguments=["-topic", "robot_description", "-name", "rrbot_system_position"], + output="screen", + ) + + clock_bridge = Node( + package="ros_gz_bridge", + executable="parameter_bridge", + name="clock_bridge", + parameters=[{"use_sim_time": True}], + arguments=["/clock@rosgraph_msgs/msg/Clock[ignition.msgs.Clock"], output="screen", ) @@ -85,6 +95,10 @@ def generate_launch_description(): executable="spawner", arguments=["forward_position_controller", "--controller-manager", "/controller_manager"], ) + + rviz_config_file = PathJoinSubstitution( + [FindPackageShare("ros2_control_demo_description"), "rrbot/rviz", "rrbot.rviz"] + ) rviz_node = Node( package="rviz2", executable="rviz2", @@ -98,6 +112,7 @@ def generate_launch_description(): gazebo, node_robot_state_publisher, spawn_entity, + clock_bridge, joint_state_broadcaster_spawner, robot_controller_spawner, rviz_node, diff --git a/example_9/bringup/launch/rrbot_gazebo_sim.launch.xml b/example_9/bringup/launch/rrbot_gazebo_sim.launch.xml new file mode 100644 index 000000000..8b2c9c43b --- /dev/null +++ b/example_9/bringup/launch/rrbot_gazebo_sim.launch.xml @@ -0,0 +1,64 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/example_9/description/gazebo/rrbot.gazebo.xacro b/example_9/description/gazebo/rrbot.gazebo.xacro index 1de74bcc8..e2400617c 100644 --- a/example_9/description/gazebo/rrbot.gazebo.xacro +++ b/example_9/description/gazebo/rrbot.gazebo.xacro @@ -7,10 +7,13 @@ https://github.com/ros-simulation/gazebo_ros_demos/blob/kinetic-devel/rrbot_desc - + + + - + $(find ros2_control_demo_example_9)/config/rrbot_controllers.yaml + ${prefix}controller_manager diff --git a/example_9/description/ros2_control/rrbot.ros2_control.xacro b/example_9/description/ros2_control/rrbot.ros2_control.xacro index 0d57bf036..4d2340d7f 100644 --- a/example_9/description/ros2_control/rrbot.ros2_control.xacro +++ b/example_9/description/ros2_control/rrbot.ros2_control.xacro @@ -1,14 +1,14 @@ - + - - gazebo_ros2_control/GazeboSystem + + gz_ros2_control/GazeboSimSystem - + ros2_control_demo_example_9/RRBotSystemPositionOnlyHardware 0 3.0 diff --git a/example_9/description/urdf/rrbot.urdf.xacro b/example_9/description/urdf/rrbot.urdf.xacro index a77033cee..01d7f14ae 100644 --- a/example_9/description/urdf/rrbot.urdf.xacro +++ b/example_9/description/urdf/rrbot.urdf.xacro @@ -6,7 +6,7 @@ https://github.com/ros-simulation/gazebo_ros_demos/blob/kinetic-devel/rrbot_desc --> - + @@ -25,9 +25,9 @@ https://github.com/ros-simulation/gazebo_ros_demos/blob/kinetic-devel/rrbot_desc + name="RRBot" prefix="$(arg prefix)" use_gazebo_sim="$(arg use_gazebo_sim)"/> - + diff --git a/example_9/package.xml b/example_9/package.xml index 580b31746..b40b6b968 100644 --- a/example_9/package.xml +++ b/example_9/package.xml @@ -24,7 +24,7 @@ controller_manager forward_command_controller gazebo_ros - gazebo_ros2_control + gz_ros2_control joint_state_broadcaster joint_state_publisher_gui joint_trajectory_controller diff --git a/example_9/worlds/empty.world b/example_9/worlds/empty.world new file mode 100644 index 000000000..3a2872c24 --- /dev/null +++ b/example_9/worlds/empty.world @@ -0,0 +1,72 @@ + + + + + 0.001 + 1.0 + + + + + + + + + + + ogre2 + + + + true + 0 0 10 0 0 0 + 0.8 0.8 0.8 1 + 0.2 0.2 0.2 1 + + 1000 + 0.9 + 0.01 + 0.001 + + -0.5 0.1 -0.9 + + + + true + + + + + 0 0 1 + 100 100 + + + + + + + 0 0 1 + 100 100 + + + + 0.8 0.8 0.8 1 + 0.8 0.8 0.8 1 + 0.8 0.8 0.8 1 + + + + + + +