ROS simulation and interface with DJI Mavic Air 2S (or others).
-
Requirements
- Ubuntu 20.04
- ROS Noetic and set up catkin workspace
- git lfs
-
Installation
-
Take a look at these tutorials to setup ardupilot, gazebo and the ardupilot gazebo plugin by Intelligent-Quads
-
Clone this repository
cd ~/catkin_ws/src git clone https://github.com/hayashilab/drone_sim.git catkin build echo 'export GAZEBO_MODEL_PATH=~/catkin_ws/src/drone_sim/models' >> ~/.bashrc source ~/.bashrc -
Launch the world
roslaunch drone_sim Beach_drone.launch -
Terminal drone command
mode guided #switch to GUIDED mode arm throttle #arm the drone takeoff z #take off to z meter position x y z #move to position x y z relative to previous position set yaw r 0 1 #rotate r degree relative to previous position -
Available scripts
Script Description Mavic_connection Establish connection between Mavic Air 2S and Python script, see [Drone-PC Interface](## Drone-PC Interface) Mavic_connection_sim Establish connection between Mavic Air 2S and Python script inside Gazebo simulation. get_sim_image Receive franes from drone camera inside Gazebo simulation in OpenCV format gazebo_spawn_object_simple Randomly spawn object inside Gazebo world ["beer","bowl","marble_1_5cm","plastic_cup","wood_cube_7_5cm","wooden_board"]
-
vehicle.commands.upload() is commented out in utils/drone_utils.py, so the mission is never sent to SITL. Uncomment it to fix.
The spawn z-height in gazebo/SIM_model_handler.py needs to match the terrain:
- Hokuto:
initial_pose.position.z = 5.0(beach terrain sits at z=2) - Kyutech:
initial_pose.position.z = 0.5
There are 4 files to update when switching environments. All changes are listed below.
| Environment | Value |
|---|---|
| Hokuto | -l 33.853112,130.501569,0,300 |
| Kyutech | -l 33.655187,130.673922,0,300 |
# Hokuto (current)
xterm -e sim_vehicle.py -v ArduCopter -f gazebo-iris -l 33.853112,130.501569,0,300 --console
# Kyutech
xterm -e sim_vehicle.py -v ArduCopter -f gazebo-iris -l 33.655187,130.673922,0,300 --console# Hokuto (current)
mission_file = 'missions/hokuto_mission.txt'
# Kyutech
mission_file = 'missions/kyutech_mission.txt'/spawn_objects route — change the area passed to init_spawn_objects:
# Hokuto
init_spawn_objects(model_names, beach_area, model_path_prefix, object_count)
# Kyutech
init_spawn_objects(model_names, kyutech_area, model_path_prefix, object_count)gazebo/SIM_model_handler.py — change spawn z-height to match terrain:
# Hokuto (beach terrain sits at z=2)
initial_pose.position.z = 5.0
# Kyutech
initial_pose.position.z = 0.5/show_map_result route — change tif path and coordinates:
# Hokuto
model_positions, track_positions, image_data = map_result(Hokuto_tif_path, latest_db, 33.85315582, 130.50159024)
# Kyutech
model_positions, track_positions, image_data = map_result(Kyutech_tif_path, latest_db, 33.655187, 130.673922)| Environment | Command |
|---|---|
| Hokuto | roslaunch drone_sim beach_drone.launch |
| Kyutech | roslaunch drone_sim kyutech_drone.launch |
| Hokuto | Kyutech | |
|---|---|---|
| Launch file | beach_drone.launch |
kyutech_drone.launch |
| World | worlds/Hokuto.world |
worlds/KyutechField.world |
| Mission | missions/hokuto_mission.txt |
missions/kyutech_mission.txt |
| SITL coords | 33.853112, 130.501569 |
33.655187, 130.673922 |
| Map origin | 33.85315582, 130.50159024 |
33.655187, 130.673922 |
| Waypoints | 15 | 11 |
-
Follow instruction to install Rosettadrone.
-
Clone or download the repository.
git clone https://github.com/OpenDroneMap/WebODM.git -
In Android Studio, select File->New->Import Project and navigate to the downloaded folder.
-
Sign up for the DJI Developer Program at https://developer.dji.com/mobile-sdk/ and create an Application key. The package name should be sq.rogue.rosettadrone.
-
Generate Google Maps API key using instructions at https://developers.google.com/maps/documentation/javascript/get-api-key#creating-api-keys
-
Create a new file called keys.xml in the /app/src/main/res/values/ folder, and insert the following:
<?xml version="1.0" encoding="utf-8"?> <resources> <string name="dji_key">INSERT KEY HERE</string> <string name="google_key">INSERT KEY HERE</string> </resources> -
Run Build->Make Project
-