Programming Drones Yu David Liu
Drones in the News
Drones in the News
Drones in the News
Unmanned Aerial Vehicle (UAV) Drones are more technically called UAVs A flying computer! For historical reasons, the boundary between hardware and software in existing UAV systems is often blurred, and the boundary between system software and application software is blurred as well For this talk, we will focus on an open hardware-software UAV system, Paparazzi http://wiki.paparazziuav.org/wiki/Main_Page
Fixed Wing vs. Multi-Rotor Drones Source: https://www.auav.com.au/articles/drone-types/
Overview two-way data one-way control
Paparazzi UAV Main Autopilot Board Sensors Datalink Radio Modem Attitude sensor (infrared) Inertial measurement (acceleration, rotation) Airspeed sensor Pressure sensor Datalink Radio Modem RC Receiver Actuators (movement and control) Propulsion system GPS Receiver Batteries Payload (Camera, Video recorder, etc)
MicroJet Example Autopilot Control Board Motor & Controller Battery Datalink Radio-Modem & Antenna GPS Receiver IR Sensor Motor & Controller RC Receiver & Antenna Servos (actuators) Payload
Terms: Roll, Pitch, Yaw
Paparazzi Programming Paparazzi programming comes in several layers: On the highest level, there is a GUI, a user-friendly way to set configurations of your aircraft and your flight information Under the GUI, most configuration information is textually represented as XML files Under the GUI/XML, the real flight control programs are written in C, with glue code written in ML and Python
Configurations Airframe XML File: autopilot parameters (e.g. hardware component settings) Flight Plan XML File: flight behavior definitions Radio XML File: RC transmitter behaviors (manual control) Telemetry XML File: data messages and transmission rate definitions Settings XML Files
A Typical UAV Program: Flight Plan A typical UAV program describes the duration of flying a UAV through a sequence of points in physical space and completing a series of flying tasks Key questions: How to define points in physical space? (“waypoints”) How to describe flying tasks? (“blocks”)
Flight Plan Part I: Waypoint A waypoint is a reference point in physical space used for purposes of navigation Conceptually, it’s like a coordinate in the 3D space In modern aviation industry: There are multiple established ways to represent such points For real airlines, waypoints are typically abstract and nicknamed (just as you often say “our university is located at exit 7 of I-81 north” instead of “longitude 101E, latitude 33N.”)
A Real-World Flight Plan Example http://www.fscommander.com/flightplan.htm
2D Waypoint through Latitude/Longitude Latitude 0: Equator Longitude 0: Prime Meridian Example: 42.1022° N, 75.9117° W (where is this?)
The Third Dimension of Waypoint Absolute: “altitude,” usually represented as Meters above Sea Level (MSL) Relative: “height,” usually represented as the difference in altitude from ground altitude
Paparazzi Waypoint Examples
Flight Plan Part II: Stages/Blocks A flight plan is composed of a sequence of stages Logically, each stage defines a unit of the flying mission, such as take-off, landing, circling, etc The stages are enclosed in a pair of blocks tags. Each stage is defined through a block tag.
Blocks Example <blocks> <block name="Wait GPS"> <set value="1" var="kill_throttle"/> <while cond="!GpsFixValid()"/> </block> <block name="Geo init"> <while cond="LessThan(NavBlockTime(), 10)"/> <call fun="NavSetGroundReferenceHere()"/> <block name="Holding point"> <attitude roll="0" throttle="0" vmode="throttle"/> </blocks>
The Semantics of Blocks As it turns out, the blocks construct is as expressive as a procedural language Order matters: the blocks are executed in sequence following the order of block definition Program behavior is undefined after the last block is completed You will see familiar features from procedural languages, such as “while” and “for” and “call” and “set” (guess what they mean!)
The Semantics of Blocks (Cnt’d) Control flow can be altered when “exception” is thrown: <block name=”X” > <exception cond="GetPosAlt() > ground_alt+25" deroute= “Y"/> … </block> <block name=”Y” > “deroute” is similar to “goto” when the “cond” of the “exception” is true
Terms: Flying Cycle Take-off Climb Cruise Descent Approach Landing Go-Around (aborted landing)
Basic Waypoint Navigation: Go <go wp="HOME"/> Navigate to the waypoint “Home” May lead to altitude change if the waypoint to go to may have a different altitude Control flow goes to the next stage once “Home” is reached
Basic Waypoint Navigation: Go <go from="wp1" wp="wp2" hmode="route"/> Navigate from waypoint “wp1” to “wp2” with a linear route in between
Basic Waypoint Navigation: Go <go from="wp1" wp="wp2" hmode="route" pitch="auto" throttle="0.75" alt="ground_alt+100"/> Navigate from waypoint “wp1” to “wp2” with a linear route in between, with a fixed level of throttle, and overrides the target waypoint’s altitude with “ground_alt+100”
Terms: Throttle An aircraft needs power in the engine to perform flying tasks, such as take-off and maintaining speed. The level of power is called throttle The throttle value is between 0 and 1 Obviously, for different flying tasks, the level of throttle is different
Basic Waypoint Navigation: Go <go from="wp1" wp="wp2" hmode="route" vmode="climb" climb="1.5"/> Navigate from waypoint “wp1” to “wp2” with a linear route in between, with a fixed level of climb speed (1.5 meters per second)
Basic Waypoint Navigation: Go <go from="wp1" wp="wp2" hmode="route" approaching_time="1"/> Navigate from waypoint “wp1” to “wp2” with a linear route in between, with a duration of 1 unit of time
Basic Waypoint Navigation: Circle <circle wp="HOME" radius="75"/> Circle clock-wise around waypoint “HOME”, with a radius of 75 meters
Basic Waypoint Navigation: Circle <circle wp="HOME" radius=”-75"/> Circle counter-clock-wise around waypoint “HOME”, with a radius of 75 meters
Basic Waypoint Navigation: Circle <circle wp="HOME" radius=” 50+(GetPosAlt()-ground_alt)/2” vmode="throttle" throttle="0.75" pitch="15”/> Circle and climb clock-wise around waypoint “HOME”, with an expanding radius
Example: Take-Off <block name="Takeoff” > <exception cond="GetPosAlt() > ground_alt+25" deroute="Standby"/> <set value="0" var="kill_throttle"/> <set value="0" var="autopilot_flight_time"/> <go from="HOME" throttle="1.0" vmode="throttle" wp="CLIMB" pitch="15"/> </block>
Example: Land <block name="land"> <call fun="nav_compute_baseleg(WP_AF, WP_TD, WP_BASELEG, nav_radius)"/> <circle radius="nav_radius" until="NavCircleCount() > 0.5" wp=”WP_BASELEG"/> </block> <block name="final"> <exception cond="ground_alt + 10 > GetPosAlt()" deroute="flare"/> <go from="AF" hmode="route" vmode="glide" wp="TD"/> <block name="flare"> <go approaching_time="0” hmode="route" throttle="0.0" vmode="throttle" wp="TD"/> <attitude roll="0.0" throttle="0.0" until="FALSE" vmode="throttle"/>
Acknowledgments Paparazzi website Bhavin Desai, exploratory studies Wikipedia Images of news articles are from Google News
Terms: Course, Track, Heading Course is the angle that the intended path of the UAV makes with a fixed reference object (typically north). Course is measured in degrees from 0° clockwise to 360° in compass convention (0° being north, 90° being east). Track is the actual path over the ground (ideally the course) Heading is the direction the UAV has to point in order to achieve its course (course and heading may differ because of e.g., wind)
Terms: Vertical Control Modes Specified by the vmode attribute in Paparazzi Can be one of the four: Throttle mode (vmode = “throttle”): specifying the desired throttle, with speed implicitly determined Speed mode (vmode = “climb”): specifying the desired (climb) speed (meter/second), with throttle level implicitly determined Maintain altitude mode (vmode = “alt”): maintain the altitude specified by the waypoint (default) Glide mode (vmode = “glide”): maintain the slope between two waypoints
Terms: Horizontal Control Modes Specified by the hmode attribute in Paparazzi The most widely used one is “route”, which connects two way points