Simulation of Erle Copter

From COINS Research Group
Jump to: navigation, search

Tutorial Overview

Title

Simulation of Erle Copter with SITL and ROS Gazebo

Author

Anis Koubaa

Note

This tutorial shows how to simulate Erle Copter with SITL and Gazebo in ROS.

References

Notes

Environment

  • ~/erle_simulation_ardupilot: folder that contains all simulation resources of Erle
  • ~/erle_simulation_ardupilot/ardupilot folder that contains the Ardupilot of Erle copter. Installation steps are here
  • ~/erle_simulation_ardupilot/jsbsim: folder that contains jbsim 3D flight simulator.
  • ~/erle_simulation_ardupilot/erle_catkin_ws: directory of the catkin workspace created to simulate the Erle copter with SITL and Gazebo. Check ROS Installation Steps and Download Gazebo Models first.

Testing the simulator

Start Ardupilot amd MAVProxy Ground Station

cd ~/erle_simulation_ardupilot/ardupilot/ArduCopter
'sim_vehicle.sh -j 4 -f Gazebo --map --console

once MAVProxy has launched completely, load the parameters

param load ~/erle_simulation_ardupilot/ardupilot/Tools/Frame_params/Erle-Copter.param

Note: It could be better to copy the file Erle-Copter.param into ~/erle_simulation_ardupilot/ardupilot/Tools/autotest and rename it as copter_params.param (replace the original file) to load automatically with the simulator.


This is important otherwise, you will have some problems when launching Gazebo. If Gazebo, does not open in the first time, try again until it opens.

Run ROS and Gazebo

Then, run Gazebo and ROS Simulation

source ~/erle_simulation_ardupilot/erle_catkin_ws/devel/setup.bash
roslaunch ardupilot_sitl_gazebo_plugin erlecopter_spawn.launch

Controlling Erle-Copter using MAVProxy

If you get this error in MAVProxy or ROS

FCU: PreArm: RC not calibrated

Then, type this command in MAVProxy prompt

param set ARMING_CHECK 0

Then , in the MAVProxy prompt, write:

mode GUIDED
arm throttle
takeoff 1

You will see the copter taking off at an altitude of 1 meter in Gazebo.

If you want to land, write

mode land

You will see the copter landing at an altitude of 1 meter in Gazebo.

You can also use the Loiter mode:

# in the MAVProxy prompt:
mode LOITER
arm throttle
rc 3 1600

The copter will fly high. Write then

 mode land

To make the copter lands.

See the camera images

Execute in a terminal (make sure it have installed image_view)

rosrun image_view image_view image:=/erlecopter/front/image_front_raw

This will show you the front camera view of the copter.
You can also see the bottom view, by running this command

rosrun image_view image_view image:=/erlecopter/bottom/image_raw

Sonar Sensors

You can see the altitude of the copter using the botton sonar sensor using ROS as follows:

rostopic echo /sonar_down

For the front sensor, write the command

rostopic echo /sonar_front

Controlling with ROS and mavros

The dronemap.py code shows how to control the drone using a ROS node that calls the services of mavros.
This video shows an illustration of the program when executed