<!-- TITLE: Controls --> <!-- SUBTITLE: System for interacting with drone actuators based off sensor data and mission plans --> # Description The controls team on UAS@UCLA deals with designing the commands framework and routing algorithms for accomplishing the inputted mission objectives. This system consists of a PX4 autopilot flight controller and a Raspberry Pi offboard computer running custom control code to send high-level commands to the PX4 when conducting a mission. # Documentation **Note:** Our team has already completed two technical documentation paper (for [Flappy 2017](http://www.auvsi-suas.org/static/competitions/2017/journals/auvsi_suas-2017-journals-university_of_california_los_angeles.pdf) and [Spinny 2018](http://www.auvsi-suas.org/static/competitions/2018/journals/auvsi_suas-2018-journals-university_of_california_los_angeles.pdf)) outlining all of the fundamental components that make our drones fly, so please check out those resources for an in-depth understanding about the platform we work upon. ## Avionics Wiring Layout (Spinny) ![Wiring Layout](/uploads/control/i-0-nqlk-8.jpg "I 0 Nqlk 8") This diagram outlines the power system and signal lines connecting the PX4 flight controller to the motors. It also showcases the communication links between the PX4 flight controller and the Raspberry Pi offboard computer running our custom control scripts. ## Multi-Process Software Layout and Distributed Networking (Spinny) ![Software processes layout](/uploads/control/4-z-4-bbxw.jpg "4 Z 4 Bbxw") This diagram outlines the main processes operating on the drone, and shows how they are linked using shared memory and inter-process messaging. Additionally, it shows the communication links to the groundstation via TCP socket transport. Communication between the PX4 flight controller and our custom control code on the Raspberry Pi is done using [MAVLink messages](http://mavlink.org/messages/common). In the case of simulations, the physical PX4 is replaced with a mock flight controller (running within a Docker image), which accepts and outputs all of the same messages that a real flight controller would relay. ## Mission Calculation, Message Format, and Synchronization ## Obstacle Avoidance ![Avoidance](/uploads/control/zrgnev-7.jpg "Zrgnev 7") # Training ## How do I get involved with controls? The controls team relies heavily on 3rd party frameworks, namely the [PX4 flight controller software suite](http://px4.io/). There are many tutorials online for how to get started with this platform, along with internal team projects that will teach the basics. Please refer to the projects/assignments section below for links to these. ## Environment Setup [See the software overview page](/fields/software/overview#setup) for getting a core platform installed for developing UAS@UCLA software. Also see the [Guide to Running Controls Code](/subsystems/controls/overview/running-code). ## Outside Readings ### Control Theory for Drones * [Drone coordinate systems and conventions](https://developer.dji.com/mobile-sdk/documentation/introduction/flightController_concepts.html) * [PID control](https://www.csimn.com/CSI_pages/PIDforDummies.html) * [Explaination of common flight controller modes](https://www.rotordronemag.com/flight-basics/) ### Autopilot details (PX4) * [PX4 General Reference](https://docs.px4.io/en/) * [PX4 Architecture Overview](https://dev.px4.io/en/concept/architecture.html) * [PX4 full parameter reference](https://dev.px4.io/en/advanced/parameter_reference.html) * Understand the difference between parameter prefixes, such as MC_* (attitude control), MPC_* (position control), PWM_* (output signal range setting), etc. * Consult [our team's spreadsheet for tracking parameters here](https://docs.google.com/spreadsheets/d/1bOL7nwof_8-NNWxbKCQ_claVRixw7kwrTH-azhR4wPQ/edit#gid=673229638) for more information about the meaning behind these configuration settings (and feel free to add additional notes as you learn what the parameters do) * [PX4 firmware source code](https://github.com/PX4/Firmware) for seeing how the firmware works internally * Suggestion: Clone that git repository, navigate to it using cd, and search for the parameter names above to see where they are referenced using "grep -r [[search string]]" * [Offboard computer setup with a PX4](https://dev.px4.io/en/ros/offboard_control.html) ## Projects * [Creating a mission with QGroundControl and Gazebo](/subsystems/controls/overview/gazebo-and-q-ground-control-simulation) * [Writing and running the python script](/subsystems/controls/overview/python-script-simulator) # Platforms and Libraries Used * [MAVLink Common Messages](http://mavlink.org/messages/common) for communicating between Ground Control Station and the UAV * [Bazel](https://bazel.build/), a C++ cross-compiler for the Raspberry Pi * [Gazebo](https://dev.px4.io/en/simulation/gazebo.html) for 3D simulation