diff --git a/rcdt_utilities/CMakeLists.txt b/rcdt_utilities/CMakeLists.txt index 02fb9ea..92ebc08 100644 --- a/rcdt_utilities/CMakeLists.txt +++ b/rcdt_utilities/CMakeLists.txt @@ -19,7 +19,7 @@ find_package(tf2_eigen REQUIRED) # Install project files install( DIRECTORY - launch rviz + launch rviz urdf sdf DESTINATION share/${PROJECT_NAME} ) diff --git a/rcdt_utilities/launch/gazebo_robot.launch.py b/rcdt_utilities/launch/gazebo_robot.launch.py index 6b5c45a..8c48692 100644 --- a/rcdt_utilities/launch/gazebo_robot.launch.py +++ b/rcdt_utilities/launch/gazebo_robot.launch.py @@ -2,36 +2,71 @@ # # SPDX-License-Identifier: Apache-2.0 -from launch.actions import IncludeLaunchDescription -from launch import LaunchDescription +from typing import List + +from launch import LaunchContext, LaunchDescription +from launch.actions import IncludeLaunchDescription, OpaqueFunction from launch_ros.actions import Node -from rcdt_utilities.launch_utils import get_file_path +from rcdt_utilities.launch_utils import LaunchArgument, get_file_path + +load_gazebo_ui_arg = LaunchArgument("load_gazebo_ui", False, [True, False]) +world_arg = LaunchArgument("world", "") +use_realsense_arg = LaunchArgument("realsense", False, [True, False]) + + +def launch_setup(context: LaunchContext) -> List: + load_gazebo_ui = load_gazebo_ui_arg.value(context) + world = world_arg.value(context) + use_realsense = use_realsense_arg.value(context) + + if world == "": + world = get_file_path("rcdt_utilities", ["sdf"], "empty.xml.sdf") -gazebo = IncludeLaunchDescription( - get_file_path("ros_gz_sim", ["launch"], "gz_sim.launch.py"), - launch_arguments={"gz_args": "empty.sdf -r"}.items(), -) + gz_args = f" -r {world}" + if not load_gazebo_ui: + gz_args += " -s" + gazebo = IncludeLaunchDescription( + get_file_path("ros_gz_sim", ["launch"], "gz_sim.launch.py"), + launch_arguments={"gz_args": gz_args}.items(), + ) + + spawn_robot = Node( + package="ros_gz_sim", + executable="create", + arguments=["-topic", "/robot_description"], + output="screen", + ) -spawn_robot = Node( - package="ros_gz_sim", - executable="create", - arguments=["-topic", "/robot_description"], - output="screen", -) + bridge_topics = ["/clock@rosgraph_msgs/msg/Clock[ignition.msgs.Clock"] + if use_realsense: + bridge_topics.extend( + [ + "/camera/color/camera_info@sensor_msgs/msg/CameraInfo@gz.msgs.CameraInfo", + "/camera/color/image_raw@sensor_msgs/msg/Image@gz.msgs.Image", + "/camera/depth/camera_info@sensor_msgs/msg/CameraInfo@gz.msgs.CameraInfo", + "/camera/depth/image_rect_raw@sensor_msgs/msg/Image@gz.msgs.Image", + ] + ) + + bridge = Node( + package="ros_gz_bridge", + executable="parameter_bridge", + arguments=bridge_topics, + ) -sync_clock = Node( - package="ros_gz_bridge", - executable="parameter_bridge", - name="sync_clock", - arguments=["/clock@rosgraph_msgs/msg/Clock[gz.msgs.Clock"], -) + return [ + gazebo, + spawn_robot, + bridge, + ] def generate_launch_description() -> LaunchDescription: return LaunchDescription( [ - gazebo, - spawn_robot, - sync_clock, + load_gazebo_ui_arg.declaration, + world_arg.declaration, + use_realsense_arg.declaration, + OpaqueFunction(function=launch_setup), ] ) diff --git a/rcdt_utilities/rviz/realsense.rviz b/rcdt_utilities/rviz/realsense.rviz new file mode 100644 index 0000000..3ee20b0 --- /dev/null +++ b/rcdt_utilities/rviz/realsense.rviz @@ -0,0 +1,307 @@ +# SPDX-FileCopyrightText: Alliander N. V. +# +# SPDX-License-Identifier: Apache-2.0 + +Panels: + - Class: rviz_common/Displays + Help Height: 78 + Name: Displays + Property Tree Widget: + Expanded: + - /Global Options1 + - /Status1 + Splitter Ratio: 0.5 + Tree Height: 352 + - 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 + - Class: rviz_common/Time + Experimental: false + Name: Time + SyncMode: 0 + SyncSource: "" +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 + - 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 + camera_bottom_screw_frame: + Alpha: 1 + Show Axes: false + Show Trail: false + camera_color_frame: + Alpha: 1 + Show Axes: false + Show Trail: false + camera_color_optical_frame: + Alpha: 1 + Show Axes: false + Show Trail: false + camera_depth_frame: + Alpha: 1 + Show Axes: false + Show Trail: false + camera_depth_optical_frame: + Alpha: 1 + Show Axes: false + Show Trail: false + camera_infra1_frame: + Alpha: 1 + Show Axes: false + Show Trail: false + camera_infra1_optical_frame: + Alpha: 1 + Show Axes: false + Show Trail: false + camera_infra2_frame: + Alpha: 1 + Show Axes: false + Show Trail: false + camera_infra2_optical_frame: + Alpha: 1 + Show Axes: false + Show Trail: false + camera_link: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + fr3_hand: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + fr3_hand_tcp: + Alpha: 1 + Show Axes: false + Show Trail: false + fr3_leftfinger: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + fr3_link0: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + fr3_link1: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + fr3_link2: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + fr3_link3: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + fr3_link4: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + fr3_link5: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + fr3_link6: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + fr3_link7: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + fr3_link8: + Alpha: 1 + Show Axes: false + Show Trail: false + fr3_rightfinger: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + realsense_link: + Alpha: 1 + Show Axes: false + Show Trail: false + world: + Alpha: 1 + Show Axes: false + Show Trail: false + Mass Properties: + Inertia: false + Mass: false + Name: RobotModel + TF Prefix: "" + Update Interval: 0 + Value: true + Visual Enabled: true + - Class: rviz_default_plugins/Image + Enabled: true + Max Value: 1 + Median window: 5 + Min Value: 0 + Name: Color + Normalize Range: true + Topic: + Depth: 5 + Durability Policy: Volatile + History Policy: Keep Last + Reliability Policy: Reliable + Value: /camera/color/image_raw + Value: true + - Class: rviz_default_plugins/Image + Enabled: true + Max Value: 1 + Median window: 5 + Min Value: 0 + Name: Depth + Normalize Range: true + Topic: + Depth: 5 + Durability Policy: Volatile + History Policy: Keep Last + Reliability Policy: Reliable + Value: /camera/depth/image_rect_raw + 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 + Covariance x: 0.25 + Covariance y: 0.25 + Covariance yaw: 0.06853891909122467 + 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: 3.2032787799835205 + Enable Stereo Rendering: + Stereo Eye Separation: 0.05999999865889549 + Stereo Focal Distance: 1 + Swap Stereo Eyes: false + Value: false + Focal Point: + X: 0.030398249626159668 + Y: -0.048146918416023254 + Z: 0.40179479122161865 + Focal Shape Fixed Size: true + Focal Shape Size: 0.05000000074505806 + Invert Z Axis: false + Name: Current View + Near Clip Distance: 0.009999999776482582 + Pitch: 0.2703982889652252 + Target Frame: + Value: Orbit (rviz) + Yaw: 0.690392792224884 + Saved: ~ +Window Geometry: + Color: + collapsed: false + Depth: + collapsed: false + Displays: + collapsed: false + Height: 1043 + Hide Left Dock: false + Hide Right Dock: false + QMainWindow State: 000000ff00000000fd00000004000000000000015600000379fc020000000afb0000001200530065006c0065006300740069006f006e00000001e10000009b0000005c00fffffffb0000001e0054006f006f006c002000500072006f0070006500720074006900650073020000072c000001df00000185000000a3fb000000120056006900650077007300200054006f006f02000001df000002110000018500000122fb000000200054006f006f006c002000500072006f0070006500720074006900650073003203000002880000011d000002210000017afb000000100044006900730070006c006100790073010000003b000001e9000000c700fffffffb0000002000730065006c0065006300740069006f006e00200062007500660066006500720200000138000000aa0000023a00000294fb00000014005700690064006500530074006500720065006f02000000e6000000d2000003ee0000030bfb0000000c004b0069006e0065006300740200000186000001060000030c00000261fb0000000a00440065007000740068010000022a000000d90000002800fffffffb0000000a0043006f006c006f00720100000309000000ab0000002800ffffff000000010000010f00000379fc0200000003fb0000001e0054006f006f006c002000500072006f00700065007200740069006500730100000041000000780000000000000000fb0000000a00560069006500770073010000003b00000379000000a000fffffffb0000001200530065006c0065006300740069006f006e010000025a000000b200000000000000000000000200000490000000a9fc0100000001fb0000000a00560069006500770073030000004e00000080000002e10000019700000003000007800000003efc0100000002fb0000000800540069006d00650100000000000007800000025300fffffffb0000000800540069006d006501000000000000045000000000000000000000050f0000037900000004000000040000000800000008fc0000000100000002000000010000000a0054006f006f006c00730100000000ffffffff0000000000000000 + Selection: + collapsed: false + Time: + collapsed: false + Tool Properties: + collapsed: false + Views: + collapsed: false + Width: 1920 + X: 305 + Y: 0 diff --git a/rcdt_utilities/sdf/empty.xml.sdf b/rcdt_utilities/sdf/empty.xml.sdf new file mode 100644 index 0000000..c148ffc --- /dev/null +++ b/rcdt_utilities/sdf/empty.xml.sdf @@ -0,0 +1,76 @@ + + + + + + 0.001 + 1.0 + + + + + + + + + + + + + + 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 + + + + + + + \ No newline at end of file diff --git a/rcdt_utilities/urdf/rcdt_realsense_d435.urdf.xacro b/rcdt_utilities/urdf/rcdt_realsense_d435.urdf.xacro new file mode 100644 index 0000000..8e7fd79 --- /dev/null +++ b/rcdt_utilities/urdf/rcdt_realsense_d435.urdf.xacro @@ -0,0 +1,84 @@ + + + + + + + + + + + + + + + + + + + + + + + true + 30.0 + + ${namespace}/color/image_raw + false + + ${namespace}_color_optical_frame + ${69.0/180.0*pi} + + 1280 + 720 + R8G8B8 + + + 0.02 + 300.0 + + + + + + true + 30.0 + + ${namespace}/depth/image_rect_raw + false + + ${namespace}_depth_frame + + ${87.0/180.0*pi} + + 1280 + 720 + R_FLOAT32 + + + 0.28 + 8.0 + + + gaussian + 0.0 + 0.005 + + + + + + + + \ No newline at end of file