Home        Store        Docs        Blog

Setting up a simulation environment


#1

Hey!

I was wondering if someone could help me out setting up a simulation environment for testing missions or guided-mode dronekit python scripts.

So far I understand that there is a SITL file in the install directory for ardusub. I was wondering what other components of this do I need to successful send the simulated drone commands, and more specifically what each component does? And for example would I link the SITL to gazebo? I saw that there is a gazebo plugin on the bluerobotics github, do I need this and what exactly does it do ?

I’m sorry if these questions are elementary, it is just I’m struggling to find a tutorial specific to ardusub.


(Patrick José Pereira) #2

Hello,

Sorry for taking so long to reply. I did a small documentation to help you with your simulation environment, this same documentation will be added in ardusub.com in the future.

S.I.T.L (Software In The Loop)

SITL is a simulator that allows you to run ArduSub without any hardware. It is a build of the autopilot code using an ordinary C++ compiler, giving you a native executable that allows you to test the behaviour of the vehicle.

Installation

To configure and run SITL for the first time in your computer, take a look in Running SITL ArduPilot documentation.

Running ArduSub SITL

This part assumes that you have already set up SITL on your machine.
First is necessary to be inside ArduSub folder.

cd ardupilot/ArduSub

To execute SITL with sim_vehicle.py.

sim_vehicle.py -L RATBeach --out=udp:0.0.0.0:14550 --map --console

After that, ArduSub SITL will compile and start to run, you’ll be able to connect it with QGroundControl and control it.

For more information about sim_vehicle.py and the options available, check:

sim_vehicle.py --help

Running ArduSub SITL with Gazebo

To run ArduSub SITL with Gazebo, it’s necessary to:

  1. Install freebuoyancy_gazebo plugin for buoyancy simulation.

  2. Install ardupilot_gazebo/add_link plugin for ardupilot-gazebo communication. add_link is a branch that provides actuation over sdf links, after the git clone, it’s necessary to run git checkout add_link.

  3. Run BlueRov2 Gazebo model

    1. Download bluerov_ros_playground

      git clone https://github.com/patrickelectric/bluerov_ros_playground
      
    2. Run Gazebo model

      cd bluerov_ros_playground
      source gazebo.sh
      gazebo worlds/underwater.world -u
      # Start the simulation
      
  4. Execute ArduPilot SITL

    sim_vehicle.py -f gazebo-bluerov2 -L RATBeach --out=udp:0.0.0.0:14550 --console
    

The console will start to display the output if the connection was successful.


#3

Hey,

I really appreciate the help! So I’m trying to setup Gazebo but I keep running into low level problems. Particularly with building the freebuoyancy plugin. I cannot seem to find a version number for which that plugin was designed for. The cpp file in the src folder makes me think it is not the current version as it is not using ignition math. Seeing as the next step says to use 7 or 8 I guess it is not the latest version.

So I try to install Gazebo 8.2, but even then I’m running into more low level problems particularly with missing/mismatching libraries. Do they have an easier way of installing Gazebo 8.2 like they do for 9? I keep getting stuck. I would appreciate any more guidance if possible.


(Jacob) #4

ping @patrickelectric


#5

@patrickelectric I was referred to this page by a helpful person on the gazebo answers site: http://gazebosim.org/tutorials?tut=ros_wrapper_versions

Not sure if these are easier/cleaner installations though I will try that soon. Should I go for gazebo 7 or 8? I also noticed that the freebuouyancy plugin was designed to use without ROS, should this be of concern to me even if I install a gazebo package with ROS? Is there any particular reason that the plugin has been built not to use ROS?

What distribution of ROS works best with ardusub?


(Patrick José Pereira) #6

Hi,

Sorry for taking so long to reply, I was O.o.O in this last days.
I did this tutorial with Gazebo 8. It’s necessary to have all versions of all necessary libraries compatible between them, and that’s a big pain to solve sometimes depending of the OS.
What is the operating system that you are using and which version ?


#7

I have tried your tutorial on Ubuntu 16 Xenial and gazebo7 and was able to get gazebo linked with the SITL. I was not able to set waypoints and upload a mission to the rov but manual mode worked fine. Since you said you made the tutorial in gazebo8 I’ll try to set that up and see if I get the same sort of errors before I say anything more.

I’m assuming most things are compatible with Xenial and I should stick on Xenial for development purposes?

Thanks a ton for all the support!

Note to others who may be stuck:
I tried to install gazebo 8 from source because I could not find the gazebo8 package when using apt. This was because I was on Ubuntu 18 Bionic Beaver. The only supported gazebo version on Bionic is gazebo9. I had to look through the packages file in the osrf online repository to find this out. When I backtracked to Ubuntu 16 Xenial, everything worked fine because the gazebo7 and gazebo8 packages exist on that distro, and you should be able to follow the tutorial above and everything worked well. There were a few hiccups but nothing massive like when compiling from source.


(Patrick José Pereira) #8

Hi,

I was not able to set waypoints and upload a mission to the rov but manual mode worked fine.

You should be able to create a mission without problems with QGC, this is a test that I did:
Some points are not great because of the tunning.


I’m assuming most things are compatible with Xenial and I should stick on Xenial for development purposes?

It’s compatible with any operating system that can run gazebo 8.
I’ll try to update the tutorial to be compatible with Ubuntu 18.04 (last LTS) and probably 16.04 as well.


(Patrick José Pereira) #9

I did tests with ubuntu 16.04 and 18.04, using Gazebo 7 and Gazebo 8, everything is working fine.


#10

So I’m getting the following error when trying to upload a mission. I also attached my terminals in which I ran ardupilot and gazebo.

This is on gazebo8 on Ubuntu 16.04 now.


(Patrick José Pereira) #11

This problem was solved in the last version of the QGC development branch.

QGroundControl maintains this download links to allow test and usage of the last updates in main code.

This links are not BlueRobotics QGC Version


#12

Thanks

I let the ROV run in auto mode to go form the home position to the first waypoint. It seems to be struggling to get there at all. I guess I wanted to check if I’m doing something wrong or if this is expected behavior?


Also my ROV doesn’t seem to have a texture like in your screenshot though I believe I did everything as you said. Not sure why this is the case. Your screenshot has that frame in front of the ROV what looks like it is what the camera is seeing, is this the case? Is it possible to get that camera feed back into QGC?


(Jacob) #13

The auto/gps modes are still in development (not stable).

I do not believe this is the case with the stable revs.


(Patrick José Pereira) #14

You should run it in “Auto mode”, and as you can see, the parameters need to be corrected. (In the first image it shows the ROV upside down).

You can download here: bluerov_sitl_fast.params (24.3 KB) The parameters that I use in this gif:

It’s running like in The Fast and the Furious mode, but a bit of tuning will make it better.

Also my ROV doesn’t seem to have a texture like in your screenshot though I believe I did everything as you said.

I need confirm that, but probably is related to your gazebo version.

Your screenshot has that frame in front of the ROV what looks like it is what the camera is seeing, is this the case? Is it possible to get that camera feed back into QGC?

The image with the camera is a picture of the bluerov_playground simulation module, it was not from the SITL, but we are working to stream the gazebo camera to QGC.