Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor diff_drive demo #635

Open
wants to merge 4 commits into
base: ros2
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions ros_gz_sim_demos/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ if(BUILD_TESTING)
ament_lint_auto_find_test_dependencies()
endif()

install(
DIRECTORY
config/
DESTINATION share/${PROJECT_NAME}/config
)

install(
DIRECTORY
launch/
Expand Down
4 changes: 2 additions & 2 deletions ros_gz_sim_demos/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ Trigger the camera:

Send commands to a differential drive vehicle and listen to its odometry.

ros2 launch ros_gz_sim_demos diff_drive.launch.py
ros2 launch ros_gz_sim_demos diff_drive.launch.xml

Then unpause and send a command
Then send a command

ros2 topic pub /model/vehicle_blue/cmd_vel geometry_msgs/msg/Twist "{linear: {x: 5.0}, angular: {z: 0.5}}"

Expand Down
36 changes: 36 additions & 0 deletions ros_gz_sim_demos/config/diff_drive.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Diff drive configuration.
- topic_name: "/model/vehicle_blue/cmd_vel"
ros_type_name: "geometry_msgs/msg/Twist"
gz_type_name: "gz.msgs.Twist"
lazy: true
direction: ROS_TO_GZ

- topic_name: "/model/vehicle_blue/odometry"
ros_type_name: "nav_msgs/msg/Odometry"
gz_type_name: "gz.msgs.Odometry"
lazy: true
direction: GZ_TO_ROS

- topic_name: "/model/vehicle_green/cmd_vel"
ros_type_name: "geometry_msgs/msg/Twist"
gz_type_name: "gz.msgs.Twist"
lazy: true
direction: ROS_TO_GZ

- topic_name: "/model/vehicle_green/odometry"
ros_type_name: "nav_msgs/msg/Odometry"
gz_type_name: "gz.msgs.Odometry"
lazy: true
direction: GZ_TO_ROS

- ros_topic_name: "/tf"
gz_topic_name: "/model/vehicle_green/tf"
ros_type_name: "tf2_msgs/msg/TFMessage"
gz_type_name: "gz.msgs.Pose_V"
direction: GZ_TO_ROS

- ros_topic_name: "/tf"
gz_topic_name: "/model/vehicle_blue/tf"
ros_type_name: "tf2_msgs/msg/TFMessage"
gz_type_name: "gz.msgs.Pose_V"
direction: GZ_TO_ROS
69 changes: 0 additions & 69 deletions ros_gz_sim_demos/launch/diff_drive.launch.py

This file was deleted.

16 changes: 16 additions & 0 deletions ros_gz_sim_demos/launch/diff_drive.launch.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<launch>
<gz_server
world_sdf_file="diff_drive.sdf"
use_composition="True"
create_own_container="True" />
<ros_gz_bridge
bridge_name="ros_gz_bridge"
config_file="$(find-pkg-share ros_gz_sim_demos)/config/diff_drive.yaml"
use_composition="True"
bridge_params="'qos_overrides./model/vehicle_blue.subscriber.reliability': 'reliable',
'qos_overrides./model/vehicle_green.subscriber.reliability': 'reliable'" />
<node pkg="rviz2" exec="rviz2" args="-d $(find-pkg-share ros_gz_sim_demos)/rviz/diff_drive.rviz" />
<node pkg="tf2_ros" exec="static_transform_publisher" args="--frame-id world --child-frame-id vehicle_green/odom" />
<node pkg="tf2_ros" exec="static_transform_publisher" args="--frame-id world --child-frame-id vehicle_blue/odom" />
<executable cmd="gz sim -g" />
</launch>
1 change: 1 addition & 0 deletions ros_gz_sim_demos/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
<exec_depend>rqt_topic</exec_depend>
<exec_depend>rviz2</exec_depend>
<exec_depend>sdformat_urdf</exec_depend>
<exec_depend>tf2_ros</exec_depend>
<exec_depend>xacro</exec_depend>

<test_depend>ament_lint_auto</test_depend>
Expand Down
41 changes: 31 additions & 10 deletions ros_gz_sim_demos/rviz/diff_drive.rviz
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,12 @@ Panels:
Expanded:
- /Global Options1
- /Odometry1
- /Odometry1/Status1
Splitter Ratio: 0.5
Tree Height: 701
Tree Height: 688
- Class: rviz_common/Selection
Name: Selection
- Class: rviz_common/Tool Properties
Expanded:
- /2D Nav Goal1
- /Publish Point1
Name: Tool Properties
Splitter Ratio: 0.5886790156364441
Expand Down Expand Up @@ -56,13 +54,18 @@ Visualization Manager:
Shaft Length: 1
Shaft Radius: 0.05000000074505806
Value: Arrow
Topic: /model/vehicle_blue/odometry
Unreliable: false
Topic:
Depth: 5
Durability Policy: Volatile
Filter size: 10
History Policy: Keep Last
Reliability Policy: Reliable
Value: /model/vehicle_blue/odometry
Value: true
Enabled: true
Global Options:
Background Color: 48; 48; 48
Fixed Frame: vehicle_blue/odom
Fixed Frame: world
Frame Rate: 30
Name: root
Tools:
Expand All @@ -72,12 +75,30 @@ Visualization Manager:
- Class: rviz_default_plugins/Measure
Line color: 128; 128; 0
- Class: rviz_default_plugins/SetInitialPose
Topic: /initialpose
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: /move_base_simple/goal
Topic:
Depth: 5
Durability Policy: Volatile
History Policy: Keep Last
Reliability Policy: Reliable
Value: /move_base_simple/goal
- Class: rviz_default_plugins/PublishPoint
Single click: true
Topic: /clicked_point
Topic:
Depth: 5
Durability Policy: Volatile
History Policy: Keep Last
Reliability Policy: Reliable
Value: /clicked_point
Transformation:
Current:
Class: rviz_default_plugins/TF
Expand Down Expand Up @@ -111,7 +132,7 @@ Window Geometry:
Height: 846
Hide Left Dock: false
Hide Right Dock: false
QMainWindow State: 000000ff00000000fd00000004000000000000023d000002f8fc0200000008fb0000001200530065006c0065006300740069006f006e00000001e10000009b0000005c00fffffffb0000001e0054006f006f006c002000500072006f007000650072007400690065007302000001ed000001df00000185000000a3fb000000120056006900650077007300200054006f006f02000001df000002110000018500000122fb000000200054006f006f006c002000500072006f0070006500720074006900650073003203000002880000011d000002210000017afb000000100044006900730070006c006100790073010000003b000002f8000000c700fffffffb0000002000730065006c0065006300740069006f006e00200062007500660066006500720200000138000000aa0000023a00000294fb00000014005700690064006500530074006500720065006f02000000e6000000d2000003ee0000030bfb0000000c004b0069006e0065006300740200000186000001060000030c00000261000000010000010f000002f8fc0200000003fb0000001e0054006f006f006c002000500072006f00700065007200740069006500730100000041000000780000000000000000fb0000000a00560069006500770073000000003b000002f8000000a000fffffffb0000001200530065006c0065006300740069006f006e010000025a000000b200000000000000000000000200000490000000a9fc0100000001fb0000000a00560069006500770073030000004e00000080000002e10000019700000003000004420000003efc0100000002fb0000000800540069006d00650100000000000004420000000000000000fb0000000800540069006d006501000000000000045000000000000000000000026d000002f800000004000000040000000800000008fc0000000100000002000000010000000a0054006f006f006c00730100000000ffffffff0000000000000000
QMainWindow State: 000000ff00000000fd00000004000000000000023d000002f0fc0200000008fb0000001200530065006c0065006300740069006f006e00000001e10000009b0000005d00fffffffb0000001e0054006f006f006c002000500072006f007000650072007400690065007302000001ed000001df00000185000000a3fb000000120056006900650077007300200054006f006f02000001df000002110000018500000122fb000000200054006f006f006c002000500072006f0070006500720074006900650073003203000002880000011d000002210000017afb000000100044006900730070006c006100790073010000003f000002f0000000cc00fffffffb0000002000730065006c0065006300740069006f006e00200062007500660066006500720200000138000000aa0000023a00000294fb00000014005700690064006500530074006500720065006f02000000e6000000d2000003ee0000030bfb0000000c004b0069006e0065006300740200000186000001060000030c00000261000000010000010f000002f8fc0200000003fb0000001e0054006f006f006c002000500072006f00700065007200740069006500730100000041000000780000000000000000fb0000000a00560069006500770073000000003b000002f8000000a900fffffffb0000001200530065006c0065006300740069006f006e010000025a000000b200000000000000000000000200000490000000a9fc0100000001fb0000000a00560069006500770073030000004e00000080000002e10000019700000003000004420000003efc0100000002fb0000000800540069006d00650100000000000004420000000000000000fb0000000800540069006d006501000000000000045000000000000000000000026d000002f000000004000000040000000800000008fc0000000100000002000000010000000a0054006f006f006c00730100000000ffffffff0000000000000000
Selection:
collapsed: false
Tool Properties:
Expand Down