Python - Gazebo Simulation Environment for a UAV with Geometric Control
tag:ros-noetic |
This repository includes Python codes for the position control a UAV in a Gazebo simulation environment, using geometric controllers.
@InProceedings{Gamagedara2019b,
title={Geometric controls of a quadrotor uav with decoupled yaw control},
author={Gamagedara, Kanishke and Bisheban, Mahdis and Kaufman, Evan and Lee, Taeyoung},
booktitle={2019 American Control Conference (ACC)},
pages={3285--3290},
year={2019},
organization={IEEE}
}
Controller
class with your controller.fM
).@InProceedings{Gamagedara2019a,
author = {Kanishke Gamagedara and Taeyoung Lee and Murray R. Snyder},
title = {Real-time Kinematics {GPS} Based Telemetry System for Airborne Measurements of Ship Air Wake},
booktitle = {{AIAA} Scitech 2019 Forum},
year = {2019},
month = {jan},
publisher = {American Institute of Aeronautics and Astronautics},
doi = {10.2514/6.2019-2377}
}
DelayedKalmanFilter.m
is utilized here.Estimator
class with your estimator.Trajectory
class.calculate_desired
function inside the Trajectory
class.:bangbang: If you are running this on a virtual machine, please make sure that Gazebo can run at real-time speed. It is known that this simulation exhibits unintended behavior if the "real-time factor" of the Gazebo simulation is not closer to 1.0 (See issue#3).
git clone https://github.com/fdcl-gwu/uav_simulator.git
cd uav_simulator
git submodule update --init --recursive
You have to options here:
Installing everything locally is probably the fastest way, but you may have to instal dependencies manually, or may have to deal with package version changes. Docker solves this by streamlining all the dependencies, up-to the OS. For example, if you are on Ubuntu 22.04 and want to test the ROS-Melodic version, docker will be the only way.
If you want to install everything locally, follow Local Install. If you want to run a docker container instead, skip to Docker Setup.
ros-melodic
branch before installing dependencies.sudo apt-get install python3-pip python3-gi
python3 -m pip install numpy pandas matplotlib
Now, skip to Setting-up the plugins and Gazebo.
The instructions here assume you are on Ubuntu. This has not been tested on other OS versions.
cd uav_simulator
xhost +
docker build -t uav_simulator .
(see following paragraph if you just want to pull the built image instead)bash docker_run.sh
The last command will start a docker container, install all the dependencies, and mount the local directory there. The first time you run the build command will take a while as it installs all the libraries.
You can skip the build command altogether by pulling the built docker from the Docker Hub with the following command. This is NOT required if you are building it locally using the build command.
docker pull kanishgama/uav_simulator:ros-noetic
bash docker_run.sh
After that, you only need to run the bash docker_run.sh
every time you need to run the simulation.
Since this mounts the local repository inside the docker, you just need to change the code in your local repository, and it will be automatically update inside the docker.
For running the code, simply follow Setting-up the plugins and Gazebo, and onwards.
You only need to do the followings once (unless you change the Gazebo plugins)
# From uav_simulator
catkin_make
# From uav_simulator
cd devel && source setup.bash && cd ../
# From uav_simulator
roslaunch uav_gazebo simple_world.launch
# From uav_simulator/scripts
python3 main.py
If you change the Python code, simply re-run the Python code.
The code has been tested with Python3.8.10, which comes default with Ubuntu 20.04.catkin_make
and re-run it.reset_uav()
in rover.py
when you run the Python code.WASD
: to move in horizontal planeP
: increase altitudeL
: decrease altitudeQ
: yaw rotation in anti-clockwise directionE
: yaw rotation in clockwise directionM
: kill motors0-5
: set the flight mode without clicking on the GUIon_key_press
function in gui.py
.python -m unittest
.matrix_utils.py
module.