After this README file, you should be able to run an autonomous mission of the drone (take off, object detection and descend, pickup, dropoff and landing without coverage planning) as seen in this video.
- Ubuntu 16.04 LTS
- ROS Kinetic
- Assuming you use catkin build system
- Gazebo 7.14
- OR You can use download and run this script here:
- Download and save it
- Go to the location that you saved
- Run
source ubuntu_sim_ros_gazebo.sh
This simulation is based on OpenUAV project.
- In your home directory create a
srcfolder by typingmkdir srcin your terminal - Go to the src folder
cd src - Clone all git repositories in OpenUAV to this folder by
git clonecommand - Go to the
Firmwarerepository by typingcd Firmware source setup-install.sh(press Return to continue when asked)- When it finishes, type
make posix_sitl_default - Then run Gazebo by typing
gazeboin your terminal - Connect the
sitl_gazebofolder with yourcatkin_ws/srcfolder by typingsudo ln -s ~/sitl_gazebo ~/catkin_ws/srcin your terminal - Connect the
src/Firmwarefolder with yourcatkin_ws/srcfolder by typingsudo ln -s ~/src/Firmware ~/catkin_ws/srcin your terminal - Go to your
catkin_ws/srcfolder (cd ~/catkin_ws/src) and build it by typingcatkin buildin the terminal. - Type
source devel/setup.bash - Now do the following to configure your ROS environment:
roscdcd ..cd src/Firmwaremake posix_sitl_defaultsource ~/catkin_ws/devel/setup.bashsource Tools/setup_gazebo.bash $(pwd) $(pwd)/build_posix_sitl_defaultexport ROS_PACKAGE_PATH=$ROS_PACKAGE_PATH:$(pwd)export ROS_PACKAGE_PATH=$ROS_PACKAGE_PATH:$(pwd)/Tools/sitl_gazebo
- Open a terminal and type:
roslaunch px4 posix_sitl.launch - Open a terminal and type:
roslaunch mavros px4.launch fcu_url:="udp://:14550@127.0.0.1:14557"Make sure there is no error in this launch. You can then close terminate the terminals.
Clone the repository as to your home: git clone https://github.com/CPS2018/Simulation_F651.git
-
Open a terminal and type
printenv | grep GAZEBO -
Two or more paths should be displayed:
GAZEBO_MODEL_PATH=:/home/user/src/Firmware/Tools/sitl_gazebo/models:/home/user/catkin_ws/src/simulation_control/src/modelsGAZEBO_PLUGIN_PATH=:/home/user/src/Firmware/Tools/sitl_gazebo/Build(Gazebo gets it's models in this case from two paths which are told apart by the:sign.) -
Add the file
gripper_plugin.ccin the folder one step up from yourGAZEBO_PLUGIN_PATH. In this case, it would be/home/user/src/Firmware/Tools/sitl_gazebo/src -
Add the following lines under plugins to the
CMakeLists.txtfile located at/home/user/src/Firmware/Tools/sitl_gazebo/srcfind_package(roscpp REQUIRED)
find_package(std_msgs REQUIRED)
include_directories(${roscpp_INCLUDE_DIRS})
include_directories(${std_msgs_INCLUDE_DIRS})
find_package(gazebo REQUIRED)
include_directories(${GAZEBO_INCLUDE_DIRS})
link_directories(${GAZEBO_LIBRARY_DIRS})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GAZEBO_CXX_FLAGS}")
add_library(gripper_plugin SHARED src/gripper_plugin.cc)
target_link_libraries(gripper_plugin ${GAZEBO_libraries} ${roscpp_LIBRARIES})
- Open a terminal and type the following:
cd ~/home/user/src/Firmware/Tools/sitl_gazebo/Build(GAZEBO_PLUGIN_PATH)cmake ../make
- Add the folder
simulation_controlto yourcatkin_ws/srcfolder. - Open a terminal and type the following to build the catkin workspace:
cd ~/catkin_wscatkin build
- Double check if you're missing any dependencies like
pyscietc. and install them if not. Then build again. - Open a terminal and type: (adding gazebo model path to bashrc)
sudo nano ~/.bashrc - In your bashrc, add the following line along with your GAZEBO_MODEL_PATH:
:/home/user/catkin_ws/src/simulation_control/src/models
For example if it looks like this:
export GAZEBO_MODEL_PATH=:/home/user/src/Firmware/Tools/sitl_gazebo/models
After editing it should look like this:
export GAZEBO_MODEL_PATH=:/home/user/src/Firmware/Tools/sitl_gazebo/models:/home/user/catkin_ws/src/simulation_control/src/models
- Add the file
f550_amazingto/home/user/src/Firmware/posix-configs/SITL/init/lpe
Open three Terminals:
roslaunch simulation_control posix_sitl.launchroslaunch simulation_control px4.launch fcu_url:="udp://:14550@127.0.0.1:14557"roslaunch simulation_control simulation_control.launch
If after making posix_sitl, Gazebo doesn’t launch and gives you a error message regarding geographiclib
Do the following:
- In your terminal type:
sudo apt-get install ros-kinetic-mavros ros-kinetic-mavros-extras - When that installation is ready type:
wget https://raw.githubusercontent.com/mavlink/mavros/master/mavros/scripts/install_geographiclib_datasets.sh./install_geographiclib_datasets.sh(you might have to make the install_geographiclib_datasets.sh executable.)
