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

Add UFO Example #189

Open
wants to merge 18 commits into
base: main
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
1 change: 1 addition & 0 deletions drake_ros_examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ find_package(gflags REQUIRED COMPONENTS shared)
add_subdirectory(examples/iiwa_manipulator)
add_subdirectory(examples/multirobot)
add_subdirectory(examples/rs_flip_flop)
add_subdirectory(examples/ufo)

if(BUILD_TESTING)
find_package(ament_cmake_clang_format REQUIRED)
Expand Down
5 changes: 4 additions & 1 deletion drake_ros_examples/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Drake ROS Examples

This is a collection of examples built around `drake_ros` libraries' C++ and Python APIs.
This is a collection of examples built around `drake_ros` libraries' C++ and
Python APIs.

## Building with Colcon

Expand Down Expand Up @@ -117,3 +118,5 @@ tooling per the list below.
- [IIWA manipulator](./examples/iiwa_manipulator): an RViz visualization of a static IIWA arm.
- [Multi-Robot Simulation](./examples/multirobot): Simulates multiple robots
using Drake and visualizes them with RViz using a single marker display topic.
- [UFO](./examples/multirobot): an RViz visualization of a flying object
controlled with the Drake systems framework and commanded using RViz.
27 changes: 27 additions & 0 deletions drake_ros_examples/examples/ufo/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
find_package(ament_index_cpp REQUIRED)
find_package(drake REQUIRED)
find_package(drake_ros REQUIRED)
find_package(geometry_msgs REQUIRED)

add_executable(ufo ufo.cc)
target_link_libraries(ufo PRIVATE
ament_index_cpp::ament_index_cpp
drake::drake
drake_ros::drake_ros_core
drake_ros::drake_ros_tf2
drake_ros::drake_ros_viz
${geometry_msgs_TARGETS}
)
target_compile_features(ufo PRIVATE cxx_std_17)

install(
TARGETS
ufo
DESTINATION lib/${PROJECT_NAME}
)

install(
DIRECTORY
models/
DESTINATION share/${PROJECT_NAME}/models/
)
34 changes: 34 additions & 0 deletions drake_ros_examples/examples/ufo/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# UFO

## Overview

The UFO example shows how to use Drake ROS and the Drake systems framework to
enable controlling a flying object with RViz.

It publishes the following topics:

* `/tf` (all scene frames)
* `/scene_markers/collision` (all collision geometries)
* `/scene_markers/visual` (all visual geometries)

It subscribes to the following topic

* `/goal_pose` (commands where the object should fly to)

## How to run the example

Run the `ufo` executable.

```
ros2 run drake_ros_examples ufo
```

Run RViz in a different terminal with your ROS installation sourced to visualize
the station.

```
ros2 run rviz2 rviz2 -d ufo.rviz
```

Use the `2D Goal Pose` button in RViz to set the location to which the object
should fly to.
25 changes: 25 additions & 0 deletions drake_ros_examples/examples/ufo/models/ground.sdf
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" ?>
<sdf version="1.9">
<model name="ground">
<static>true</static>
<link name="ground">
<visual name="visual">
<geometry>
<plane>
<size>50 50</size>
</plane>
</geometry>
<material>
<diffuse>0.0 0.5 0.0 1.0</diffuse>
</material>
</visual>
<collision name="collision">
<geometry>
<plane>
<size>50 50</size>
</plane>
</geometry>
</collision>
</link>
</model>
</sdf>
79 changes: 79 additions & 0 deletions drake_ros_examples/examples/ufo/models/ufo.sdf
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<?xml version="1.0" ?>
<sdf version="1.9">
<model name="flying_saucer">
<!-- A great place to put a tractor beam -->
<frame name="bottom_center"/>

<!-- Ellipsoid body of the craft -->
<link name="spacecraft">
<pose relative_to="bottom_center">0 0 0.5 0 0 0</pose>
<visual name="visual">
<geometry>
<ellipsoid>
<radii>2.5 2.5 0.5</radii>
</ellipsoid>
</geometry>
<material>
<diffuse>0.5 0.5 0.5 1.0</diffuse>
</material>
</visual>
<collision name="collision">
<geometry>
<ellipsoid>
<radii>2.5 2.5 0.5</radii>
</ellipsoid>
</geometry>
</collision>
<inertial>
<mass>1000</mass>
<inertia>
<ixx>1300</ixx>
<ixy>0</ixy>
<ixz>0</ixz>
<iyy>1300</iyy>
<iyz>0</iyz>
<izz>2500</izz>
</inertia>
</inertial>
</link>

<!-- Spherical translucent shell for pilot to peer out of -->
<link name="lookout">
<pose relative_to="spacecraft">0 0 0.49 0 0 0</pose>
<visual name="visual">
<geometry>
<sphere>
<radius>0.98</radius>
</sphere>
</geometry>
<material>
<diffuse>1.0 0.55 0.0 0.35</diffuse>
</material>
</visual>
<collision name="collision">
<geometry>
<sphere>
<radius>0.98</radius>
</sphere>
</geometry>
</collision>
<inertial>
<mass>100</mass>
<inertia>
<ixx>65.34</ixx>
<ixy>0</ixy>
<ixz>0</ixz>
<iyy>65.34</iyy>
<iyz>0</iyz>
<izz>65.34</izz>
</inertia>
</inertial>
</link>

<!-- Combine links -->
<joint name="weld" type="fixed">
<parent>spacecraft</parent>
<child>lookout</child>
</joint>
</model>
</sdf>
16 changes: 16 additions & 0 deletions drake_ros_examples/examples/ufo/models/ufo_scene.sdf
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" ?>
<sdf version="1.9">
<world name="ufo_scene">
<model name="spacecraft">
<include merge="true">
<uri>package://drake_ros_examples/models/ufo.sdf</uri>
</include>
</model>
<model name="ground">
<include merge="true">
<uri>package://drake_ros_examples/models/ground.sdf</uri>
</include>
<static>true</static>
</model>
</world>
</sdf>
Loading