From 8ccc4acf084e10f36317a47d4144a1700203fd4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Ellensohn?= Date: Wed, 12 Apr 2023 10:11:46 +0200 Subject: [PATCH] changed for using name cps_rmp220_support package --- .vscode/c_cpp_properties.json | 22 + .vscode/settings.json | 12 + CMakeLists.txt | 2 +- README.md | 13 +- config/gaz_ros2_ctl_use_sim.yaml | 3 + config/joystick.yaml | 27 + config/my_controllers.yaml | 68 +++ config/twist_mux.yaml | 15 + config/view_bot.rviz | 204 +++++++ description/camera.xacro | 62 ++ description/depth_camera.xacro | 57 ++ description/face.xacro | 42 ++ description/gazebo_control.xacro | 31 + description/inertial_macros.xacro | 40 ++ description/lidar.xacro | 66 +++ description/robot.urdf.xacro | 18 +- description/robot_core.xacro | 204 +++++++ description/ros2_control.xacro | 66 +++ launch/camera.launch.py | 23 + launch/joystick.launch.py | 45 ++ launch/launch_robot.launch.py | 115 ++++ launch/launch_sim.launch.py | 98 ++++ launch/rplidar.launch.py | 20 + launch/rsp.launch.py | 11 +- package.xml | 8 +- worlds/obstacles.world | 935 ++++++++++++++++++++++++++++++ 26 files changed, 2193 insertions(+), 14 deletions(-) create mode 100644 .vscode/c_cpp_properties.json create mode 100644 .vscode/settings.json create mode 100644 config/gaz_ros2_ctl_use_sim.yaml create mode 100644 config/joystick.yaml create mode 100644 config/my_controllers.yaml create mode 100644 config/twist_mux.yaml create mode 100644 config/view_bot.rviz create mode 100644 description/camera.xacro create mode 100644 description/depth_camera.xacro create mode 100755 description/face.xacro create mode 100644 description/gazebo_control.xacro create mode 100755 description/inertial_macros.xacro create mode 100644 description/lidar.xacro create mode 100644 description/robot_core.xacro create mode 100644 description/ros2_control.xacro create mode 100644 launch/camera.launch.py create mode 100644 launch/joystick.launch.py create mode 100755 launch/launch_robot.launch.py create mode 100755 launch/launch_sim.launch.py create mode 100644 launch/rplidar.launch.py create mode 100644 worlds/obstacles.world diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json new file mode 100644 index 0000000..baf088c --- /dev/null +++ b/.vscode/c_cpp_properties.json @@ -0,0 +1,22 @@ +{ + "configurations": [ + { + "browse": { + "databaseFilename": "${default}", + "limitSymbolsToIncludedHeaders": false + }, + "includePath": [ + "/home/bjorn/Documents/ros-projects/cps_rmp220_ws/install/segway_msgs/include/**", + "/opt/ros/humble/include/**", + "/home/bjorn/Documents/ros-projects/cps_rmp220_ws/src/segwayrmp/include/**", + "/usr/include/**" + ], + "name": "ROS", + "intelliSenseMode": "gcc-x64", + "compilerPath": "/usr/bin/gcc", + "cStandard": "gnu11", + "cppStandard": "c++14" + } + ], + "version": 4 +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..48ea5f4 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,12 @@ +{ + "python.autoComplete.extraPaths": [ + "/home/bjorn/Documents/ros-projects/cps_rmp220_ws/install/segway_msgs/local/lib/python3.10/dist-packages", + "/opt/ros/humble/lib/python3.10/site-packages", + "/opt/ros/humble/local/lib/python3.10/dist-packages" + ], + "python.analysis.extraPaths": [ + "/home/bjorn/Documents/ros-projects/cps_rmp220_ws/install/segway_msgs/local/lib/python3.10/dist-packages", + "/opt/ros/humble/lib/python3.10/site-packages", + "/opt/ros/humble/local/lib/python3.10/dist-packages" + ] +} \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index dfa34c8..8899664 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.5) -project(my_bot) +project(cps_rmp220_support) # Default to C99 if(NOT CMAKE_C_STANDARD) diff --git a/README.md b/README.md index d2f2f88..4e75491 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,12 @@ -## Robot Package Template +## Supplementary Robot PAckage for Segway RMP220 lite -This is a GitHub template. You can make your own copy by clicking the green "Use this template" button. +This package should be placed into your workspace src/ folder. +Alongside you must clone https://github.com/bjoernellens1/segwayrmp and https://github.com/bjoernellens1/segway_msgs to control the robot. +Go back to ws folder and colcon build --symlink-install && source install/setup.bash -It is recommended that you keep the repo/package name the same, but if you do change it, ensure you do a "Find all" using your IDE (or the built-in GitHub IDE by hitting the `.` key) and rename all instances of `my_bot` to whatever your project's name is. +### Launch files: +#### Launch Gazebo +ros2 launch cps_rmp220_support launch_sim.launch.py -Note that each directory currently has at least one file in it to ensure that git tracks the files (and, consequently, that a fresh clone has direcctories present for CMake to find). These example files can be removed if required (and the directories can be removed if `CMakeLists.txt` is adjusted accordingly). \ No newline at end of file +#### Launch Robot operator (Only neeed for Camera and additional devices for now) +ros2 launch cps_rmp220_support launch_robot.launch.py \ No newline at end of file diff --git a/config/gaz_ros2_ctl_use_sim.yaml b/config/gaz_ros2_ctl_use_sim.yaml new file mode 100644 index 0000000..775d5c6 --- /dev/null +++ b/config/gaz_ros2_ctl_use_sim.yaml @@ -0,0 +1,3 @@ +controller_manager: + ros__parameters: + use_sim_time: true diff --git a/config/joystick.yaml b/config/joystick.yaml new file mode 100644 index 0000000..2112f35 --- /dev/null +++ b/config/joystick.yaml @@ -0,0 +1,27 @@ +joy_node: + ros__parameters: + device_id: 0 + deadzone: 0.05 + autorepeat_rate: 20.0 + +teleop_node: + ros__parameters: + axis_linear: + x: 1 + scale_linear: + x: 0.7 + scale_linear_turbo: + x: 1.5 + + axis_angular: + yaw: 0 + scale_angular: + yaw: 0.5 + scale_angular_turbo: + yaw: 1.0 + + + enable_button: 2 + enable_turbo_button: 5 + + require_enable_button: true \ No newline at end of file diff --git a/config/my_controllers.yaml b/config/my_controllers.yaml new file mode 100644 index 0000000..5d9721a --- /dev/null +++ b/config/my_controllers.yaml @@ -0,0 +1,68 @@ +controller_manager: + ros__parameters: + update_rate: 30 + use_sim_time: false + + diff_cont: + type: diff_drive_controller/DiffDriveController + + joint_broad: + type: joint_state_broadcaster/JointStateBroadcaster + +diff_cont: + ros__parameters: + + publish_rate: 50.0 + + base_frame_id: base_link + + left_wheel_names: ['left_wheel_joint'] + right_wheel_names: ['right_wheel_joint'] + wheel_separation: 0.35 + wheel_radius: 0.05 + + use_stamped_vel: false + + # open_loop: false + + # wheels_per_side: x + # wheel_separation_multiplier: x + # left_wheel_radius_multiplier: x + # right_wheel_radius_multiplier: x + + # odom_frame_id: x + # pose_covariance_diagonal: x + # twist_covariance_diagonal: x + # open_loop: x + # enable_odom_tf: x + + # cmd_vel_timeout: x + # publish_limited_velocity: x + # velocity_rolling_window_size: x + + + # linear.x.has_velocity_limits: false + # linear.x.has_acceleration_limits: false + # linear.x.has_jerk_limits: false + # linear.x.max_velocity: NAN + # linear.x.min_velocity: NAN + # linear.x.max_acceleration: NAN + # linear.x.min_acceleration: NAN + # linear.x.max_jerk: NAN + # linear.x.min_jerk: NAN + + # angular.z.has_velocity_limits: false + # angular.z.has_acceleration_limits: false + # angular.z.has_jerk_limits: false + # angular.z.max_velocity: NAN + # angular.z.min_velocity: NAN + # angular.z.max_acceleration: NAN + # angular.z.min_acceleration: NAN + # angular.z.max_jerk: NAN + # angular.z.min_jerk: NAN + + + + +# joint_broad: +# ros__parameters: \ No newline at end of file diff --git a/config/twist_mux.yaml b/config/twist_mux.yaml new file mode 100644 index 0000000..97411fc --- /dev/null +++ b/config/twist_mux.yaml @@ -0,0 +1,15 @@ +twist_mux: + ros__parameters: + topics: + navigation: + topic : cmd_vel + timeout : 0.5 + priority: 10 + tracker: + topic : cmd_vel_tracker + timeout : 0.5 + priority: 20 + joystick: + topic : cmd_vel_joy + timeout : 0.5 + priority: 100 \ No newline at end of file diff --git a/config/view_bot.rviz b/config/view_bot.rviz new file mode 100644 index 0000000..9b6f19b --- /dev/null +++ b/config/view_bot.rviz @@ -0,0 +1,204 @@ +Panels: + - Class: rviz_common/Displays + Help Height: 78 + Name: Displays + Property Tree Widget: + Expanded: + - /Global Options1 + - /Status1 + - /TF1 + - /RobotModel1 + - /RobotModel1/Status1 + Splitter Ratio: 0.5 + Tree Height: 759 + - Class: rviz_common/Selection + Name: Selection + - Class: rviz_common/Tool Properties + Expanded: + - /2D Goal Pose1 + - /Publish Point1 + Name: Tool Properties + Splitter Ratio: 0.5886790156364441 + - Class: rviz_common/Views + Expanded: + - /Current View1 + Name: Views + Splitter Ratio: 0.5 +Visualization Manager: + Class: "" + Displays: + - Alpha: 0.5 + Cell Size: 1 + Class: rviz_default_plugins/Grid + Color: 160; 160; 164 + Enabled: true + Line Style: + Line Width: 0.029999999329447746 + Value: Lines + Name: Grid + Normal Cell Count: 0 + Offset: + X: 0 + Y: 0 + Z: 0 + Plane: XY + Plane Cell Count: 10 + Reference Frame: + Value: true + - Class: rviz_default_plugins/TF + Enabled: true + Frame Timeout: 15 + Frames: + All Enabled: true + base_link: + Value: true + caster_wheel: + Value: true + chassis: + Value: true + left_wheel: + Value: true + right_wheel: + Value: true + Marker Scale: 1 + Name: TF + Show Arrows: true + Show Axes: true + Show Names: true + Tree: + base_link: + chassis: + caster_wheel: + {} + left_wheel: + {} + right_wheel: + {} + Update Interval: 0 + Value: true + - Alpha: 1 + Class: rviz_default_plugins/RobotModel + Collision Enabled: false + Description File: "" + Description Source: Topic + Description Topic: + Depth: 5 + Durability Policy: Volatile + History Policy: Keep Last + Reliability Policy: Reliable + Value: /robot_description + Enabled: true + Links: + All Links Enabled: true + Expand Joint Details: false + Expand Link Details: false + Expand Tree: false + Link Tree Style: Links in Alphabetic Order + base_link: + Alpha: 1 + Show Axes: false + Show Trail: false + caster_wheel: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + chassis: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + left_wheel: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + right_wheel: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + Name: RobotModel + TF Prefix: "" + Update Interval: 0 + Value: true + Visual Enabled: true + Enabled: true + Global Options: + Background Color: 48; 48; 48 + Fixed Frame: base_link + Frame Rate: 30 + Name: root + Tools: + - Class: rviz_default_plugins/Interact + Hide Inactive Objects: true + - Class: rviz_default_plugins/MoveCamera + - Class: rviz_default_plugins/Select + - Class: rviz_default_plugins/FocusCamera + - Class: rviz_default_plugins/Measure + Line color: 128; 128; 0 + - Class: rviz_default_plugins/SetInitialPose + Topic: + Depth: 5 + Durability Policy: Volatile + History Policy: Keep Last + Reliability Policy: Reliable + Value: /initialpose + - Class: rviz_default_plugins/SetGoal + Topic: + Depth: 5 + Durability Policy: Volatile + History Policy: Keep Last + Reliability Policy: Reliable + Value: /goal_pose + - Class: rviz_default_plugins/PublishPoint + Single click: true + Topic: + Depth: 5 + Durability Policy: Volatile + History Policy: Keep Last + Reliability Policy: Reliable + Value: /clicked_point + Transformation: + Current: + Class: rviz_default_plugins/TF + Value: true + Views: + Current: + Class: rviz_default_plugins/Orbit + Distance: 1.0897012948989868 + Enable Stereo Rendering: + Stereo Eye Separation: 0.05999999865889549 + Stereo Focal Distance: 1 + Swap Stereo Eyes: false + Value: false + Focal Point: + X: 0 + Y: 0 + Z: 0 + Focal Shape Fixed Size: true + Focal Shape Size: 0.05000000074505806 + Invert Z Axis: false + Name: Current View + Near Clip Distance: 0.009999999776482582 + Pitch: 0.4002038538455963 + Target Frame: + Value: Orbit (rviz) + Yaw: 5.888577461242676 + Saved: ~ +Window Geometry: + Displays: + collapsed: false + Height: 997 + Hide Left Dock: false + Hide Right Dock: false + QMainWindow State: 000000ff00000000fd00000004000000000000016a00000386fc0200000008fb0000001200530065006c0065006300740069006f006e00000001e10000009b0000006400fffffffb0000001e0054006f006f006c002000500072006f007000650072007400690065007302000001ed000001df00000185000000a3fb000000120056006900650077007300200054006f006f02000001df000002110000018500000122fb000000200054006f006f006c002000500072006f0070006500720074006900650073003203000002880000011d000002210000017afb000000100044006900730070006c006100790073010000004100000386000000dd00fffffffb0000002000730065006c0065006300740069006f006e00200062007500660066006500720200000138000000aa0000023a00000294fb00000014005700690064006500530074006500720065006f02000000e6000000d2000003ee0000030bfb0000000c004b0069006e0065006300740200000186000001060000030c00000261000000010000010f00000386fc0200000003fb0000001e0054006f006f006c002000500072006f00700065007200740069006500730100000041000000780000000000000000fb0000000a00560069006500770073010000004100000386000000b000fffffffb0000001200530065006c0065006300740069006f006e010000025a000000b200000000000000000000000200000490000000a9fc0100000001fb0000000a00560069006500770073030000004e00000080000002e10000019700000003000004420000003efc0100000002fb0000000800540069006d00650100000000000004420000000000000000fb0000000800540069006d00650100000000000004500000000000000000000004fb0000038600000004000000040000000800000008fc0000000100000002000000010000000a0054006f006f006c00730100000000ffffffff0000000000000000 + Selection: + collapsed: false + Tool Properties: + collapsed: false + Views: + collapsed: false + Width: 1920 + X: 0 + Y: 28 diff --git a/description/camera.xacro b/description/camera.xacro new file mode 100644 index 0000000..0fbcae9 --- /dev/null +++ b/description/camera.xacro @@ -0,0 +1,62 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Gazebo/Black + + + 0 0 0 0 0 0 + true + 10 + + 1.089 + + R8G8B8 + 640 + 480 + + + 0.05 + 8.0 + + + + camera_link_optical + + + + + \ No newline at end of file diff --git a/description/depth_camera.xacro b/description/depth_camera.xacro new file mode 100644 index 0000000..4caf504 --- /dev/null +++ b/description/depth_camera.xacro @@ -0,0 +1,57 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Gazebo/Red + + + 0 0 0 0 0 0 + true + 10 + + 1.089 + + B8G8R8 + 640 + 480 + + + 0.05 + 8.0 + + + + camera_link_optical + 0.1 + 100.0 + + + + + \ No newline at end of file diff --git a/description/face.xacro b/description/face.xacro new file mode 100755 index 0000000..4f05620 --- /dev/null +++ b/description/face.xacro @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Gazebo/Black + + + + \ No newline at end of file diff --git a/description/gazebo_control.xacro b/description/gazebo_control.xacro new file mode 100644 index 0000000..474b27d --- /dev/null +++ b/description/gazebo_control.xacro @@ -0,0 +1,31 @@ + + + + + + + + left_wheel_joint + right_wheel_joint + 0.297 + 0.066 + + + + 200 + 10.0 + + + + odom + base_link + + true + true + true + + + + + + \ No newline at end of file diff --git a/description/inertial_macros.xacro b/description/inertial_macros.xacro new file mode 100755 index 0000000..5cf1cac --- /dev/null +++ b/description/inertial_macros.xacro @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/description/lidar.xacro b/description/lidar.xacro new file mode 100644 index 0000000..7b09156 --- /dev/null +++ b/description/lidar.xacro @@ -0,0 +1,66 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Gazebo/Black + + + 0 0 0 0 0 0 + false + 10 + + + + 360 + -3.14 + 3.14 + + + + 0.3 + 12 + + + + + ~/out:=scan + + sensor_msgs/LaserScan + laser_frame + + + + + \ No newline at end of file diff --git a/description/robot.urdf.xacro b/description/robot.urdf.xacro index 3136feb..8cecffc 100644 --- a/description/robot.urdf.xacro +++ b/description/robot.urdf.xacro @@ -1,7 +1,21 @@ - - + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/description/robot_core.xacro b/description/robot_core.xacro new file mode 100644 index 0000000..b2b03af --- /dev/null +++ b/description/robot_core.xacro @@ -0,0 +1,204 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Gazebo/Orange + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Gazebo/Blue + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Gazebo/Blue + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Gazebo/White + + + + + \ No newline at end of file diff --git a/description/ros2_control.xacro b/description/ros2_control.xacro new file mode 100644 index 0000000..9431690 --- /dev/null +++ b/description/ros2_control.xacro @@ -0,0 +1,66 @@ + + + + + + + diffdrive_arduino/DiffDriveArduino + left_wheel_joint + right_wheel_joint + 30 + /dev/ttyUSB0 + 57600 + 1000 + 3436 + + + + -10 + 10 + + + + + + + -10 + 10 + + + + + + + + + + + gazebo_ros2_control/GazeboSystem + + + + -10 + 10 + + + + + + + -10 + 10 + + + + + + + + + + $(find segway_rmp220_support)/config/my_controllers.yaml + $(find segway_rmp220_support)/config/gaz_ros2_ctl_use_sim.yaml + + + + diff --git a/launch/camera.launch.py b/launch/camera.launch.py new file mode 100644 index 0000000..fd62dfa --- /dev/null +++ b/launch/camera.launch.py @@ -0,0 +1,23 @@ +import os + +from launch import LaunchDescription +from launch_ros.actions import Node + +def generate_launch_description(): + + + + return LaunchDescription([ + + Node( + package='v4l2_camera', + executable='v4l2_camera_node', + output='screen', + namespace='camera', + parameters=[{ + 'image_size': [640,480], + 'time_per_frame': [1, 6], + 'camera_frame_id': 'camera_link_optical' + }] + ) + ]) diff --git a/launch/joystick.launch.py b/launch/joystick.launch.py new file mode 100644 index 0000000..7ed3bf4 --- /dev/null +++ b/launch/joystick.launch.py @@ -0,0 +1,45 @@ +from launch import LaunchDescription +from launch_ros.actions import Node +from launch.substitutions import LaunchConfiguration +from launch.actions import DeclareLaunchArgument + +import os +from ament_index_python.packages import get_package_share_directory + +def generate_launch_description(): + use_sim_time = LaunchConfiguration('use_sim_time') + + joy_params = os.path.join(get_package_share_directory('segway_rmp220_support'),'config','joystick.yaml') + + joy_node = Node( + package='joy', + executable='joy_node', + parameters=[joy_params, {'use_sim_time': use_sim_time}], + ) + + teleop_node = Node( + package='teleop_twist_joy', + executable='teleop_node', + name='teleop_node', + parameters=[joy_params, {'use_sim_time': use_sim_time}], + remappings=[('/cmd_vel','/cmd_vel_joy')] + ) + + # twist_stamper = Node( + # package='twist_stamper', + # executable='twist_stamper', + # parameters=[{'use_sim_time': use_sim_time}], + # remappings=[('/cmd_vel_in','/diff_cont/cmd_vel_unstamped'), + # ('/cmd_vel_out','/diff_cont/cmd_vel')] + # ) + + + return LaunchDescription([ + DeclareLaunchArgument( + 'use_sim_time', + default_value='false', + description='Use sim time if true'), + joy_node, + teleop_node, + # twist_stamper + ]) \ No newline at end of file diff --git a/launch/launch_robot.launch.py b/launch/launch_robot.launch.py new file mode 100755 index 0000000..ceec5ba --- /dev/null +++ b/launch/launch_robot.launch.py @@ -0,0 +1,115 @@ +import os + +from ament_index_python.packages import get_package_share_directory + + +from launch import LaunchDescription +from launch.actions import IncludeLaunchDescription, TimerAction +from launch.launch_description_sources import PythonLaunchDescriptionSource +from launch.substitutions import Command +from launch.actions import RegisterEventHandler +from launch.event_handlers import OnProcessStart + +from launch_ros.actions import Node + + + +def generate_launch_description(): + + + # Include the robot_state_publisher launch file, provided by our own package. Force sim time to be enabled + # !!! MAKE SURE YOU SET THE PACKAGE NAME CORRECTLY !!! + + package_name='segway_rmp220_support' #<--- CHANGE ME + + rsp = IncludeLaunchDescription( + PythonLaunchDescriptionSource([os.path.join( + get_package_share_directory(package_name),'launch','rsp.launch.py' + )]), launch_arguments={'use_sim_time': 'false', 'use_ros2_control': 'true'}.items() + ) + + # joystick = IncludeLaunchDescription( + # PythonLaunchDescriptionSource([os.path.join( + # get_package_share_directory(package_name),'launch','joystick.launch.py' + # )]) + # ) + + + twist_mux_params = os.path.join(get_package_share_directory(package_name),'config','twist_mux.yaml') + twist_mux = Node( + package="twist_mux", + executable="twist_mux", + parameters=[twist_mux_params], + remappings=[('/cmd_vel_out','/diff_cont/cmd_vel_unstamped')] + ) + + + + + robot_description = Command(['ros2 param get --hide-type /robot_state_publisher robot_description']) + + controller_params_file = os.path.join(get_package_share_directory(package_name),'config','my_controllers.yaml') + + controller_manager = Node( + package="controller_manager", + executable="ros2_control_node", + parameters=[{'robot_description': robot_description}, + controller_params_file] + ) + + delayed_controller_manager = TimerAction(period=3.0, actions=[controller_manager]) + + diff_drive_spawner = Node( + package="controller_manager", + executable="spawner", + arguments=["diff_cont"], + ) + + delayed_diff_drive_spawner = RegisterEventHandler( + event_handler=OnProcessStart( + target_action=controller_manager, + on_start=[diff_drive_spawner], + ) + ) + + joint_broad_spawner = Node( + package="controller_manager", + executable="spawner", + arguments=["joint_broad"], + ) + + delayed_joint_broad_spawner = RegisterEventHandler( + event_handler=OnProcessStart( + target_action=controller_manager, + on_start=[joint_broad_spawner], + ) + ) + + + # Code for delaying a node (I haven't tested how effective it is) + # + # First add the below lines to imports + # from launch.actions import RegisterEventHandler + # from launch.event_handlers import OnProcessExit + # + # Then add the following below the current diff_drive_spawner + # delayed_diff_drive_spawner = RegisterEventHandler( + # event_handler=OnProcessExit( + # target_action=spawn_entity, + # on_exit=[diff_drive_spawner], + # ) + # ) + # + # Replace the diff_drive_spawner in the final return with delayed_diff_drive_spawner + + + + # Launch them all! + return LaunchDescription([ + rsp, + # joystick, + twist_mux, + delayed_controller_manager, + delayed_diff_drive_spawner, + delayed_joint_broad_spawner + ]) diff --git a/launch/launch_sim.launch.py b/launch/launch_sim.launch.py new file mode 100755 index 0000000..c00c620 --- /dev/null +++ b/launch/launch_sim.launch.py @@ -0,0 +1,98 @@ +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 + + + +def generate_launch_description(): + + + # Include the robot_state_publisher launch file, provided by our own package. Force sim time to be enabled + # !!! MAKE SURE YOU SET THE PACKAGE NAME CORRECTLY !!! + + package_name='cps_rmp220_support' #<--- CHANGE ME + + rsp = IncludeLaunchDescription( + PythonLaunchDescriptionSource([os.path.join( + get_package_share_directory(package_name),'launch','rsp.launch.py' + )]), launch_arguments={'use_sim_time': 'true', 'use_ros2_control': 'true'}.items() + ) + + joystick = IncludeLaunchDescription( + PythonLaunchDescriptionSource([os.path.join( + get_package_share_directory(package_name),'launch','joystick.launch.py' + )]), launch_arguments={'use_sim_time': 'true'}.items() + ) + + twist_mux_params = os.path.join(get_package_share_directory(package_name),'config','twist_mux.yaml') + twist_mux = Node( + package="twist_mux", + executable="twist_mux", + parameters=[twist_mux_params, {'use_sim_time': True}], + remappings=[('/cmd_vel_out','/diff_cont/cmd_vel_unstamped')] + ) + + gazebo_params_file = os.path.join(get_package_share_directory(package_name),'config','gazebo_params.yaml') + + # Include the Gazebo launch file, provided by the gazebo_ros package + gazebo = IncludeLaunchDescription( + PythonLaunchDescriptionSource([os.path.join( + get_package_share_directory('gazebo_ros'), 'launch', 'gazebo.launch.py')]), + launch_arguments={'extra_gazebo_args': '--ros-args --params-file ' + gazebo_params_file}.items() + ) + + # Run the spawner node from the gazebo_ros package. The entity name doesn't really matter if you only have a single robot. + spawn_entity = Node(package='gazebo_ros', executable='spawn_entity.py', + arguments=['-topic', 'robot_description', + '-entity', 'my_bot'], + output='screen') + + + diff_drive_spawner = Node( + package="controller_manager", + executable="spawner", + arguments=["diff_cont"], + ) + + joint_broad_spawner = Node( + package="controller_manager", + executable="spawner", + arguments=["joint_broad"], + ) + + + # Code for delaying a node (I haven't tested how effective it is) + # + # First add the below lines to imports + # from launch.actions import RegisterEventHandler + # from launch.event_handlers import OnProcessExit + # + # Then add the following below the current diff_drive_spawner + # delayed_diff_drive_spawner = RegisterEventHandler( + # event_handler=OnProcessExit( + # target_action=spawn_entity, + # on_exit=[diff_drive_spawner], + # ) + # ) + # + # Replace the diff_drive_spawner in the final return with delayed_diff_drive_spawner + + + + # Launch them all! + return LaunchDescription([ + rsp, + joystick, + twist_mux, + gazebo, + spawn_entity, + diff_drive_spawner, + joint_broad_spawner + ]) diff --git a/launch/rplidar.launch.py b/launch/rplidar.launch.py new file mode 100644 index 0000000..40c9dde --- /dev/null +++ b/launch/rplidar.launch.py @@ -0,0 +1,20 @@ +import os +from launch import LaunchDescription +from launch_ros.actions import Node + +def generate_launch_description(): + + return LaunchDescription([ + + Node( + package='rplidar_ros', + executable='rplidar_composition', + output='screen', + parameters=[{ + 'serial_port': '/dev/serial/by-path/platform-fd500000.pcie-pci-0000:01:00.0-usb-0:1.3:1.0-port0', + 'frame_id': 'laser_frame', + 'angle_compensate': True, + 'scan_mode': 'Standard' + }] + ) + ]) diff --git a/launch/rsp.launch.py b/launch/rsp.launch.py index 9744884..7a0bc33 100644 --- a/launch/rsp.launch.py +++ b/launch/rsp.launch.py @@ -14,14 +14,15 @@ def generate_launch_description(): # Check if we're told to use sim time use_sim_time = LaunchConfiguration('use_sim_time') + use_ros2_control = LaunchConfiguration('use_ros2_control') # Process the URDF file - pkg_path = os.path.join(get_package_share_directory('my_bot')) + pkg_path = os.path.join(get_package_share_directory('cps_rmp220_support')) xacro_file = os.path.join(pkg_path,'description','robot.urdf.xacro') - robot_description_config = xacro.process_file(xacro_file) + robot_description_config = Command(['xacro ', xacro_file, ' use_ros2_control:=', use_ros2_control, ' sim_mode:=', use_sim_time]) # Create a robot_state_publisher node - params = {'robot_description': robot_description_config.toxml(), 'use_sim_time': use_sim_time} + params = {'robot_description': robot_description_config, 'use_sim_time': use_sim_time} node_robot_state_publisher = Node( package='robot_state_publisher', executable='robot_state_publisher', @@ -36,6 +37,10 @@ def generate_launch_description(): 'use_sim_time', default_value='false', description='Use sim time if true'), + DeclareLaunchArgument( + 'use_ros2_control', + default_value='true', + description='Use ros2_control if true'), node_robot_state_publisher ]) diff --git a/package.xml b/package.xml index 355c55b..9474e7e 100644 --- a/package.xml +++ b/package.xml @@ -1,10 +1,10 @@ - my_bot - 0.0.0 - TODO: Package description - MY NAME + cps_rmp220_support + 0.0.1 + Segway RMP220 lite ackage for control, simulation and visualization + MY NAME TODO: License declaration ament_cmake diff --git a/worlds/obstacles.world b/worlds/obstacles.world new file mode 100644 index 0000000..dc9fa2e --- /dev/null +++ b/worlds/obstacles.world @@ -0,0 +1,935 @@ + + + + 1 + 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 + + 0 + 0 + 0 + + + + 1 + + + + + 0 0 1 + 100 100 + + + + + 65535 + + + + + 100 + 50 + + + + + + + + 10 + + + 0 + + + 0 0 1 + 100 100 + + + + + + + 0 + 0 + 0 + + + 0 0 -9.8 + 6e-06 2.3e-05 -4.2e-05 + + + 0.001 + 1 + 1000 + + + 0.4 0.4 0.4 1 + 0.7 0.7 0.7 1 + 1 + + + + EARTH_WGS84 + 0 + 0 + 0 + 0 + + + + + 0 0 0.4 0 -0 0 + 500 + + 51.2096 + 51.2096 + 25 + 0 + 0 + 0 + + + + + + model://construction_barrel/meshes/construction_barrel.dae + + + 10 + + + + + + + + + + + + + + + + + model://construction_barrel/meshes/construction_barrel.dae + + + + 0 + 0 + 0 + + -0.756237 1.39226 0 0 -0 0 + + + + + 0 0 0.4 0 -0 0 + 500 + + 51.2096 + 51.2096 + 25 + 0 + 0 + 0 + + + + + + model://construction_barrel/meshes/construction_barrel.dae + + + 10 + + + + + + + + + + + + + + + + + model://construction_barrel/meshes/construction_barrel.dae + + + + 0 + 0 + 0 + + 1.80022 0.377178 0 0 -0 0 + + + + + + + 10 10 10 + model://construction_cone/meshes/construction_cone.dae + + + 10 + + + + + + + + + + + + + + + + + 10 10 10 + model://construction_cone/meshes/construction_cone.dae + + + + 0 + + 0 0 0 0 -0 0 + + 1 + 0 + 0 + 1 + 0 + 1 + + 1 + + 0 + 0 + + -2.19745 -2.25046 0 0 -0 0 + + + + + + + 10 10 10 + model://construction_cone/meshes/construction_cone.dae + + + 10 + + + + + + + + + + + + + + + + + 10 10 10 + model://construction_cone/meshes/construction_cone.dae + + + + 0 + + 0 0 0 0 -0 0 + + 1 + 0 + 0 + 1 + 0 + 1 + + 1 + + 0 + 0 + + -1.40494 -2.55135 0 0 -0 0 + + + + + + + 10 10 10 + model://construction_cone/meshes/construction_cone.dae + + + 10 + + + + + + + + + + + + + + + + + 10 10 10 + model://construction_cone/meshes/construction_cone.dae + + + + 0 + + 0 0 0 0 -0 0 + + 1 + 0 + 0 + 1 + 0 + 1 + + 1 + + 0 + 0 + + -0.501986 -2.9745 0 0 -0 0 + + + + + + + 10 10 10 + model://construction_cone/meshes/construction_cone.dae + + + 10 + + + + + + + + + + + + + + + + + 10 10 10 + model://construction_cone/meshes/construction_cone.dae + + + + 0 + + 0 0 0 0 -0 0 + + 1 + 0 + 0 + 1 + 0 + 1 + + 1 + + 0 + 0 + + 2.09724 -2.18232 0 0 -0 0 + + + + + + + 10 10 10 + model://construction_cone/meshes/construction_cone.dae + + + 10 + + + + + + + + + + + + + + + + + 10 10 10 + model://construction_cone/meshes/construction_cone.dae + + + + 0 + + 0 0 0 0 -0 0 + + 1 + 0 + 0 + 1 + 0 + 1 + + 1 + + 0 + 0 + + -3.69879 0.345038 0 0 -0 0 + + + + + + + 10 10 10 + model://construction_cone/meshes/construction_cone.dae + + + 10 + + + + + + + + + + + + + + + + + 10 10 10 + model://construction_cone/meshes/construction_cone.dae + + + + 0 + + 0 0 0 0 -0 0 + + 1 + 0 + 0 + 1 + 0 + 1 + + 1 + + 0 + 0 + + -0.406438 -4.23374 0 0 -0 0 + + + + + + + 10 10 10 + model://construction_cone/meshes/construction_cone.dae + + + 10 + + + + + + + + + + + + + + + + + 10 10 10 + model://construction_cone/meshes/construction_cone.dae + + + + 0 + + 0 0 0 0 -0 0 + + 1 + 0 + 0 + 1 + 0 + 1 + + 1 + + 0 + 0 + + 2.38815 -3.2576 0 0 -0 0 + + + + + + + 10 10 10 + model://construction_cone/meshes/construction_cone.dae + + + 10 + + + + + + + + + + + + + + + + + 10 10 10 + model://construction_cone/meshes/construction_cone.dae + + + + 0 + + 0 0 0 0 -0 0 + + 1 + 0 + 0 + 1 + 0 + 1 + + 1 + + 0 + 0 + + 2.39316 -4.49605 0 0 -0 0 + + + + + + + 10 10 10 + model://construction_cone/meshes/construction_cone.dae + + + 10 + + + + + + + + + + + + + + + + + 10 10 10 + model://construction_cone/meshes/construction_cone.dae + + + + 0 + + 0 0 0 0 -0 0 + + 1 + 0 + 0 + 1 + 0 + 1 + + 1 + + 0 + 0 + + -3.00495 -2.78053 0 0 -0 0 + + + + + + + 10 10 10 + model://construction_cone/meshes/construction_cone.dae + + + 10 + + + + + + + + + + + + + + + + + 10 10 10 + model://construction_cone/meshes/construction_cone.dae + + + + 0 + + 0 0 0 0 -0 0 + + 1 + 0 + 0 + 1 + 0 + 1 + + 1 + + 0 + 0 + + -4.64786 -0.646522 0 0 -0 0 + + + + + 0 0 0.4 0 -0 0 + 500 + + 51.2096 + 51.2096 + 25 + 0 + 0 + 0 + + + + + + model://construction_barrel/meshes/construction_barrel.dae + + + 10 + + + + + + + + + + + + + + + + + model://construction_barrel/meshes/construction_barrel.dae + + + + 0 + 0 + 0 + + -5.3108 -2.23708 0 0 -0 0 + + + + + 0 0 0.4 0 -0 0 + 500 + + 51.2096 + 51.2096 + 25 + 0 + 0 + 0 + + + + + + model://construction_barrel/meshes/construction_barrel.dae + + + 10 + + + + + + + + + + + + + + + + + model://construction_barrel/meshes/construction_barrel.dae + + + + 0 + 0 + 0 + + -2.07692 -4.26198 0 0 -0 0 + + + 457 444000000 + 459 829915274 + 1646216792 728719362 + 457444 + + -0.756319 1.39223 0 0 0 -2.4e-05 + 1 1 1 + + -0.756319 1.39223 0 0 0 -2.4e-05 + 0 0 0 0 -0 0 + 3.45865 5.7443 4.40608 1.34644 0.778762 3.14097 + 1729.32 2872.15 2203.04 0 -0 0 + + + + 1.80014 0.377148 0 0 0 -2.2e-05 + 1 1 1 + + 1.80014 0.377148 0 0 0 -2.2e-05 + 0 0 0 0 -0 0 + 3.45864 5.7443 4.40608 1.34642 0.778778 3.14097 + 1729.32 2872.15 2203.04 0 -0 0 + + + + -5.31082 -2.23709 -0 0 -0 -7e-06 + 1 1 1 + + -5.31082 -2.23709 -0 0 -0 -7e-06 + 0 0 0 0 -0 0 + -3.87743 -2.8936 0.727843 -2.17783 0.268134 -3.13538 + -1938.71 -1446.8 363.922 0 -0 0 + + + + -2.07693 -4.26199 -0 0 0 -4e-06 + 1 1 1 + + -2.07693 -4.26199 -0 0 0 -4e-06 + 0 0 0 0 -0 0 + 7.60795 0.965639 1.20183 -2.41278 0.170207 0.001195 + 3803.98 482.819 600.916 0 -0 0 + + + + -2.19745 -2.25046 -0 0 -0 0 + 1 1 1 + + -2.19745 -2.25046 -0 0 -0 0 + 0 0 0 0 -0 0 + 0 -0 -0.008512 -2.58585 1.13682 3.14159 + 0 -0 -0.008512 0 -0 0 + + + + -1.40494 -2.55135 -0 0 -0 0 + 1 1 1 + + -1.40494 -2.55135 -0 0 -0 0 + 0 0 0 0 -0 0 + 0 -0 -0.008512 -2.58585 1.13682 3.14159 + 0 -0 -0.008512 0 -0 0 + + + + -0.501986 -2.9745 -0 0 -0 0 + 1 1 1 + + -0.501986 -2.9745 -0 0 -0 0 + 0 0 0 0 -0 0 + 0 -0 -0.008512 -2.58585 1.13682 3.14159 + 0 -0 -0.008512 0 -0 0 + + + + 2.09724 -2.18232 -0 1e-06 -0 0 + 1 1 1 + + 2.09724 -2.18232 -0 1e-06 -0 0 + 0 0 0 0 -0 0 + -0 -0 -9.79988 3e-05 2e-05 -0 + -0 -0 -9.79988 0 -0 0 + + + + -3.69879 0.345038 -1e-05 0 -0 0 + 1 1 1 + + -3.69879 0.345038 -1e-05 0 -0 0 + 0 0 0 0 -0 0 + 0 0 -9.8 0 -0 0 + 0 0 -9.8 0 -0 0 + + + + -0.406438 -4.23374 -0 0 -1e-06 0 + 1 1 1 + + -0.406438 -4.23374 -0 0 -1e-06 0 + 0 0 0 0 -0 0 + -0 0 0.008512 2.58585 -1.13682 -3.14159 + -0 0 0.008512 0 -0 0 + + + + 2.38815 -3.2576 -0 0 -0 0 + 1 1 1 + + 2.38815 -3.2576 -0 0 -0 0 + 0 0 0 0 -0 0 + 0 -0 -0.008512 -2.58585 1.13682 3.14159 + 0 -0 -0.008512 0 -0 0 + + + + 2.39316 -4.49605 -0 0 -1e-06 0 + 1 1 1 + + 2.39316 -4.49605 -0 0 -1e-06 0 + 0 0 0 0 -0 0 + -0 0 0.008512 2.58585 -1.13682 -3.14159 + -0 0 0.008512 0 -0 0 + + + + -3.00495 -2.78053 -0 0 -1e-06 0 + 1 1 1 + + -3.00495 -2.78053 -0 0 -1e-06 0 + 0 0 0 0 -0 0 + -0 0 0.008512 2.58585 -1.13682 -3.14159 + -0 0 0.008512 0 -0 0 + + + + -4.64786 -0.646522 -0 0 -1e-06 0 + 1 1 1 + + -4.64786 -0.646522 -0 0 -1e-06 0 + 0 0 0 0 -0 0 + -0 0 0.008512 2.58585 -1.13682 -3.14159 + -0 0 0.008512 0 -0 0 + + + + 0 0 0 0 -0 0 + 1 1 1 + + 0 0 0 0 -0 0 + 0 0 0 0 -0 0 + 0 0 0 0 -0 0 + 0 0 0 0 -0 0 + + + + 0 0 10 0 -0 0 + + + + + -15.5892 0.392985 21.6628 0 0.851642 0.028194 + orbit + perspective + + + +