Skip to content

TCHS-aero/fly

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

95 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TCHS SUAS

Welcome to the TCHS Aero's main drone team repository! This project contains the core code, resources, and documentation for our team’s participation in SUAS (Small Unmanned Aerial Systems) competitions.

Table of contents:

Categories What's shown?
Setup Setup/Installation instructions.
Usage How to use this repository.
Simulation Guide to using the Simulation.
How does SITL work? Explains how the PX4 Software In The Loop Works.
Used Packages All packages used in this repo.

This repository is a python module; thus, setting it up is simple.

  1. Install git.

    Arch Linux
    1. Install using pacman. Sudo is required.

      sudo pacman -Sy git
    Debian/Ubuntu
    1. Install using the apt package manager. Sudo is required.

      sudo apt install git
    MacOS
    1. Make sure you have brew installed. If not, install it.

      /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
    2. Install git.

      brew install git
  2. Clone this repository.

    git clone https://github.com/TCHS-aero/fly/ fly; cd fly

To use this script, it is recommended for development to install this repository as an editable python module.

pip install -e .

Uninstalling it as simple as removing the fly module.

pip uninstall fly

Now, you can run any script/interface by running it's binary. It should automatically be aliased.

# Here is an example of running the CLI.
aero_cli
# Here is how to run our GUI
aero_gui

Alternatively, you can run it using the module path.

python -m fly.interfaces.cli #for running the cli
python -m fly.interfaces.gui #to run the gui

For the sake of simplicity, the rest of the examples will be using the former method.

Caution

When using an operating system such as Arch Linux, install your pip packages through a virtual environment to avoid system-wide python conflicts. While rare, it does happen because Arch uses python for some of it's core scripts. Virtual environments must be initiated to use their installed pip packages.

The CLI and GUI is compatible with the simulation by default with very little configuration, but some additional setup is requried for real flights. Simply running the drone simulation will forward two ports, udp://0.0.0.0:14540 and udp://0.0.0.0:14550. All you need to do is connect to one of these ports.

# The "--port" flag is an optional setting, and is mainly used for actual drones. Ignoring it defaults the connection to 14540.
aero_cli connect --port udpin://0.0.0.0:14540

Note

Port 14550 can be used to talk to the drone, however it is recommended to use 14540 instead, as 14550 is the default port that QGC listens to. You cannot have two connections bound the same port at a time.

On the actual flight, it is not as simple as connecting to 14540. You must find the port specifically connected to your PixHawk configuration on your flight device. This varies depending on what telemetry radio you are using.

Unix Filesystems

You can find plugged USB's with the command lsusb -t.

# Replace "ttyUSB0" with whatever USB port your telemetry radio is plugged in.
# If you have a differently configured BAUD rate for your pixhawk, change "57600" to said rate.
aero_cli connect --port serial:///dev/ttyUSB0:57600
Windows
# Replace "COM3" with whatever USB port your telemetry radio is plugged in. You can find your COM port via Device Manager.
# If you have a differently configured BAUD rate for your pixhawk, change "57600" to said rate.
aero_cli connect --port serial://COM3:57600 

Note

Typically you'd use 57600 BAUD for offboard control, and 921600 BAUD for Ground Control or helper apps such as QGroundControl

This repository uses PX4 and MAVSDK-python to connect to the drone. In order to use these scripts in a simulation, you must first install the neccessary software. There are multiple simulators we can choose from, but for this project we use JMavSim, a drone simulator built in Java. JMavSim comes with plenty of keyboard bindings for altering things such as the weather conditions, as documented here.

  1. Clone the PX4-Autopilot repository.

    git clone https://github.com/PX4/PX4-Autopilot; cd PX4-Autopilot
  2. Execute the setup script for your operating system. This should automatically install all required dependencies.

    Arch Linux
    1. This script installs applications through pacman, meaning you need sudo privilages.

      bash Tools/setup/arch.sh
    Debain/Ubuntu Linux
    1. Install dependencies.

      sudo apt-get install ant
    2. This script installs applications through apt, meaning you need sudo privilages.

      bash Tools/setup/ubuntu.sh

    The Ubuntu setup script sometimes skips over the ant install silently, so make sure you have both ant and atleast openjdk-17-jdk installed.

    MacOS
    1. The --sim-tools flag must be specified when using the MacOS setup script.

      bash Tools/setup/macos.sh --sim-tools

Important

This script also installs python packages through pip. It will use the system-wide version of python if you do not have a virtual environment enabled. If you have a virtual environment running in the same shell as you run this script, it will use the virtual environment instead. This may be preferred for some arch users.

  1. Restart your computer.

  2. Make PX4 SITL (Software In The Loop) and JMavSim

    make px4_sitl jmavsim

You may also want to use your simulation alongside an application such as QGroundControl. All you have to do is run it, and it will automatically connect.

Important

If you previously ran the make command before installing dependencies, it may have caused a build error, resulting in px4_sitl or JMavSim not being found. Make sure to run make distclean to revert the build before making again.

Tip

The simulation is not required to use any other scripts in this repository; it is a simple replacement for testing if you do not have access to a real drone.

PX4 SITL is a way to run the PX4 flight-control firmware on your computer instead of on a real drone. PX4 runs as a normal program, and the simulator (like Gazebo or jMAVSim) gives physics and sensor readings such as GPS and IMU data. PX4 interprets this, computes any processes or calculations that need to be done, then sends it back to the simulation for the next update. SITL and the simulator talk using MAVLink over UDP, which also allows tools like QGroundControl to connect just like they would to a real drone. This makes it safe and easy to test flight behavior, missions, and code changes without needing any physical hardware or risking a crash.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors