Skip to main content

Autonomous Flight

Follow this step-by-step guide to fly autonomously with your drone. While some steps are universal across products, others may vary depending on your specific model. Use the tabs to select the guide tailored to your product.

Feeling Lost?

Head back to your Product page and start with the initial steps outlined there. They’ll point you to the correct tutorial for your specific drone.

MRS UAV SYSTEM

This tutorial assumes that you have the MRS UAV System installed on your drone.

Current Product: None
Custom Instructions

Your drone may have custom instructions available. If so, they can be found under the 4. Custom Instructions chapter on the Product Page.

For this first autonomous flight, you will use the tmuxinator session that has been prepared for you. We also assume that you have been through all the previous tutorials in this chapter. Do not perform this autonomous flight if you did not fly the drone manually once.

The session that has been prepared for you is located in the example_session folder in the home folder of the drone.

We can now prepare the drone for the flight. We assume that the calibration has been made and that the drone is "ready to fly".

Additional Payload

If you plan to fly autonomously with an additional payload (e.g., different sensors, batteries, or extra equipment), it is crucial to update the drone's weight parameter. An incorrect weight configuration can lead to either a failed takeoff or an unsafe, excessive ascent. To prevent this, after adjusting the drone's payload, measure the new total weight (in kg), power on the drone, connect to it, and update the .bashrc file by modifying the line export UAV_MASS=XXX, replacing XXX with the new weight value.

Environment and Safety Area

Before any flight, it is important to check the environment for potential obstacles or danger.

The current "world" settings are configured to the place where we tested your drone. In order to define and use your own "world" file which will define which frame to consider for the drone odometry as well as the safety area, you have to create a new world_my_world.yaml file. You can copy a file from the example files located at roscd mrs_uav_deployment/config/worlds/. Check the different examples in this folder. Adapt your file by setting the correct latitude and longitude points of your safety area and origin. The frame name description can be found here but it is common to use latlon_origin for the horizontal coordinates and world_origin for the vertical ones.

Save this file to the roscd mrs_uav_deployment/config/worlds/ folder and in order to use is in your experiment you should edit the WORLD_NAME variable in the ~/.bashrc. Locate the variable and replace it by the my_world that you used in world_my_world.yaml.

Apply the change by sourcing this file:

source ~/.bashrc

Powering the Drone and Connecting to the Network

During the flight, the drone and your computer should be connected to the same network. Make sure to have your network coverage big enough to cover the flight area.

  1. Place the drone at the location which you want to be the center of the safety area. This location should be safe to take-off. The drone should be placed on an approximately leveled surface with a support below all legs.
  2. Make sure the RC is powered and all switches are pushed to their last position (away from you).
  3. Power the drone with the battery connected to a buzzer and turn on the computer. Make sure that you configured the drone to the correct network beforehand. It should automatically connect to the Wi-Fi you set up.
  4. Connect to the drone using ssh connection
    ssh uav@static_ip_of_the_drone

Connecting to ROS Core Remotely

Unlike the simulation framework, Rviz does not start on its own for the real world deployment. To use Rviz on your computer and have it connected to the ROS core running on the drone you should add a line to the .bashrc (or .zshrc) file on your computer in the home folder. Open this file and look for any existing ROS_MASTER_URI variable. Comment it out and add the following line

export ROS_MASTER_URI=http://<server-hostname>:11311
info

This command exports the environment variable ROS_MASTER_URI, so you don't need to set it manually every time when you open a new terminal.

The <server-hostname> should be specified in /etc/hosts on your computer, and <client-hostname> should be specified on the drone's computer. You should be able to ping one from another using just its hostname. If it is not specified on your computer and on the drone, please add it.

Launching the Session

Once logged inside the drone, it is a good practice to start the tmux session to check the 'status' tab and see that everything is working properly.

Remember

Since the safety button has not been pressed and the drone is not armed, it is ok to do so even with the propellers already on.

Within the terminal where the drone is connected, browse for the tmux session:

cd ~/example_session/

Then run the tmux session

./tmux.sh

Browse the different tabs of the main window to make sure there is no major issues (these are usually displayed in red). In a general manner, if there is an issue in the system, the boundaries of the rectangles of the 'status' tab (see imae below) will be colored in orange or red.

You can also check that your computer is connected to the ROS core running on the drone. Open a terminal on your computer (not another window/tab in the drone ssh session) and run the following command:

roslaunch mrs_uav_deployment rviz.launch uav{id_of_the_drone}

Rviz should start and you should be able to see the frames of the drone as well as the safety area.

Once you are done, you can kill the session using the binding CTRL button + A then K buttons and confirm with the "9" button. You are now ready for your first autonomous flight.

Autonomous Flight Procedure 🚀

For this first autonomous flight you also need a safety pilot that will be able to intervene if something is off during the flight. It is the pilot's responsibility to make sure that the drone is ready to fly by checking it visually but more importantly by performing a manual flight.

Launch the Tmux Session on the Drone

Similarly as before, we will start by running the tmux session. Within the ssh terminal, run the tmux session and check the 'status' tab.

./tmux.sh

Takeoff and Start Mission

Press the safety button until you hear the sounds indicating that the safety is off. Make sure that there is no object within a 10 m radius around the drone and no human closer than 15 m or any pre-specified safety distance (if you are flying outside).

RC Bindings

If you are not sure about your RC switches configuration, have a look to the RC page

Whenever you will arm the drone, you will have a few seconds to switch to Offboard mode so that the drone will autonomously take off. If you don't do it in time, the drone will by our default settings disarm itself. When you are in the Offboard mode, you can switch to the Position mode, so whenever the pilot need to take over by turning off the Offboard mode, drone will hover (if RC sticks are in the middle). We can decompose the whole procedure with the following steps:

  1. Make sure the RC is powered, connected to the drone and all switches are pushed to their last position (away from you).
  2. Arm the drone using the arming gesture you required (see the official website). The rotors should start spinning slowly.
  3. Switch to Offboard mode by toggling the Offboard switch to its first position (closest to you). The drone should start the takeoff procedure a few seconds after switching to Offboard mode.
Warning

If something happens during the flight, toggle the Offboard switch back out of the Offboard mode to take over manual control of the drone. Also you might want to have different positions of the Flight Mode switch (also called SC on most RC), which selects the mode of the control when you are not using the Offboard mode. However, be aware that if the GPS appears to be the problem (if you have a GPS), avoid using the Position mode.

After the takeoff, depending on what is configured in your session, you can navigate to the different tabs and start the nodes responsible for the autonomous mission on your drone. Please refer to the 4. Custom Instructions chapter on the Product page for more information.