Final year project to navigate a copter indoor and outdoor
This file is used for explaining the final year project done by Xianzhen Guo ([email protected]). Some necessary softwares, simulation tools, operation sysytem and how to configure the operation environment will be introduced in this file.
Operation system This project is developed and tested on Ubuntu 16.04.
Robot Operation System ROS Kinetic Kame is used in this project.
Install gazebo simulator and ROS
- A script called "ubuntu_sim_ros_gazebo.sh" is used to install Gazebo with ROS. The script can be downloaded on https://raw.githubusercontent.com/PX4/Devguide/master/build_scripts/ubuntu_sim_ros_gazebo.sh.
- Before using the script, you should make the user a member of the group "dialout" follwing the commands below. sudo usermod -a -G dialout $USER Logout and login again (the change is only made after a new login)
- source ubuntu_sim_ros_gazebo.sh For detailed steps, please read the intructions on https://dev.px4.io/en/setup/dev_env_linux.html
After that Gazebo 7 and ROS kinetic will be installed. A ROS workspace is created at ~/catkin_ws/. Please check ~/catkin_ws/src to see if there are two folders called "mavros" and "mavlink". If no, please clone this two package from https://github.com/mavlink and then build your ROS workspace using "catkin build".
PX4 Firmware We will be using PX4 v1.8.0 throughout our tutorial.
- cd ~/catkin_ws/src #it could take a while
- git clone https://github.com/PX4/Firmware.git
- cd Firmware
- git checkout v1.8.0
- make posix_sitl_default gazebo
Now you should see a window pop out and a drone is centered in the middle of the environment, but let's close the window for now.
Modifying your 'bashrc' so that your environment remains the same every time you open a new terminal: open a new terminal:
- sudo gedit ~/.bashrc
- source ~/catkin_ws/devel/setup.bash
- source ~/catkin_ws/src/Firmware/Tools/setup_gazebo.bash ~/catkin_ws/src/Firmware/ ~/catkin_ws/src/Firmware/build/posix_sitl_default
- export ROS_PACKAGE_PATH=$ROS_PACKAGE_PATH:~/catkin_ws/src/Firmware
- export ROS_PACKAGE_PATH=$ROS_PACKAGE_PATH:~/catkin_ws/src/Firmware/Tools/sitl_gazebo
Now you can try to launch MAVROS and Gazebo simulation at the same time using
- roslaunch px4 mavros_posix_sitl.launch
You can also check the mavros state using
- rostopic echo /mavros/state
Using GAAS project
- git clone [email protected]:generalized-intelligence/GAAS.git
You will see four folders in ~/GAAS: demo: everything we need for this tutorial can be found in this folder; hardware: it contains relevant information on how to build the hardware; simulator: it contains drone simulation models, world models etc. ; software: it contains other packages such as ObstacleMap, SLAM, Local and Global path planner etc
Next, add customized model path to bashrc by:
- echo "export GAZEBO_MODEL_PATH=${GAZEBO_MODEL_PATH}:(GAAS_PATH)/simulator/models" >> ~/.bashrc
Copy models and config files to corresponding PX4 folders:
#REPLACE (GAAS_PTH) WITH A REAL PATH
- cp -r (GAAS_PATH)/simulator/models/* ~/catkin_ws/src/Firmware/Tools/sitl_gazebo/models/
- cp -r (GAAS_PATH)/GAAS/simulator/worlds/* ~/catkin_ws/src/Firmware/Tools/sitl_gazebo/worlds/
- cp -r (GAAS_PATH)/GAAS/simulator/posix-config/* ~/catkin_ws/src/Firmware/posix-configs/SITL/init/ekf2/
Control a drone using python script
- cd /home/guo/GAAS/demo/tutorial_3
- python px4_mavros_run.py
- python square.py
Simulating SLAM navigation Please refer to "https://gaas.gitbook.io/guide/build-your-own-autonomous-drone-part-3-using-slam-in-gps-denied-environment-for-position-estimation" for detailed information about how to implementing SLAM navigation using GAAS.
Combination of SLAM and GPS navigation
- This is a launch file in ~/home/guo/catkin_ws/src/Firmware/launch called slam'launch
- Replace "iris_stereo_gray_no_gps" in with "iris_stereo_gray_gps"
Then you can use the launch file as the way in SLAM navigation
To enable vision and GPS as the source of external position estimation, select the top left GEAR button and select "Parameters", input "vision" in the search and tick "vision position fusion" and "GPS fusion". Click "save" to save the modification.
Next, hit "Clear" , select "Tools" and choose "reboot vehicle" to make modifications take effect.
Now you can simulation a combination of SLAM and GPS navigation. If you want to stop GPS, please use
- gpssim stop If you want to restar GPS, please use
- gpssim start
There are some useful websites for your project.
- GAAS gitbook : https://gaas.gitbook.io/guide/
- General ROS introduction: http://wiki.ros.org/
- MAVROS: http://wiki.ros.org/mavros
- MAVLINK: https://mavlink.io/
- Gazebo: http://gazebosim.org/
- PX4 development guide:https://dev.px4.io/en/