diff --git a/ros_ign_gazebo_demos/CMakeLists.txt b/ros_ign_gazebo_demos/CMakeLists.txt index aa395e18..c4265636 100644 --- a/ros_ign_gazebo_demos/CMakeLists.txt +++ b/ros_ign_gazebo_demos/CMakeLists.txt @@ -16,4 +16,10 @@ install( DESTINATION share/${PROJECT_NAME}/rviz ) +install( + DIRECTORY + models/ + DESTINATION share/${PROJECT_NAME}/models +) + ament_package() diff --git a/ros_ign_gazebo_demos/README.md b/ros_ign_gazebo_demos/README.md index 64cc786c..adbd618d 100644 --- a/ros_ign_gazebo_demos/README.md +++ b/ros_ign_gazebo_demos/README.md @@ -148,4 +148,14 @@ To try the demo launch: ros2 launch ros_ign_gazebo_demos robot_description_publisher.launch.py -![](images/robot_state_publisher_demo.png) \ No newline at end of file +![](images/robot_state_publisher_demo.png) + +## Joint States Publisher + +Publishes joint states of the robot. + +To try the demo launch: + + ros2 launch ros_ign_gazebo_demos joint_states.launch.py + +![](images/joint_states.png) diff --git a/ros_ign_gazebo_demos/images/joint_states.png b/ros_ign_gazebo_demos/images/joint_states.png new file mode 100644 index 00000000..943eaf66 Binary files /dev/null and b/ros_ign_gazebo_demos/images/joint_states.png differ diff --git a/ros_ign_gazebo_demos/launch/joint_states.launch.py b/ros_ign_gazebo_demos/launch/joint_states.launch.py new file mode 100644 index 00000000..c6296bd7 --- /dev/null +++ b/ros_ign_gazebo_demos/launch/joint_states.launch.py @@ -0,0 +1,79 @@ +import os +import xacro +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(): + + # Package Directories + pkg_ros_ign_gazebo = get_package_share_directory('ros_ign_gazebo') + pkg_ros_ign_gazebo_demos = get_package_share_directory('ros_ign_gazebo_demos') + + # Parse robot description from xacro + robot_description_file = os.path.join(pkg_ros_ign_gazebo_demos, 'models', 'rrbot.xacro') + robot_description_config = xacro.process_file( + robot_description_file + ) + robot_description = {"robot_description": robot_description_config.toxml()} + + # Robot state publisher + robot_state_publisher = Node( + package='robot_state_publisher', + executable='robot_state_publisher', + name='robot_state_publisher', + output='both', + parameters=[robot_description], + ) + + # Ignition gazebo + gazebo = IncludeLaunchDescription( + PythonLaunchDescriptionSource( + os.path.join(pkg_ros_ign_gazebo, 'launch', 'ign_gazebo.launch.py')), + launch_arguments={'ign_args': '-r empty.sdf'}.items(), + ) + + # RViz + rviz = Node( + package='rviz2', + executable='rviz2', + arguments=['-d', os.path.join(pkg_ros_ign_gazebo_demos, 'rviz', 'joint_states.rviz')], + ) + + # Spawn + spawn = Node(package='ros_ign_gazebo', executable='create', + arguments=[ + '-name', 'rrbot', + '-topic', 'robot_description', + ], + output='screen', + ) + + # Ign - ROS Bridge + bridge = Node( + package='ros_ign_bridge', + executable='parameter_bridge', + arguments=[ + # Clock (IGN -> ROS2) + '/clock@rosgraph_msgs/msg/Clock[ignition.msgs.Clock', + # Joint states (IGN -> ROS2) + '/world/empty/model/rrbot/joint_state@sensor_msgs/msg/JointState[ignition.msgs.Model', + ], + remappings=[ + ('/world/empty/model/rrbot/joint_state', 'joint_states'), + ], + output='screen' + ) + + return LaunchDescription( + [ + # Nodes and Launches + gazebo, + spawn, + bridge, + robot_state_publisher, + rviz, + ] + ) diff --git a/ros_ign_gazebo_demos/models/rrbot.xacro b/ros_ign_gazebo_demos/models/rrbot.xacro new file mode 100644 index 00000000..782154e3 --- /dev/null +++ b/ros_ign_gazebo_demos/models/rrbot.xacro @@ -0,0 +1,165 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1 0.423529412 0.039215686 1 + 1 0.423529412 0.039215686 1 + 1 0.423529412 0.039215686 1 + + + + + + 0.2 + 0.2 + + 0 0 0 1 + 0 0 0 1 + 0 0 0 1 + + + + + + 0.2 + 0.2 + + 1 0.423529412 0.039215686 1 + 1 0.423529412 0.039215686 1 + 1 0.423529412 0.039215686 1 + + + + + + + + + \ No newline at end of file diff --git a/ros_ign_gazebo_demos/package.xml b/ros_ign_gazebo_demos/package.xml index d46e9078..0529f707 100644 --- a/ros_ign_gazebo_demos/package.xml +++ b/ros_ign_gazebo_demos/package.xml @@ -26,6 +26,7 @@ rqt_plot rqt_topic rviz2 + xacro ament_cmake diff --git a/ros_ign_gazebo_demos/rviz/joint_states.rviz b/ros_ign_gazebo_demos/rviz/joint_states.rviz new file mode 100644 index 00000000..06920d70 --- /dev/null +++ b/ros_ign_gazebo_demos/rviz/joint_states.rviz @@ -0,0 +1,190 @@ +Panels: + - Class: rviz_common/Displays + Help Height: 78 + Name: Displays + Property Tree Widget: + Expanded: + - /Global Options1 + - /Status1 + - /RobotModel1 + - /TF1 + Splitter Ratio: 0.5 + Tree Height: 802 + - 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 + - Alpha: 0.800000011920929 + 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 + link1: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + link2: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + link3: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + Name: RobotModel + TF Prefix: "" + Update Interval: 0 + Value: true + Visual Enabled: true + - Class: rviz_default_plugins/TF + Enabled: true + Frame Timeout: 15 + Frames: + All Enabled: true + link1: + Value: true + link2: + Value: true + link3: + Value: true + world: + Value: true + Marker Scale: 1 + Name: TF + Show Arrows: true + Show Axes: true + Show Names: true + Tree: + link1: + link2: + link3: + {} + world: + {} + 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.524543762207031 + Enable Stereo Rendering: + Stereo Eye Separation: 0.05999999865889549 + Stereo Focal Distance: 1 + Swap Stereo Eyes: false + Value: false + Focal Point: + X: -0.106326624751091 + Y: 0.5023337006568909 + Z: 1.1979976892471313 + Focal Shape Fixed Size: true + Focal Shape Size: 0.05000000074505806 + Invert Z Axis: false + Name: Current View + Near Clip Distance: 0.009999999776482582 + Pitch: 0.7303980588912964 + Target Frame: + Value: Orbit (rviz) + Yaw: 5.698581218719482 + Saved: ~ +Window Geometry: + Displays: + collapsed: false + Height: 1025 + Hide Left Dock: false + Hide Right Dock: false + QMainWindow State: 000000ff00000000fd000000040000000000000156000003abfc0200000008fb0000001200530065006c0065006300740069006f006e00000001e10000009b0000005c00fffffffb0000001e0054006f006f006c002000500072006f007000650072007400690065007302000001ed000001df00000185000000a3fb000000120056006900650077007300200054006f006f02000001df000002110000018500000122fb000000200054006f006f006c002000500072006f0070006500720074006900650073003203000002880000011d000002210000017afb000000100044006900730070006c006100790073010000003b000003ab000000c700fffffffb0000002000730065006c0065006300740069006f006e00200062007500660066006500720200000138000000aa0000023a00000294fb00000014005700690064006500530074006500720065006f02000000e6000000d2000003ee0000030bfb0000000c004b0069006e0065006300740200000186000001060000030c00000261000000010000010f000003abfc0200000003fb0000001e0054006f006f006c002000500072006f00700065007200740069006500730100000041000000780000000000000000fb0000000a00560069006500770073010000003b000003ab000000a000fffffffb0000001200530065006c0065006300740069006f006e010000025a000000b200000000000000000000000200000490000000a9fc0100000001fb0000000a00560069006500770073030000004e00000080000002e10000019700000003000004420000003efc0100000002fb0000000800540069006d00650100000000000004420000000000000000fb0000000800540069006d00650100000000000004500000000000000000000004cc000003ab00000004000000040000000800000008fc0000000100000002000000010000000a0054006f006f006c00730100000000ffffffff0000000000000000 + Selection: + collapsed: false + Tool Properties: + collapsed: false + Views: + collapsed: false + Width: 1853 + X: 67 + Y: 27 diff --git a/ros_ign_image/src/image_bridge.cpp b/ros_ign_image/src/image_bridge.cpp index 8e2c82f8..35b11c78 100644 --- a/ros_ign_image/src/image_bridge.cpp +++ b/ros_ign_image/src/image_bridge.cpp @@ -15,7 +15,7 @@ #include #include -#include +#include #include #include diff --git a/ros_ign_interfaces/CHANGELOG.rst b/ros_ign_interfaces/CHANGELOG.rst new file mode 100644 index 00000000..ffde9ad5 --- /dev/null +++ b/ros_ign_interfaces/CHANGELOG.rst @@ -0,0 +1,4 @@ +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +Changelog for package ros_ign_interfaces +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + diff --git a/ros_ign_interfaces/CMakeLists.txt b/ros_ign_interfaces/CMakeLists.txt new file mode 100644 index 00000000..b7e1255e --- /dev/null +++ b/ros_ign_interfaces/CMakeLists.txt @@ -0,0 +1,42 @@ +cmake_minimum_required(VERSION 3.5) +project(ros_ign_interfaces) + +if(NOT CMAKE_CXX_STANDARD) + set(CMAKE_CXX_STANDARD 14) +endif() + +if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") + add_compile_options(-Wall -Wextra -Wpedantic) +endif() + +find_package(ament_cmake REQUIRED) +find_package(builtin_interfaces REQUIRED) +find_package(std_msgs REQUIRED) +find_package(geometry_msgs REQUIRED) +find_package(rosidl_default_generators REQUIRED) + +set(msg_files + "msg/Contact.msg" + "msg/Contacts.msg" + "msg/Entity.msg" + "msg/EntityFactory.msg" + "msg/WorldControl.msg" + "msg/WorldReset.msg" +) + +set(srv_files + "srv/ControlWorld.srv" + "srv/DeleteEntity.srv" + "srv/SetEntityPose.srv" + "srv/SpawnEntity.srv" +) + +rosidl_generate_interfaces(${PROJECT_NAME} + ${msg_files} + ${srv_files} + DEPENDENCIES builtin_interfaces std_msgs geometry_msgs + ADD_LINTER_TESTS +) + +ament_export_dependencies(rosidl_default_runtime) +ament_package() diff --git a/ros_ign_interfaces/README.md b/ros_ign_interfaces/README.md new file mode 100644 index 00000000..82731d3c --- /dev/null +++ b/ros_ign_interfaces/README.md @@ -0,0 +1,20 @@ +# Message and service data structures for interacting with Ignition from ROS2 + +This package currently contains some Ignition-specific ROS message and service data structures (.msg and .srv) + +## Messages (.msg) + +* [Contact](msg/Contact.msg): related to [ignition::msgs::Contact](https://github.com/ignitionrobotics/ign-msgs/blob/ign-msgs7/proto/ignition/msgs/contact.proto). Contant info bewteen collisions in Ignition Gazebo. +* [Contacts](msg/Contacts.msg): related to [ignition::msgs::Contacts](https://github.com/ignitionrobotics/ign-msgs/blob/ign-msgs7/proto/ignition/msgs/contacts.proto).a list of contact. +* [Entity](msg/Entity.msg): related to [ignition::msgs::Entity](https://github.com/ignitionrobotics/ign-msgs/blob/ign-msgs7/proto/ignition/msgs/entity.proto). Entity of Ignition Gazebo. +* [EntityFactory](msg/EntityFactory.msg): related to [ignition::msgs::EntityFactory](https://github.com/ignitionrobotics/ign-msgs/blob/ign-msgs7/proto/ignition/msgs/entity_factory.proto). Message to create a new entity. +* [WorldControl](msg/WorldControl.msg): related to [ignition::msgs::WorldControl](https://github.com/ignitionrobotics/ign-msgs/blob/ign-msgs7/proto/ignition/msgs/world_control.proto). Message to control world of Ingition Gazebo. +* [WorldReset](msg/WorldReset.msg): related to [ignition::msgs::WorldReset](https://github.com/ignitionrobotics/ign-msgs/blob/ign-msgs7/proto/ignition/msgs/world_reset.proto). Reset time and model of simulation. + +## Services (.srv) + +* [ControlWorld](srv/ControlWorld.srv): Control world of Ignition Gazebo,for example,pasue,pasue with multiple steps,resume,etc. +* [DeleteEntity](srv/DeleteEntity.srv): Delete Entity in Ignition Gazebo +* [SetEntityPose](srv/SetEntityPose.srv): Set pose of Entity in Ignition Gazebo +* [SpawnEntity](srv/SpawnEntity.srv): Spawn a Entity in Ignition Gazebo + diff --git a/ros_ign_interfaces/msg/Contact.msg b/ros_ign_interfaces/msg/Contact.msg new file mode 100644 index 00000000..0e4812e2 --- /dev/null +++ b/ros_ign_interfaces/msg/Contact.msg @@ -0,0 +1,6 @@ +ros_ign_interfaces/Entity collision1 # Contact collision1 +ros_ign_interfaces/Entity collision2 # Contact collision2 +geometry_msgs/Vector3[] positions # List of contact position +geometry_msgs/Vector3[] normals # List of contact normals +float64[] depths # List of penetration depths +geometry_msgs/Wrench[] wrenches # List of forces/torques diff --git a/ros_ign_interfaces/msg/Contacts.msg b/ros_ign_interfaces/msg/Contacts.msg new file mode 100644 index 00000000..e709e178 --- /dev/null +++ b/ros_ign_interfaces/msg/Contacts.msg @@ -0,0 +1,2 @@ +std_msgs/Header header # Time stamp +ros_ign_interfaces/Contact[] contacts # List of contacts diff --git a/ros_ign_interfaces/msg/Entity.msg b/ros_ign_interfaces/msg/Entity.msg new file mode 100644 index 00000000..b785c7ed --- /dev/null +++ b/ros_ign_interfaces/msg/Entity.msg @@ -0,0 +1,13 @@ +# Entity type: constant definition +uint8 NONE = 0 +uint8 LIGHT = 1 +uint8 MODEL = 2 +uint8 LINK = 3 +uint8 VISUAL = 4 +uint8 COLLISION = 5 +uint8 SENSOR = 6 +uint8 JOINT = 7 + +uint64 id # Entity unique identifier accross all types. Defaults to 0 +string name # Entity name, which is not guaranteed to be unique. +uint8 type # Entity type. diff --git a/ros_ign_interfaces/msg/EntityFactory.msg b/ros_ign_interfaces/msg/EntityFactory.msg new file mode 100644 index 00000000..4576c003 --- /dev/null +++ b/ros_ign_interfaces/msg/EntityFactory.msg @@ -0,0 +1,11 @@ +string name # New name for the entity, overrides the name on the SDF +bool allow_renaming false # Whether the server is allowed to rename the entity in case of + # overlap with existing entities. + +# Only one method is supported at a time (sdf,sdf_filename,clone_name) +string sdf # SDF description in string format +string sdf_filename # Full path to SDF file. +string clone_name # Name of entity to clone + +geometry_msgs/Pose pose # Pose where the entity will be spawned in the world. +string relative_to "world" # Pose is defined relative to the frame of this entity. diff --git a/ros_ign_interfaces/msg/WorldControl.msg b/ros_ign_interfaces/msg/WorldControl.msg new file mode 100644 index 00000000..f08cb6f5 --- /dev/null +++ b/ros_ign_interfaces/msg/WorldControl.msg @@ -0,0 +1,7 @@ +bool pause # Paused state. +bool step # +uint32 multi_step 0 # Paused after stepping multi_step. +ros_ign_interfaces/WorldReset reset # +uint32 seed # +builtin_interfaces/Time run_to_sim_time # A simulation time in the future to run to and + # then pause. diff --git a/ros_ign_interfaces/msg/WorldReset.msg b/ros_ign_interfaces/msg/WorldReset.msg new file mode 100644 index 00000000..46f5971f --- /dev/null +++ b/ros_ign_interfaces/msg/WorldReset.msg @@ -0,0 +1,3 @@ +bool all false # Reset time and model +bool time_only false # Reset time only +bool model_only false # Reset model only diff --git a/ros_ign_interfaces/package.xml b/ros_ign_interfaces/package.xml new file mode 100644 index 00000000..ba858aa9 --- /dev/null +++ b/ros_ign_interfaces/package.xml @@ -0,0 +1,26 @@ + + ros_ign_interfaces + 0.233.1 + Message and service data structures for interacting with Ignition from ROS2. + Apache 2.0 + Louise Poubel + Zhenpeng Ge + Zhenpeng Ge + ament_cmake + rosidl_default_generators + + builtin_interfaces + std_msgs + geometry_msgs + + builtin_interfaces + std_msgs + geometry_msgs + rosidl_default_runtime + + ament_lint_common + rosidl_interface_packages + + ament_cmake + + diff --git a/ros_ign_interfaces/srv/ControlWorld.srv b/ros_ign_interfaces/srv/ControlWorld.srv new file mode 100644 index 00000000..92f7a712 --- /dev/null +++ b/ros_ign_interfaces/srv/ControlWorld.srv @@ -0,0 +1,3 @@ +ros_ign_interfaces/WorldControl world_control # Message to Control world in Ignition Gazebo +--- +bool success # Return true if control is successful. diff --git a/ros_ign_interfaces/srv/DeleteEntity.srv b/ros_ign_interfaces/srv/DeleteEntity.srv new file mode 100644 index 00000000..d922e7f9 --- /dev/null +++ b/ros_ign_interfaces/srv/DeleteEntity.srv @@ -0,0 +1,3 @@ +ros_ign_interfaces/Entity entity # Ignition Gazebo entity to be deleted. +--- +bool success # Return true if deletion is successful. diff --git a/ros_ign_interfaces/srv/SetEntityPose.srv b/ros_ign_interfaces/srv/SetEntityPose.srv new file mode 100644 index 00000000..f1fbec7e --- /dev/null +++ b/ros_ign_interfaces/srv/SetEntityPose.srv @@ -0,0 +1,4 @@ +ros_ign_interfaces/Entity entity # Ignition Gazebo entity. +geometry_msgs/Pose pose # Pose of entity. +--- +bool success # Return true if set successfully. diff --git a/ros_ign_interfaces/srv/SpawnEntity.srv b/ros_ign_interfaces/srv/SpawnEntity.srv new file mode 100644 index 00000000..cb85e438 --- /dev/null +++ b/ros_ign_interfaces/srv/SpawnEntity.srv @@ -0,0 +1,3 @@ +ros_ign_interfaces/EntityFactory entity_factory # Message to create a new entity +--- +bool success # Return true if spawned successfully.