Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon

Using ROS with UAVs

Save for later
  • 11 min read
  • 10 Nov 2016

article-image

In this article by Carol Fairchild and Dr. Thomas L. Harman, co-authors of the book ROS Robotics by Example, you will discover the field of ROS Unmanned Air Vehicles (UAVs), quadrotors, in particular. The reader is invited to learn about the simulated hector quadrotor and take it for a flight.

The ROS wiki currently contains a growing list of ROS UAVs. These UAVs are as follows:

(For more resources related to this topic, see here.)

  • AscTec Pelican and Hummingbird quadrotors
  • Berkeley's STARMAC
  • Bitcraze Crazyflie
  • DJI Matrice 100 Onboard SDK ROS support
  • Erle-copter
  • ETH sFly
  • Lily CameraQuadrotor
  • Parrot AR.Drone
  • Parrot Bebop
  • Penn's AscTec Hummingbird Quadrotors
  • PIXHAWK MAVs
  • Skybotix CoaX helicopter

Refer to http://wiki.ros.org/Robots#UAVs for future additions to this list and to the website http://www.ros.org/news/robots/uavs/ to get the latest ROS UAV news.

The preceding list contains primarily quadrotors except for the Skybotix helicopter. A number of universities have adopted the AscTec Hummingbird as their ROS UAV of choice. For this book, we present a simulator called Hector Quadrotor and two real quadrotors Crazyflie and Bebop that use ROS.

Introducing Hector quadrotor

The hardest part of learning about flying robots is the constant crashing. From the first-time learning of flight control to testing new hardware or flight algorithms, the resulting failures can have a huge cost in terms of broken hardware components. To answer this difficulty, a simulated air vehicle designed and developed for ROS is ideal.

A simulated quadrotor UAV for the ROS Gazebo environment has been developed by the Team Hector Darmstadt of Technische Universität Darmstadt. This quadrotor, called Hector Quadrotor, is enclosed in the hector_quadrotor metapackage. This metapackage contains the URDF description for the quadrotor UAV, its flight controllers, and launch files for running the quadrotor simulation in Gazebo.

Advanced uses of the Hector Quadrotor simulation allows the user to record sensor data such as Lidar, depth camera, and many more. The quadrotor simulation can also be used to test flight algorithms and control approaches in simulation.

The hector_quadrotor metapackage contains the following key packages:

  • hector_quadrotor_description: This package provides a URDF model of Hector Quadrotor UAV and the quadrotor configured with various sensors. Several URDF quadrotor models exist in this package each configured with specific sensors and controllers.
  • hector_quadrotor_gazebo: This package contains launch files for executing Gazebo and spawning one or more Hector Quadrotors.
  • hector_quadrotor_gazebo_plugins: This package contains three UAV specific plugins, which are as follows:
    • The simple controller gazebo_quadrotor_simple_controller subscribes to a geometry_msgs/Twist topic and calculates the required forces and torques
    • A gazebo_ros_baro sensor plugin simulates a barometric altimeter
    • The gazebo_quadrotor_propulsion plugin simulates the propulsion, aerodynamics, and drag from messages containing motor voltages and wind vector input
  • hector_gazebo_plugins: This package contains generic sensor plugins not specific to UAVs such as IMU, magnetic field, GPS, and sonar data.
  • hector_quadrotor_teleop: This package provides a node and launch files for controlling a quadrotor using a joystick or gamepad.
  • hector_quadrotor_demo: This package provides sample launch files that run the Gazebo quadrotor simulation and hector_slam for indoor and outdoor scenarios.

The entire list of packages for the hector_quadrotor metapackage appears in the next section.

Loading Hector Quadrotor

The repository for the hector_quadrotor software is at the following website:

https://github.com/tu-darmstadt-ros-pkg/hector_quadrotor

The following commands will install the binary packages of hector_quadrotor into the ROS package repository on your computer. If you wish to install the source files, instructions can be found at the following website:

http://wiki.ros.org/hector_quadrotor/Tutorials/Quadrotor%20outdoor%20flight%20demo

(It is assumed that ros-indigo-desktop-full has been installed on your computer.)

For the binary packages, type the following commands to install the ROS Indigo version of Hector Quadrotor:

$ sudo apt-get update
$ sudo apt-get install ros-indigo-hector-quadrotor-demo

A large number of ROS packages are downloaded and installed in the hector_quadrotor_demo download with the main hector_quadrotor packages providing functionality that should now be somewhat familiar. This installation downloads the following packages:

  • hector_gazebo_worlds
  • hector_geotiff
  • hector_map_tools
  • hector_mapping
  • hector_nav_msgs
  • hector_pose_estimation
  • hector_pose_estimation_core
  • hector_quadrotor_controller
  • hector_quadrotor_controller_gazebo
  • hector_quadrotor_demo
  • hector_quadrotor_description
  • hector_quadrotor_gazebo
  • hector_quadrotor_gazebo_plugins
  • hector_quadrotor_model
  • hector_quadrotor_pose_estimation
  • hector_quadrotor_teleop
  • hector_sensors_description
  • hector_sensors_gazebo
  • hector_trajectory_serve
  • hector_uav_msgs
  • message_to_tf

A number of these packages will be discussed as the Hector Quadrotor simulations are described in the next section.

Launching Hector Quadrotor in Gazebo

Two demonstration tutorials are available to provide the simulated applications of the Hector Quadrotor for both outdoor and indoor environments. These simulations are described in the next sections.

Before you begin the Hector Quadrotor simulations, check your ROS master using the following command in your terminal window:

$ echo $ROS_MASTER_URI

If this variable is set to localhost or the IP address of your computer, no action is needed. If not, type the following command:

$ export ROS_MASTER_URI=http://localhost:11311

This command can also be added to your .bashrc file. Be sure to delete or comment out (with a #) any other commands setting the ROS_MASTER_URI variable.

Flying Hector outdoors

The quadrotor outdoor flight demo software is included as part of the hector_quadrotor metapackage. Start the simulation by typing the following command:

$ roslaunch hector_quadrotor_demo outdoor_flight_gazebo.launch

This launch file loads a rolling landscape environment into the Gazebo simulation and spawns a model of the Hector Quadrotor configured with a Hokuyo UTM-30LX sensor. An rviz node is also started and configured specifically for the quadrotor outdoor flight. A large number of flight position and control parameters are initialized and loaded into the Parameter Server.

Note that the quadrotor propulsion model parameters for quadrotor_propulsion plugin and quadrotor drag model parameters for quadrotor_aerodynamics plugin are displayed. Then look for the following message:

Physics dynamic reconfigure ready.

The following screenshots show both the Gazebo and rviz display windows when the Hector outdoor flight simulation is launched. The view from the onboard camera can be seen in the lower left corner of the rviz window. If you do not see the camera image on your rviz screen, make sure that Camera has been added to your Displays panel on the left and that the checkbox has been checked. If you would like to pilot the quadrotor using the camera, it is best to uncheck the checkboxes for tf and robot_model because the visualizations sometimes block the view:

using-ros-uavs-img-0Hector Quadrotor outdoor gazebo view

using-ros-uavs-img-1Hector Quadrotor outdoor rviz view

The quadrotor appears on the ground in the simulation ready for takeoff. Its forward direction is marked by a red mark on its leading motor mount. To be able to fly the quadrotor, you can launch the joystick controller software for the Xbox 360 controller. In a second terminal window, launch the joystick controller software with a launch file from the hector_quadrotor_teleop package:

$ roslaunch hector_quadrotor_teleop xbox_controller.launch

This launch file launches joy_node to process all joystick input from the left stick and right stick on the Xbox 360 controller as shown in the following figure. The message published by joy_node contains the current state of the joystick axes and buttons. The quadrotor_teleop node subscribes to these messages and publishes messages on the cmd_vel topic. These messages provide the velocity and direction for the quadrotor flight.

Unlock access to the largest independent learning library in Tech for FREE!
Get unlimited access to 7500+ expert-authored eBooks and video courses covering every tech area you can think of.
Renews at ₹800/month. Cancel anytime

Several joystick controllers are currently supported by the ROS joy package including PS3 and Logitech devices. For this launch, the joystick device is accessed as /dev/input/js0 and is initialized with a deadzone of 0.050000. Parameters to set the joystick axes are as follows:

* /quadrotor_teleop/x_axis: 5
* /quadrotor_teleop/y_axis: 4
* /quadrotor_teleop/yaw_axis: 1
* /quadrotor_teleop/z_axis: 2

These parameters map to the Left Stick and the Right Stick controls on the Xbox 360 controller shown in the following figure. The direction of these sticks control are as follows:

  • Left Stick:
    • Forward (up) is to ascend
    • Backward (down) is to descend
    • Right is to rotate clockwise
    • Left is to rotate counterclockwise
  • Right Stick:
    • Forward (up) is to fly forward
    • Backward (down) is to fly backward
    • Right is to fly right
    • Left is to fly left

using-ros-uavs-img-2Xbox 360 joystick controls for Hector

Now use the joystick to fly around the simulated outdoor environment! The pilot's view can be seen in the Camera image view on the bottom left of the rviz screen.

As you fly around in Gazebo, keep an eye on the Gazebo launch terminal window. The screen will display messages as follows depending on your flying ability:

[ INFO] [1447358765.938240016, 617.860000000]: Engaging motors!

[ WARN] [1447358778.282568898, 629.410000000]: Shutting down motors due to flip over!

When Hector flips over, you will need to relaunch the simulation.

Within ROS, a clearer understanding of the interactions between the active nodes and topics can be obtained by using the rqt_graph tool. The following diagram depicts all currently active nodes (except debug nodes) enclosed in oval shapes. These nodes publish to the topics enclosed in rectangles that are pointed to by arrows. You can use the rqt_graph command in a new terminal window to view the same display:

using-ros-uavs-img-3ROS nodes and topics for Hector Quadrotor outdoor flight demo

The rostopic list command will provide a long list of topics currently being published. Other command line tools such as rosnode, rosmsg, rosparam, and rosservice will help gather specific information about Hector Quadrotor's operation.

To understand the orientation of the quadrotor on the screen, use the Gazebo GUI to show the vehicle's tf reference frame. Select quadrotor in the World panel on the left, then select the translation mode on the top environment toolbar (looks like crossed double-headed arrows). This selection will bring up the red-green-blue axis for the x-y-z axes of the tf frame, respectively. In the following figure, the x axis is pointing to the left, the y axis is pointing to the right (toward the reader), and the z axis is pointing up.

using-ros-uavs-img-4 Hector Quadrotor tf reference frame

An YouTube video of hector_quadrotor outdoor scenario demo shows the hector_quadrotor in Gazebo operated with a gamepad controller:

https://www.youtube.com/watch?v=9CGIcc0jeuI

Flying Hector indoors

The quadrotor indoor SLAM demo software is included as part of the hector_quadrotor metapackage. To launch the simulation, type the following command:

$ roslaunch hector_quadrotor_demo indoor_slam_gazebo.launch

The following screenshots show both the rviz and Gazebo display windows when the Hector indoor simulation is launched:

using-ros-uavs-img-5Hector Quadrotor indoor rviz and gazebo views

If you do not see this image for Gazebo, roll your mouse wheel to zoom out of the image. Then you will need to rotate the scene to a top-down view, in order to find the quadrotor press Shift + right mouse button.

The environment was the offices at Willow Garage and Hector starts out on the floor of one of the interior rooms. Just like in the outdoor demo, the xbox_controller.launch file from the hector_quadrotor_teleop package should be executed:

$ roslaunch hector_quadrotor_teleop xbox_controller.launch

If the quadrotor becomes embedded in the wall, waiting a few seconds should release it and it should (hopefully) end up in an upright position ready to fly again. If you lose sight of it, zoom out from the Gazebo screen and look from a top-down view. Remember that the Gazebo physics engine is applying minor environment conditions as well. This can create some drifting out of its position.

The rqt graph of the active nodes and topics during the Hector indoor SLAM demo is shown in the following figure. As Hector is flown around the office environment, the hector_mapping node will be performing SLAM and be creating a map of the environment.

using-ros-uavs-img-6ROS nodes and topics for Hector Quadrotor indoor SLAM demo

The following screenshot shows Hector Quadrotor mapping an interior room of Willow Garage:

using-ros-uavs-img-7Hector mapping indoors using SLAM

The 3D robot trajectory is tracked by the hector_trajectory_server node and can be shown in rviz. The map along with the trajectory information can be saved to a GeoTiff file with the following command:

$ rostopic pub syscommand std_msgs/String "savegeotiff"

The savegeotiff map can be found in the hector_geotiff/map directory.

An YouTube video of hector_quadrotor stack indoor SLAM demo shows hector_quadrotor in Gazebo operated with a gamepad controller:

https://www.youtube.com/watch?v=IJbJbcZVY28

Summary

In this article, we learnt about Hector Quadrotors, loading Hector Quadrotors, launching Hector Quadrotor in Gazebo, and also about flying Hector outdoors and indoors.

Resources for Article:


Further resources on this subject: