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.

Before deploying custom autonomous sessions onto your drone, practice flying with the built-in basic autonomy features of the MRS UAV System. These include two core functionalities and example sessions, which will form the foundation for your custom sessions.

MRS UAV SYSTEM

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

Before You Start

For this first autonomous flight, you will use one of the example sessions 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 and the calibration has not been performed. You will 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.

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, replacing <static_ip_of_the_drone> with the actual static IP address of your drone:

    ssh uav@<static_ip_of_the_drone>

    Refer to the Network page for more information on how to connect to the drone.

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
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.

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 are 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 image 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.

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 10m 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.