This repository contains simulation code to control a Quadcopter using ROS/Gazebo. This is done by sending ROS topics from Simulink, using blocks from ROS toolbox. To control the drone following the architecture of Simulink/Gazebo is implemented:
Working architecture of the simulation model
Simulation Architecture Simulink
For the moment, these models control the drone with ID 1, but you can change the topics of the Subscribe and Publish blocks to control another drone.
The simulation is tested to be working on the following dependencies:
- ROS Kinetic
- GAZEBO 7
- Ubuntu 16.04.7 LTS
- Vmware workstation 16 players (Highly recommended for connection with MATLAB
-
ROS Kinetic
http://wiki.ros.org/kinetic/Installation/Ubuntu
-
Gazebo 7
sudo apt-get install gazebo7
-
UBUNTU 16.04.7 LTS
https://releases.ubuntu.com/16.04/
-
Vmware workstation 16 player
https://www.vmware.com/in/products/workstation-player.html
ROS Quick install and run process(ROS side; Using Bash)
-
If not done make scripts executable: chmod +x setup.sh chmod +x run_gzb.sh chmod +x start_uav.sh
-
Run setup script (this should be done once for a fresh install without ROS or gazebo already installed, in case of error run required commands by hand step by step) ./setup.sh
-
Start gazebo environment simulator and ROS server ./run_gzb.sh
-
Add a robot to the scene with default ID ./start_uav.sh MATLAB To connect Simulink with the ROS server, follow these steps:
-
In MATLAB, execute the rosinit function with the IP of the virtual machine
-
In Simulink, navigate to Tools > Robotics Operating System > Configure Network Addresses
-
In ROS Master, make sure Network Address is set to Default
-
In Node Host, make sure Network Address is set to Default
-
Test the connectivity using the Test button
When testing the code on a real drone make sure of the following:
- Always tune the PID Values within less windy areas
- Redundancy in communication channels during initial tuning is required.
Matlab has the advantage of a model-based design strategy which gives its quick turnaround time with a high-level view of the model internal data giving the user access to deep understanding along with production quality code generation plugins for various types of embedded platforms and SOC. Also, Matlab has various pre-built libraries of many algorithms in robotics ready to deploy making prototyping a breeze.
The stack will be upgraded :
- GPS Sensor for accurate estimations
- Build the code through code generator for NVIDIA Jetson XAVIER AGX
- ROS2 in the coming week for the reasons below: a) Support real-time control: ROS2 also adds support for real-time control, which can improve the timeliness of control and the performance of the overall robot. b) Multi-platform support: ROS2 not only runs on Linux systems, but also adds support for Windows, MacOS, RTOS and other systems, giving developers more choices.
- UI for different controls bridging inputs and outputs of Gazebo and Matlab in one place.
- Better input mechanism for different drone platforms.
-
If a model can control the drone but does not receive any data from the drone: a) Make sure you have set the ROS_IP environment variable in the VM before running ROS b) See if the port on VM is listening
-
If Gazebo keeps crashing export the below variable to adjust the problem
export SVGA_VGPU10=0