RotorS is a MAV gazebo simulator. It provides some multirotor models such as the AscTec Hummingbird, the AscTec Pelican, or the AscTec Firefly, but the simulator is not limited for the use with these multicopters.
There are simulated sensors coming with the simulator such as an IMU, a generic odometry sensor, and the VI-Sensor, which can be mounted on the multirotor.
This package also contains some example controllers, basic worlds, a joystick interface, and example launch files.
Below we provide the instructions necessary for getting started. See RotorS' wiki for more instructions and examples (https://github.com/ethz-asl/rotors_simulator/wiki).
If you are using this simulator within the research for your publication, please cite:
@Inbook{Furrer2016,
author="Furrer, Fadri
and Burri, Michael
and Achtelik, Markus
and Siegwart, Roland",
editor="Koubaa, Anis",
chapter="RotorS---A Modular Gazebo MAV Simulator Framework",
title="Robot Operating System (ROS): The Complete Reference (Volume 1)",
year="2016",
publisher="Springer International Publishing",
address="Cham",
pages="595--625",
isbn="978-3-319-26054-9",
doi="10.1007/978-3-319-26054-9_23",
url="http://dx.doi.org/10.1007/978-3-319-26054-9_23"
}
This simulator requires to have the last version of mavros mavlink and mavcomm libraries. For installing these just execute:
sudo apt-get install ros-kinetic-mavlink ros-kinetic-mavros ros-kinetic-mav-comm python-wstool python-catkin-tools protobuf-compiler libgoogle-glog-dev ros-kinetic-control-toolbox
Launch the simulator with a hex-rotor helicopter model, in our case, the AscTec Firefly in a basic world.
$ roslaunch rotors_gazebo mav_hovering_example.launch mav_name:=firefly world_name:=basic
Note The first run of gazebo might take considerably long, as it will download some models from an online database. Should you receive a timeout error, try running gazebo by itself (e.g. roslaunch gazebo_ros empty_world.launch ) so it has sufficient time to actually download all of the models.
The simulator starts by default in paused mode. To start it you can either
-
use the Gazebo GUI and press the play button
-
or you can send the following service call.
$ rosservice call gazebo/unpause_physics
There are some basic launch files where you can load the different multicopters with additional sensors. They can all be found in ~/catkin_ws/src/rotors_simulator/rotors_gazebo/launch
.
The world_name
argument looks for a .world file with a corresponding name in ~/catkin_ws/src/rotors_simulator/rotors_gazebo/worlds
. By default, all launch files, with the exception of those that have the world name explicitly included in the file name, use the empty world described in basic.world
.
To let the multicopter fly you need to generate thrust with the rotors, this is achieved by sending commands to the multicopter, which make the rotors spin. There are currently a few ways to send commands to the multicopter, we will show one of them here. The rest is documented here in our Wiki. We will here also show how to write a stabilizing controller and how you can control the multicopter with a joystick.
We will for now just send some constant motor velocities to the multicopter.
$ rostopic pub /firefly/command/motor_speed mav_msgs/Actuators '{angular_velocities: [100, 100, 100, 100, 100, 100]}'
Note The size of the
motor_speed
array should be equal to the number of motors you have in your model of choice (e.g. 6 in the Firefly model).
You should see (if you unpaused the simulator and you have a multicopter in it), that the rotors start spinning. The thrust generated by these motor velocities is not enough though to let the multicopter take off.
You can play with the numbers and will realize that the Firefly will take off with motor speeds of about 545 on each rotor. The multicopter is unstable though, since there is no controller running, if you just set the motor speeds.
You can let the helicopter hover with ground truth odometry (perfect state estimation), by launching:
$ roslaunch rotors_gazebo mav_hovering_example.launch mav_name:=firefly world_name:=basic
TODO(ff): Write something here.
Connect a USB joystick to your computer and launch the simulation alongside ROS joystick driver and the RotorS joystick node:
$ roslaunch rotors_gazebo mav_with_joy.launch mav_name:=firefly world_name:=basic
Depending on the type of joystick and the personal preference for operation, you can assign the axis number using the axis_<roll/pitch/thrust>_
parameter and the axis direction using the axis_direction_<roll/pitch/thrust>
parameter.
First, perform a one-time setup of virtual keyboard joystick as described here: https://github.com/ethz-asl/rotors_simulator/wiki/Setup-virtual-keyboard-joystick.
Launch the simulation with the keyboard interface using the following launch file:
$ roslaunch rotors_gazebo mav_with_keyboard.launch mav_name:=firefly world_name:=basic
If everything was setup correctly, an additional GUI should appear with bars indicating the current throttle, roll, pitch, and yaw inputs. While this window is active, the Arrows and W, A, S, D keys will generate virtual joystick inputs, which can then be processed by the RotorS joystick node in the same way as real joystick commands.