Rosanswers logo

Hi guys,

I'm pretty new to the whole Gazebo/ROS software and I need to do a project using them and came across a few queries, could you help?

First of all, what I want to do is to control a UAV in simulation via Matlab. Could someone kindly explain how this could be done and from where should I start? From what I understood so far, I would need to simulate the robot in ROS and communicate with Matlab via ROS while using Gazebo as the simulation environment, is that so? If so how can I do this? Practically I would like to give the robot a target location from Matlab and let the robot go there.

Secondly from what I can understand the best quadrotor to use is the hector_quadrotor (can't publish the link since I'm new to the forum :/). I've been trying to get this to work but seem to be running across a few difficulties. I have tried installing the hector_quadrotor package by first cloning the git link then using rosdep to install and roslaunch (again I was following the link to install packages used in asctec_drivers but I can't post the link). The problem is that when running rosdep it is telling me that there are missing resources such as roscpp and hector_sensors_description. Could someone kindly help me?

Thanks a lot in advance and sorry for the long post. Again i'm fairly new to all this and I've been banging my head on this all week :/

Cheers, JP

Originally posted by jpcallus on ROS Answers with karma: 33 on 2013-06-27

Post score: 2


1 Answer 1


Rosanswers logo

Let's start with the second problem:

I assume you are using groovy. You need to install/clone several additional stacks to use hector_quadrotor with all features:

and of course the simulator_gazebo stack with the Gazebo simulator and related packages. Make sure to clone the groovy-devel branch of the hector_quadrotor, hector_gazebo and hector_models in groovy, but this should be the default. rosdep only installs system dependencies and some 3rd-party libraries packaged especially for ROS, not other packages and stacks.

I added a rosinstall file containing all dependencies to the repo. If you have the python-rosinstall package installed, you can simply create a new workspace using the following commands:

rosinstall hector_quadrotor_workspace /opt/ros/groovy https://raw.github.com/tu-darmstadt-ros-pkg/hector_quadrotor/groovy-devel/hector_quadrotor.rosinstall
cd hector_quadrotor_workspace
source setup.bash
rosmake hector_quadrotor_gazebo

I just verfied that this procedure works with a pure ROS groovy installation and the simulator_gazebo stack installed.

If all stacks are in your ROS_PACKAGE_PATH, you should be able to rosmake hector_quadrotor_gazebo and spawn a quadrotor in Gazebo using the roslaunch hector_quadrotor_gazebo spawn_quadrotor.launch command (or one of the other variants depending of your application).

You can also check the hector_quadrotor tutorials which contain some further instructions for doing indoor or outdoor SLAM.

The quadrotor can be controlled by velocity commands on the /cmd_vel topic and also publishes its state in tf and on the /ground_truth/state topic.

There are several solutions to control the quadrotor from within Matlab. Check this page for an overview. None of these methods works just out of the box as there is no supported ROS client library yet.

In our group we use the rosmatlab package to communicate with the simulated and real quadrotor. Installation is a bit complicated, but once installed writing litte scripts or publishing control commands from Matlab is very easy. The interface mimics roscpp as far as possible.

This Gazebo/Matlab approach is fine for commanding velocities that only change slowly compared to the drone's dynamics. If you want to simulate a real-time controller, you have to implement your own Gazebo plugin. The hector_quadrotor_controller package contains two plugins to simulate the propulsion system and the aerodynamics of the quadrotor using a Matlab model compiled with Matlab Coder. These plugins are disabled by default as not everyone has an installation of Matlab. We use these plugins together with the gazebo_rtt_plugin to load Orocos Real-Time Toolkit components into Gazebo for software-in-the-loop simulations, but this approach is currently not documented.

Originally posted by Johannes Meyer with karma: 1266 on 2013-07-04

This answer was ACCEPTED on the original site

Post score: 4

Original comments

Comment by jpcallus on 2013-07-04:
Wow thanks for that! I have decided to write the code directly in C++ instead of using Matlab since it seems to be the more straightforward option but at the moment I'm trying to get the whole thing to work with Gazebo 1.8 since the version used in the simulator_gazebo package seems to be outdated!


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.