diff --git a/docs/mvsim_node.rst b/docs/mvsim_node.rst index 5ff7ed86..ffe1b227 100644 --- a/docs/mvsim_node.rst +++ b/docs/mvsim_node.rst @@ -25,7 +25,8 @@ Basic usage from the command line .. code-block:: bash roslaunch mvsim launch_world.launch \ - XX + world_file:=/path/to/your/my.world.xml \ + headless:=True .. tab-item:: ROS 2 :selected: @@ -33,54 +34,46 @@ Basic usage from the command line .. code-block:: bash ros2 launch mvsim launch_world.launch.py \ - world_file:=/path/to/your/my.world.xml + world_file:=/path/to/your/my.world.xml \ + headless:=True | All launch parameters ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +All these parameters apply to both, ROS 1 and ROS 2 launch files above: -.. tab-set:: - .. tab-item:: ROS 1 - - .. code-block:: bash - - xxx - - .. tab-item:: ROS 2 - :selected: - - .. code-block:: bash +.. code-block:: bash - $ ros2 launch mvsim launch_world.launch.py --show-args - Arguments (pass arguments as ':='): + $ ros2 launch mvsim launch_world.launch.py --show-args + Arguments (pass arguments as ':='): - 'world_file': - Path to the *.world.xml file to load + 'world_file': + Path to the *.world.xml file to load - 'headless': - no description given - (default: 'False') + 'headless': + no description given + (default: 'False') - 'do_fake_localization': - publish fake identity tf "map" -> "odom" - (default: 'True') + 'do_fake_localization': + publish fake identity tf "map" -> "odom" + (default: 'True') - 'publish_tf_odom2baselink': - publish tf "odom" -> "base_link" - (default: 'True') + 'publish_tf_odom2baselink': + publish tf "odom" -> "base_link" + (default: 'True') - 'force_publish_vehicle_namespace': - Use vehicle name namespace even if there is only one vehicle - (default: 'False') + 'force_publish_vehicle_namespace': + Use vehicle name namespace even if there is only one vehicle + (default: 'False') - 'use_rviz': - Whether to launch RViz2 - (default: 'True') + 'use_rviz': + Whether to launch RViz2 + (default: 'True') - 'rviz_config_file': - If use_rviz:="True", the configuration file for rviz - (default: '') + 'rviz_config_file': + If use_rviz:="True", the configuration file for rviz + (default: '') | @@ -92,9 +85,29 @@ You can use this code to bootstrap your own launch files: .. tab-set:: .. tab-item:: ROS 1 - .. code-block:: bash - - xxx + .. code-block:: xml + + + + + + + + + + + + + + + + + + + + + + .. tab-item:: ROS 2 :selected: diff --git a/launch/launch_world.launch b/launch/launch_world.launch new file mode 100644 index 00000000..4f5be820 --- /dev/null +++ b/launch/launch_world.launch @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/launch/launch_world.launch.py b/launch/launch_world.launch.py index 61dc8a3e..37e7cf63 100644 --- a/launch/launch_world.launch.py +++ b/launch/launch_world.launch.py @@ -1,4 +1,5 @@ # Generic ROS2 launch file +# Read: https://mvsimulator.readthedocs.io/en/latest/mvsim_node.html from launch import LaunchDescription from launch.substitutions import LaunchConfiguration diff --git a/mvsim_tutorial/demo_depth_camera.rviz b/mvsim_tutorial/demo_depth_camera.rviz index a0f38397..31259b28 100644 --- a/mvsim_tutorial/demo_depth_camera.rviz +++ b/mvsim_tutorial/demo_depth_camera.rviz @@ -6,10 +6,8 @@ Panels: Expanded: - /Global Options1 - /Status1 - - /MarkerArray1 - - /Image1 Splitter Ratio: 0.4941176474094391 - Tree Height: 538 + Tree Height: 559 - Class: rviz/Selection Name: Selection - Class: rviz/Tool Properties @@ -27,7 +25,7 @@ Panels: - Class: rviz/Time Name: Time SyncMode: 0 - SyncSource: LaserScan + SyncSource: Image - Class: rviz_plugin_tutorials/Teleop Name: Teleop Topic: /cmd_vel @@ -58,24 +56,22 @@ Visualization Manager: Value: true - Class: rviz/TF Enabled: true + Filter (blacklist): "" + Filter (whitelist): "" Frame Timeout: 15 Frames: All Enabled: true - base_footprint: - Value: true base_link: Value: true - camera1_image: - Value: true - camera1_points: + cam1: Value: true - laser1: + lidar1_points: Value: true map: Value: true odom: Value: true - world: + scanner1: Value: true Marker Alpha: 1 Marker Scale: 1 @@ -84,18 +80,15 @@ Visualization Manager: Show Axes: true Show Names: true Tree: - world: - map: - odom: - base_link: - base_footprint: - {} - camera1_image: - {} - camera1_points: - {} - laser1: - {} + map: + odom: + base_link: + cam1: + {} + lidar1_points: + {} + scanner1: + {} Update Interval: 0 Value: true - Class: rviz/MarkerArray @@ -106,6 +99,8 @@ Visualization Manager: mvsim.chassis_shape: true mvsim.chassis_shape.wheel0: true mvsim.chassis_shape.wheel1: true + mvsim.chassis_shape.wheel2: true + mvsim.chassis_shape.wheel3: true Queue Size: 100 Value: true - Alpha: 1 @@ -166,7 +161,7 @@ Visualization Manager: Value: true - Class: rviz/Image Enabled: true - Image Topic: /camera1_image + Image Topic: /cam1/image_raw Max Value: 1 Median window: 5 Min Value: 0 @@ -176,6 +171,34 @@ Visualization Manager: Transport Hint: raw Unreliable: false Value: true + - Alpha: 1 + Autocompute Intensity Bounds: true + Autocompute Value Bounds: + Max Value: 10 + Min Value: -10 + Value: true + Axis: Z + Channel Name: z + Class: rviz/PointCloud2 + Color: 255; 255; 255 + Color Transformer: Intensity + Decay Time: 0 + Enabled: true + Invert Rainbow: false + Max Color: 255; 255; 255 + Min Color: 0; 0; 0 + Name: 3D LiDAR + Position Transformer: XYZ + Queue Size: 10 + Selectable: true + Size (Pixels): 3 + Size (m): 0.029999999329447746 + Style: Flat Squares + Topic: /lidar1_points + Unreliable: false + Use Fixed Frame: true + Use rainbow: true + Value: true Enabled: true Global Options: Background Color: 48; 48; 48 @@ -204,7 +227,7 @@ Visualization Manager: Views: Current: Class: rviz/Orbit - Distance: 14.817850112915039 + Distance: 21.356739044189453 Enable Stereo Rendering: Stereo Eye Separation: 0.05999999865889549 Stereo Focal Distance: 1 @@ -212,27 +235,27 @@ Visualization Manager: Value: false Field of View: 0.7853981852531433 Focal Point: - X: 8.227726936340332 - Y: -0.9801739454269409 - Z: 0.4060775637626648 + X: 8.40973949432373 + Y: -0.6488088369369507 + Z: 0.9110875725746155 Focal Shape Fixed Size: true Focal Shape Size: 0.05000000074505806 Invert Z Axis: false Name: Current View Near Clip Distance: 0.009999999776482582 - Pitch: 0.180398091673851 + Pitch: 0.24039803445339203 Target Frame: - Yaw: 2.8854002952575684 + Yaw: 2.8703999519348145 Saved: ~ Window Geometry: Displays: collapsed: false - Height: 1016 + Height: 1043 Hide Left Dock: false Hide Right Dock: false Image: collapsed: false - QMainWindow State: 000000ff00000000fd0000000400000000000001560000035afc0200000009fb0000001200530065006c0065006300740069006f006e00000001e10000009b0000005c00fffffffb0000001e0054006f006f006c002000500072006f007000650072007400690065007302000001ed000001df00000185000000a3fb000000120056006900650077007300200054006f006f02000001df000002110000018500000122fb000000200054006f006f006c002000500072006f0070006500720074006900650073003203000002880000011d000002210000017afb000000100044006900730070006c006100790073010000003d000002a5000000c900fffffffb0000002000730065006c0065006300740069006f006e00200062007500660066006500720200000138000000aa0000023a00000294fb00000014005700690064006500530074006500720065006f02000000e6000000d2000003ee0000030bfb0000000c004b0069006e0065006300740200000186000001060000030c00000261fb0000000c00540065006c0065006f007001000002e8000000af0000004700ffffff00000001000001f80000035afc0200000004fb0000000a0049006d006100670065010000003d0000035a0000001600fffffffb0000001e0054006f006f006c002000500072006f00700065007200740069006500730100000041000000780000000000000000fb0000000a00560069006500770073000000003d00000339000000a400fffffffb0000001200530065006c0065006300740069006f006e010000025a000000b200000000000000000000000200000490000000a9fc0100000001fb0000000a00560069006500770073030000004e00000080000002e10000019700000003000007380000003efc0100000002fb0000000800540069006d0065010000000000000738000003bc00fffffffb0000000800540069006d00650100000000000004500000000000000000000003de0000035a00000004000000040000000800000008fc0000000100000002000000010000000a0054006f006f006c00730100000000ffffffff0000000000000000 + QMainWindow State: 000000ff00000000fd00000004000000000000015600000375fc0200000009fb0000001200530065006c0065006300740069006f006e00000001e10000009b0000005c00fffffffb0000001e0054006f006f006c002000500072006f007000650072007400690065007302000001ed000001df00000185000000a3fb000000120056006900650077007300200054006f006f02000001df000002110000018500000122fb000000200054006f006f006c002000500072006f0070006500720074006900650073003203000002880000011d000002210000017afb000000100044006900730070006c006100790073010000003d000002ba000000c900fffffffb0000002000730065006c0065006300740069006f006e00200062007500660066006500720200000138000000aa0000023a00000294fb00000014005700690064006500530074006500720065006f02000000e6000000d2000003ee0000030bfb0000000c004b0069006e0065006300740200000186000001060000030c00000261fb0000000c00540065006c0065006f007001000002fd000000b50000004700ffffff00000001000001f800000375fc0200000004fb0000000a0049006d006100670065010000003d000003750000001600fffffffb0000001e0054006f006f006c002000500072006f00700065007200740069006500730100000041000000780000000000000000fb0000000a00560069006500770073000000003d00000339000000a400fffffffb0000001200530065006c0065006300740069006f006e010000025a000000b200000000000000000000000200000490000000a9fc0100000001fb0000000a00560069006500770073030000004e00000080000002e10000019700000003000007800000003efc0100000002fb0000000800540069006d0065010000000000000780000003cc00fffffffb0000000800540069006d00650100000000000004500000000000000000000004260000037500000004000000040000000800000008fc0000000100000002000000010000000a0054006f006f006c00730100000000ffffffff0000000000000000 Selection: collapsed: false Teleop: @@ -243,6 +266,6 @@ Window Geometry: collapsed: false Views: collapsed: false - Width: 1848 - X: 1152 - Y: 27 + Width: 1920 + X: 1920 + Y: 0 diff --git a/mvsim_tutorial/demo_turtlebot_world.launch.py b/mvsim_tutorial/demo_turtlebot_world.launch.py index 4070166d..ae20b4e3 100644 --- a/mvsim_tutorial/demo_turtlebot_world.launch.py +++ b/mvsim_tutorial/demo_turtlebot_world.launch.py @@ -1,57 +1,70 @@ -# ROS2 launch file +# ROS2 launch file, invoking mvsim/launch/launch_world.launch.py +# See: https://mvsimulator.readthedocs.io/en/latest/mvsim_node.html -from launch import LaunchDescription +from launch.actions import IncludeLaunchDescription from launch.substitutions import TextSubstitution -from launch.substitutions import LaunchConfiguration from launch_ros.actions import Node +from launch.conditions import IfCondition from launch.actions import DeclareLaunchArgument from ament_index_python import get_package_share_directory import os +from launch import LaunchDescription +from launch.actions import DeclareLaunchArgument, IncludeLaunchDescription +from launch.substitutions import LaunchConfiguration +from launch.launch_description_sources import PythonLaunchDescriptionSource +from ament_index_python.packages import get_package_share_directory + -mvsimDir = get_package_share_directory("mvsim") +def generate_launch_description(): + # mvsim directory: + mvsimDir = get_package_share_directory("mvsim") -MVSIM_WORLD_FILE = os.path.join(mvsimDir, 'mvsim_tutorial', - 'demo_turtlebot_world.world.xml') -MVSIM_ROS2_PARAMS_FILE = os.path.join(mvsimDir, 'mvsim_tutorial', - 'mvsim_ros2_params.yaml') -RVIZ2_FILE = os.path.join(mvsimDir, 'mvsim_tutorial', - 'demo_turtlebot_world_ros2.rviz') + # World to launch: + world_file = os.path.join( + mvsimDir, 'mvsim_tutorial', 'demo_turtlebot_world.world.xml') + rviz_config_file = os.path.join( + get_package_share_directory('mvsim'), 'mvsim_tutorial', 'demo_turtlebot_world_ros2.rviz') + # Configurable arguments + headless = LaunchConfiguration('headless', default='True') + do_fake_localization = LaunchConfiguration( + 'do_fake_localization', default='False') + publish_tf_odom2baselink = LaunchConfiguration( + 'publish_tf_odom2baselink', default='False') + force_publish_vehicle_namespace = LaunchConfiguration( + 'force_publish_vehicle_namespace', default='True') + use_rviz = LaunchConfiguration('use_rviz', default='False') -def generate_launch_description(): - # args that can be set from the command line or a default will be used - world_file_launch_arg = DeclareLaunchArgument( - "world_file", default_value=TextSubstitution( - text=MVSIM_WORLD_FILE)) - - do_fake_localization_arg = DeclareLaunchArgument( - "do_fake_localization", default_value='True', description='publish tf odom -> base_link') - - mvsim_node = Node( - package='mvsim', - executable='mvsim_node', - name='mvsim', - output='screen', - parameters=[ - MVSIM_ROS2_PARAMS_FILE, - { - "world_file": LaunchConfiguration('world_file'), - "headless": False, - "do_fake_localization": LaunchConfiguration('do_fake_localization'), - }] - ) - - rviz2_node = Node( - package='rviz2', - executable='rviz2', - name='rviz2', - arguments=[ - '-d', [RVIZ2_FILE]] - ) - - return LaunchDescription([ - world_file_launch_arg, - do_fake_localization_arg, - mvsim_node, - rviz2_node - ]) + # Create LaunchDescription + ld = LaunchDescription() + + # Add arguments to LaunchDescription + ld.add_action(DeclareLaunchArgument('headless', default_value='False', + description='Run in headless mode')) + ld.add_action(DeclareLaunchArgument('do_fake_localization', default_value='True', + description='Publish fake identity tf "map" -> "odom"')) + ld.add_action(DeclareLaunchArgument('publish_tf_odom2baselink', default_value='True', + description='Publish tf "odom" -> "base_link"')) + ld.add_action(DeclareLaunchArgument('force_publish_vehicle_namespace', default_value='False', + description='Use vehicle name namespace even if there is only one vehicle')) + ld.add_action(DeclareLaunchArgument('use_rviz', default_value='True', + description='Whether to launch RViz2')) + + # Include the original launch file + ld.add_action(IncludeLaunchDescription( + PythonLaunchDescriptionSource( + os.path.join(get_package_share_directory('mvsim'), + 'launch', 'launch_world.launch.py') + ), + launch_arguments={ + 'world_file': world_file, + 'headless': headless, + 'do_fake_localization': do_fake_localization, + 'publish_tf_odom2baselink': publish_tf_odom2baselink, + 'force_publish_vehicle_namespace': force_publish_vehicle_namespace, + 'use_rviz': use_rviz, + 'rviz_config_file': rviz_config_file + }.items() + )) + + return ld