diff --git a/dummy_robot/dummy_robot_bringup/CMakeLists.txt b/dummy_robot/dummy_robot_bringup/CMakeLists.txt index f73a49f6b..3cf51ba64 100644 --- a/dummy_robot/dummy_robot_bringup/CMakeLists.txt +++ b/dummy_robot/dummy_robot_bringup/CMakeLists.txt @@ -4,7 +4,7 @@ project(dummy_robot_bringup) find_package(ament_cmake REQUIRED) -install(DIRECTORY launch +install(DIRECTORY launch rviz DESTINATION share/${PROJECT_NAME}) if(BUILD_TESTING) diff --git a/dummy_robot/dummy_robot_bringup/README.md b/dummy_robot/dummy_robot_bringup/README.md new file mode 100644 index 000000000..e23a311d2 --- /dev/null +++ b/dummy_robot/dummy_robot_bringup/README.md @@ -0,0 +1,76 @@ +## **What Is This?** + +This is a simple demo robot with all components from publishing **joint states** to publishing **fake laser data** to visualizing the robot model on a map in `RViz2`. + +## **Build** + +```bash +colcon build --package-select dummy_map_server dummy_sensors dummy_robot_bringup +``` + +## **Run** + +```bash +ros2 launch dummy_robot_bringup dummy_robot_bringup.launch.py +``` + +## **Verify** + +A similar terminal output should be seen: + +```bash +[INFO] [launch]: All log files can be found below /home/$USER/.ros/log/2022-07-22-17-02-33-629155-comname-39641 +[INFO] [launch]: Default logging verbosity is set to INFO +[INFO] [dummy_map_server-1]: process started with pid [39643] +[INFO] [robot_state_publisher-2]: process started with pid [39645] +[INFO] [dummy_joint_states-3]: process started with pid [39647] +[INFO] [dummy_laser-4]: process started with pid [39649] +[dummy_laser-4] [INFO] [1658480554.018685559] [dummy_laser]: angle inc: 0.004363 +[dummy_laser-4] [INFO] [1658480554.018738346] [dummy_laser]: scan size: 1081 +[dummy_laser-4] [INFO] [1658480554.018747091] [dummy_laser]: scan time increment: 0.000028 +[robot_state_publisher-2] Link single_rrbot_link1 had 1 children +[robot_state_publisher-2] Link single_rrbot_link2 had 1 children +[robot_state_publisher-2] Link single_rrbot_link3 had 2 children +[robot_state_publisher-2] Link single_rrbot_camera_link had 0 children +[robot_state_publisher-2] Link single_rrbot_hokuyo_link had 0 children +[robot_state_publisher-2] [INFO] [1658480554.019739425] [robot_state_publisher]: got segment single_rrbot_camera_link +[robot_state_publisher-2] [INFO] [1658480554.019783457] [robot_state_publisher]: got segment single_rrbot_hokuyo_link +[robot_state_publisher-2] [INFO] [1658480554.019791344] [robot_state_publisher]: got segment single_rrbot_link1 +[robot_state_publisher-2] [INFO] [1658480554.019796905] [robot_state_publisher]: got segment single_rrbot_link2 +[robot_state_publisher-2] [INFO] [1658480554.019801861] [robot_state_publisher]: got segment single_rrbot_link3 +[robot_state_publisher-2] [INFO] [1658480554.019806522] [robot_state_publisher]: got segment world +``` + +The robot should be displayed similarly in `RViz2`: + +![](img/robot_in_rviz.gif) + +## **FAQ** + +`Q`: I ran `ros2 launch dummy_robot_bringup dummy_robot_bringup.launch.py` and `rviz2`. However, nothing is displayed in `RViz2` window. + +`A`: This issue could be related to the **ROS 2 Daemon**. It serves the same role as a **ROS1 Master** but within **ROS 2**. Restarting the daemon, as follows, should resolve this issue. + +`Reference`: https://github.com/ros2/ros2cli/issues/582#issuecomment-775997721 + +``` bash +ros2 daemon stop; ros2 daemon start +# Verify +# Open new terminal +ros2 launch dummy_robot_bringup dummy_robot_bringup.launch.py +# Open new terminal +ros2 node list +``` + +```bash +# You should see the following terminal output: +/dummy_joint_states +/dummy_laser +/dummy_map_server +/robot_state_publisher +``` + +## **References** + +- Original Rolling Demo Tutorial: https://docs.ros.org/en/rolling/Tutorials/Demos/dummy-robot-demo.html +- What is ROS 2 Daemon: https://answers.ros.org/question/327348/what-is-ros2-daemon/ diff --git a/dummy_robot/dummy_robot_bringup/config/dummy_robot.rviz b/dummy_robot/dummy_robot_bringup/config/dummy_robot.rviz deleted file mode 100644 index 0aaff270b..000000000 --- a/dummy_robot/dummy_robot_bringup/config/dummy_robot.rviz +++ /dev/null @@ -1,180 +0,0 @@ -Panels: - - Class: rviz/Displays - Help Height: 78 - Name: Displays - Property Tree Widget: - Expanded: - - /Global Options1 - - /Status1 - - /TF1 - - /TF1/Frames1 - - /Map1 - - /Map1/Status1 - Splitter Ratio: 0.5 - Tree Height: 717 - - Class: rviz/Selection - Name: Selection - - Class: rviz/Tool Properties - Expanded: - - /2D Pose Estimate1 - - /2D Nav Goal1 - - /Publish Point1 - Name: Tool Properties - Splitter Ratio: 0.588679016 - - Class: rviz/Views - Expanded: - - /Current View1 - Name: Views - Splitter Ratio: 0.5 - - Class: rviz/Time - Experimental: false - Name: Time - SyncMode: 0 - SyncSource: LaserScan -Visualization Manager: - Class: "" - Displays: - - Alpha: 0.5 - Cell Size: 1 - Class: rviz/Grid - Color: 160; 160; 164 - Enabled: true - Line Style: - Line Width: 0.0299999993 - 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/TF - Enabled: true - Frame Timeout: 15 - Frames: - All Enabled: false - base_link: - Value: true - dummy_laser_link: - Value: true - link1: - Value: true - link2: - Value: true - Marker Scale: 0.5 - Name: TF - Show Arrows: true - Show Axes: true - Show Names: true - Tree: - base_link: - link1: - link2: - dummy_laser_link: - {} - Update Interval: 0 - Value: true - - Alpha: 1 - Autocompute Intensity Bounds: true - Autocompute Value Bounds: - Max Value: 10 - Min Value: -10 - Value: true - Axis: Z - Channel Name: intensity - Class: rviz/LaserScan - Color: 255; 255; 255 - Color Transformer: Intensity - Decay Time: 0 - Enabled: true - Invert Rainbow: false - Max Color: 255; 255; 255 - Max Intensity: 0 - Min Color: 0; 0; 0 - Min Intensity: 0 - Name: LaserScan - Position Transformer: XYZ - Queue Size: 10 - Selectable: true - Size (Pixels): 3 - Size (m): 0.00999999978 - Style: Flat Squares - Topic: /scan - Unreliable: false - Use Fixed Frame: true - Use rainbow: true - Value: true - - Alpha: 0.699999988 - Class: rviz/Map - Color Scheme: costmap - Draw Behind: false - Enabled: true - Name: Map - Topic: /map - Unreliable: false - Value: true - Enabled: true - Global Options: - Background Color: 48; 48; 48 - Fixed Frame: base_link - Frame Rate: 30 - Name: root - Tools: - - Class: rviz/Interact - Hide Inactive Objects: true - - Class: rviz/MoveCamera - - Class: rviz/Select - - Class: rviz/FocusCamera - - Class: rviz/Measure - - Class: rviz/SetInitialPose - Topic: /initialpose - - Class: rviz/SetGoal - Topic: /move_base_simple/goal - - Class: rviz/PublishPoint - Single click: true - Topic: /clicked_point - Value: true - Views: - Current: - Class: rviz/Orbit - Distance: 13.0682049 - Enable Stereo Rendering: - Stereo Eye Separation: 0.0599999987 - Stereo Focal Distance: 1 - Swap Stereo Eyes: false - Value: false - Focal Point: - X: -0.452401936 - Y: -0.743706822 - Z: 0.43603161 - Focal Shape Fixed Size: true - Focal Shape Size: 0.0500000007 - Name: Current View - Near Clip Distance: 0.00999999978 - Pitch: 0.505398452 - Target Frame: - Value: Orbit (rviz) - Yaw: 5.48862028 - Saved: ~ -Window Geometry: - Displays: - collapsed: false - Height: 1029 - Hide Left Dock: false - Hide Right Dock: false - QMainWindow State: 000000ff00000000fd0000000400000000000002380000035efc0200000009fb0000001200530065006c0065006300740069006f006e00000001e10000009b0000006600fffffffb0000001e0054006f006f006c002000500072006f007000650072007400690065007302000001ed000001df00000185000000a3fb000000120056006900650077007300200054006f006f02000001df000002110000018500000122fb000000200054006f006f006c002000500072006f0070006500720074006900650073003203000002880000011d000002210000017afb000000100044006900730070006c00610079007301000000430000035e000000df00fffffffb0000002000730065006c0065006300740069006f006e00200062007500660066006500720200000138000000aa0000023a00000294fb00000014005700690064006500530074006500720065006f02000000e6000000d2000003ee0000030bfb0000000c004b0069006e0065006300740200000186000001060000030c00000261fb0000000a0049006d00610067006501000002a2000000ff0000000000000000000000010000010f0000035efc0200000003fb0000001e0054006f006f006c002000500072006f00700065007200740069006500730100000041000000780000000000000000fb0000000a0056006900650077007301000000430000035e000000b800fffffffb0000001200530065006c0065006300740069006f006e010000025a000000b200000000000000000000000200000490000000a9fc0100000001fb0000000a00560069006500770073030000004e00000080000002e100000197000000030000077e0000003efc0100000002fb0000000800540069006d006501000000000000077e0000022400fffffffb0000000800540069006d006501000000000000045000000000000000000000042b0000035e00000004000000040000000800000008fc0000000100000002000000010000000a0054006f006f006c00730100000000ffffffff0000000000000000 - Selection: - collapsed: false - Time: - collapsed: false - Tool Properties: - collapsed: false - Views: - collapsed: false - Width: 1918 - X: 0 - Y: 0 diff --git a/dummy_robot/dummy_robot_bringup/img/robot_in_rviz.gif b/dummy_robot/dummy_robot_bringup/img/robot_in_rviz.gif new file mode 100644 index 000000000..ef99d211f Binary files /dev/null and b/dummy_robot/dummy_robot_bringup/img/robot_in_rviz.gif differ diff --git a/dummy_robot/dummy_robot_bringup/launch/dummy_robot_bringup_launch.py b/dummy_robot/dummy_robot_bringup/launch/dummy_robot_bringup_launch.py index 383834f74..def22e90b 100755 --- a/dummy_robot/dummy_robot_bringup/launch/dummy_robot_bringup_launch.py +++ b/dummy_robot/dummy_robot_bringup/launch/dummy_robot_bringup_launch.py @@ -16,20 +16,37 @@ from launch import LaunchDescription from launch_ros.actions import Node +from launch.actions import DeclareLaunchArgument from launch_ros.substitutions import FindPackageShare +from launch.substitutions import LaunchConfiguration def generate_launch_description(): + pkg_share = FindPackageShare('dummy_robot_bringup').find('dummy_robot_bringup') + + default_rviz_config_path = os.path.join(pkg_share, 'rviz/dummy_robot.rviz') + rviz_config_file = LaunchConfiguration('rviz_config_file') + urdf_file = os.path.join(pkg_share, 'launch', 'single_rrbot.urdf') + + rviz_config_file_arg = DeclareLaunchArgument( + 'rviz_config_file', + default_value=default_rviz_config_path + ) + with open(urdf_file, 'r') as infp: robot_desc = infp.read() rsp_params = {'robot_description': robot_desc} return LaunchDescription([ + rviz_config_file_arg, Node(package='dummy_map_server', executable='dummy_map_server', output='screen'), Node(package='robot_state_publisher', executable='robot_state_publisher', output='screen', parameters=[rsp_params]), Node(package='dummy_sensors', executable='dummy_joint_states', output='screen'), - Node(package='dummy_sensors', executable='dummy_laser', output='screen') + Node(package='dummy_sensors', executable='dummy_laser', output='screen'), + Node(package='rviz2', executable='rviz2', name='rviz2', output='screen', + arguments=['-d', rviz_config_file]) + ]) diff --git a/dummy_robot/dummy_robot_bringup/rviz/dummy_robot.rviz b/dummy_robot/dummy_robot_bringup/rviz/dummy_robot.rviz new file mode 100644 index 000000000..5b7d20ce1 --- /dev/null +++ b/dummy_robot/dummy_robot_bringup/rviz/dummy_robot.rviz @@ -0,0 +1,158 @@ +Panels: + - Class: rviz_common/Displays + Help Height: 78 + Name: Displays + Property Tree Widget: + Expanded: + - /Global Options1 + - /Status1 + - /TF1 + - /TF1/Frames1 + Splitter Ratio: 0.5 + Tree Height: 787 + - 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 + single_rrbot_camera_link: + Value: true + single_rrbot_hokuyo_link: + Value: true + single_rrbot_link1: + Value: true + single_rrbot_link2: + Value: true + single_rrbot_link3: + Value: true + world: + Value: true + Marker Scale: 1 + Name: TF + Show Arrows: true + Show Axes: true + Show Names: true + Tree: + world: + single_rrbot_link1: + single_rrbot_link2: + single_rrbot_link3: + single_rrbot_camera_link: + {} + single_rrbot_hokuyo_link: + {} + Update Interval: 0 + Value: true + Enabled: true + Global Options: + Background Color: 48; 48; 48 + Fixed Frame: world + 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: 6.071485996246338 + Enable Stereo Rendering: + Stereo Eye Separation: 0.05999999865889549 + Stereo Focal Distance: 1 + Swap Stereo Eyes: false + Value: false + Focal Point: + X: -0.8615996837615967 + Y: -0.9043077230453491 + Z: 1.684801697731018 + Focal Shape Fixed Size: true + Focal Shape Size: 0.05000000074505806 + Invert Z Axis: false + Name: Current View + Near Clip Distance: 0.009999999776482582 + Pitch: 0.4753981828689575 + Target Frame: + Value: Orbit (rviz) + Yaw: 0.7203975915908813 + Saved: ~ +Window Geometry: + Displays: + collapsed: false + Height: 1016 + Hide Left Dock: false + Hide Right Dock: false + QMainWindow State: 000000ff00000000fd00000004000000000000022c0000039efc0200000008fb0000001200530065006c0065006300740069006f006e00000001e10000009b0000005c00fffffffb0000001e0054006f006f006c002000500072006f007000650072007400690065007302000001ed000001df00000185000000a3fb000000120056006900650077007300200054006f006f02000001df000002110000018500000122fb000000200054006f006f006c002000500072006f0070006500720074006900650073003203000002880000011d000002210000017afb000000100044006900730070006c006100790073010000003d0000039e000000c900fffffffb0000002000730065006c0065006300740069006f006e00200062007500660066006500720200000138000000aa0000023a00000294fb00000014005700690064006500530074006500720065006f02000000e6000000d2000003ee0000030bfb0000000c004b0069006e0065006300740200000186000001060000030c00000261000000010000010f0000039efc0200000003fb0000001e0054006f006f006c002000500072006f00700065007200740069006500730100000041000000780000000000000000fb0000000a00560069006500770073010000003d0000039e000000a400fffffffb0000001200530065006c0065006300740069006f006e010000025a000000b200000000000000000000000200000490000000a9fc0100000001fb0000000a00560069006500770073030000004e00000080000002e10000019700000003000004420000003efc0100000002fb0000000800540069006d00650100000000000004420000000000000000fb0000000800540069006d00650100000000000004500000000000000000000003f10000039e00000004000000040000000800000008fc0000000100000002000000010000000a0054006f006f006c00730100000000ffffffff0000000000000000 + Selection: + collapsed: false + Tool Properties: + collapsed: false + Views: + collapsed: false + Width: 1848 + X: 72 + Y: 27