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

Merged
merged 13 commits into from
Dec 18, 2024
Merged
4 changes: 2 additions & 2 deletions ros_gz_sim_demos/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,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.

17 changes: 17 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,17 @@
<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">
<param name="qos_overrides./model/vehicle_blue.subscriber.reliability" value='reliable'></param>
<param name="qos_overrides./model/vehicle_green.subscriber.reliability" value='reliable'></param>
</ros_gz_bridge>
<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 --y -2" />
<node pkg="tf2_ros" exec="static_transform_publisher" args="--frame-id world --child-frame-id vehicle_blue/odom --y 2" />
<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 @@ -25,6 +25,7 @@
<exec_depend>rviz_imu_plugin</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
111 changes: 95 additions & 16 deletions ros_gz_sim_demos/rviz/diff_drive.rviz
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,13 @@ Panels:
Expanded:
- /Global Options1
- /Odometry1
- /Odometry1/Status1
- /Odometry2
Splitter Ratio: 0.5
Tree Height: 701
- 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 All @@ -25,6 +24,24 @@ Panels:
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: <Fixed Frame>
Value: true
- Angle Tolerance: 0.10000000149011612
Class: rviz_default_plugins/Odometry
Covariance:
Expand Down Expand Up @@ -56,13 +73,57 @@ 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
- Angle Tolerance: 0.10000000149011612
Class: rviz_default_plugins/Odometry
Covariance:
Orientation:
Alpha: 0.5
Color: 255; 255; 127
Color Style: Unique
Frame: Local
Offset: 1
Scale: 1
Value: true
Position:
Alpha: 0.30000001192092896
Color: 204; 51; 204
Scale: 1
Value: true
Value: true
Enabled: true
Keep: 100
Name: Odometry
Position Tolerance: 0.10000000149011612
Shape:
Alpha: 1
Axes Length: 1
Axes Radius: 0.10000000149011612
Color: 255; 25; 0
Head Length: 0.30000001192092896
Head Radius: 0.10000000149011612
Shaft Length: 1
Shaft Radius: 0.05000000074505806
Value: Arrow
Topic:
Depth: 5
Durability Policy: Volatile
Filter size: 10
History Policy: Keep Last
Reliability Policy: Reliable
Value: /model/vehicle_green/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,38 +133,56 @@ 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
Value: true
Views:
Current:
Class: rviz_default_plugins/Orbit
Distance: 68.66040802001953
Distance: 21.00491714477539
Enable Stereo Rendering:
Stereo Eye Separation: 0.05999999865889549
Stereo Focal Distance: 1
Swap Stereo Eyes: false
Value: false
Focal Point:
X: -1.2689772844314575
Y: 10.203336715698242
Z: -2.8907392024993896
X: -0.4080231189727783
Y: 0.40098077058792114
Z: 2.436375617980957
Focal Shape Fixed Size: true
Focal Shape Size: 0.05000000074505806
Invert Z Axis: false
Name: Current View
Near Clip Distance: 0.009999999776482582
Pitch: 1.5697963237762451
Pitch: 0.5847957730293274
Target Frame: <Fixed Frame>
Value: Orbit (rviz)
Yaw: 0.8253979682922363
Yaw: 0.4803982973098755
Saved: ~
Window Geometry:
Displays:
Expand All @@ -119,5 +198,5 @@ Window Geometry:
Views:
collapsed: false
Width: 1200
X: 325
Y: 158
X: 554
Y: 154
Loading