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 battery demo #633

Draft
wants to merge 3 commits into
base: ros2
Choose a base branch
from
Draft
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
24 changes: 12 additions & 12 deletions ros_gz_sim_demos/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,18 @@ And

![](images/air_pressure_demo.png)

## Battery

Get the current state of a battery.

ros2 launch ros_gz_sim_demos battery.launch.xml

Then send a command so the vehicle moves and drains the battery.

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

![](images/battery_demo.png)

## Camera

Publishes RGB camera image and info.
Expand Down Expand Up @@ -164,18 +176,6 @@ Using Gazebo Sim plugin:

![](images/rgbd_camera_demo.png)

## Battery

Get the current state of a battery.

ros2 launch ros_gz_sim_demos battery.launch.py

Then send a command so the vehicle moves and drains the battery

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

![](images/battery_demo.png)

## Robot description publisher

Leverage the robot description publisher to spawn a new urdf model in gazebo and
Expand Down
18 changes: 18 additions & 0 deletions ros_gz_sim_demos/config/battery.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Battery configuration.
- ros_topic_name: "/model/vehicle_blue/cmd_vel"
gz_topic_name: "/model/vehicle_blue/cmd_vel"
ros_type_name: "geometry_msgs/msg/Twist"
gz_type_name: "gz.msgs.Twist"
subscriber_queue: 5
publisher_queue: 6
lazy: false
direction: ROS_TO_GZ

- ros_topic_name: "/model/vehicle_blue/battery/linear_battery/state"
gz_topic_name: "/model/vehicle_blue/battery/linear_battery/state"
ros_type_name: "sensor_msgs/msg/BatteryState"
gz_type_name: "gz.msgs.BatteryState"
subscriber_queue: 5
publisher_queue: 6
lazy: false
direction: GZ_TO_ROS
69 changes: 0 additions & 69 deletions ros_gz_sim_demos/launch/battery.launch.py

This file was deleted.

7 changes: 7 additions & 0 deletions ros_gz_sim_demos/launch/battery.launch.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<launch>
<gz_server world_sdf_file="linear_battery_demo.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/battery.yaml" use_composition="True" />
<!-- FIXME: Why isn't the topic being populated on the UI? RQt issue? -->
<node pkg="rqt_plot" exec="rqt_plot" args="--force-discover /model/vehicle_blue/battery/linear_battery/state/percentage" />
<executable cmd="gz sim -g" />
</launch>