Tuesday, March 10, 2009

Project Flying Robot: By Your Command

Our flying_robot project for Unmanned Aerial Vehicles has been underway for a few weeks now. Much soldering, and playing around with cool Arduino tricks has been taking place. You can read more here, here, here, and here if you need to catch up.

One aspect that I have mentioned several times, but not gotten into much detail about, is our protocol for communicating with the UAV from the ground station. It is amazing to me, but there is still no dominant digital protocol for controlling UAV's. Many people are this using analog radio controllers, with some kind of sideband channel for autopilot commands.

There are a few characteristics that seem essential to me for a proper ground control system design:
  • A nice way to send control stick commands from a "virtual r/c" that can be used with any UAV

  • Consistent way to send autopilot commands

  • A way to be able to read the instruments remotely, and display them as part of your "control surface"


Another observation I have, is that there is every current Arduino UAV project has an entirely different code base. There also does not seem to be any practical way for these projects to share much, even though they are all targeting the same microcontroller.

Certain characteristics seem essential for developing on-board UAV system programming, but are lacking in any of the projects I was able to find:
  • A nice, modular way to put together the pieces you need in software that match the hardware configuration for that particular vehicle

  • A high-level domain specific language (DSL) to specify the UAV's behavior, and not just programming in C++ or assembly language

  • A consistent programming interface that corresponds to the protocol used by various ground controllers


With all of these design criteria in mind, I have been implementing the flying_robot command parser and interface. Here is an example of the minimum code required to create a UAV using the current implementation:

# Example code for flying_robot
# Uses Ruby Arduino Development to create a library/interface for Unmanned Aerial Vehicles
# Written by Ron Evans (http://deadprogrammersociety.com)
#
# In order to implement a sketch that uses the flying_robot parser, you need to implement the methods that make up its interface
# so that it will respond to the standard command set.
#
# The following commands are supported:
# (h)ail - See if the UAV can still respond. Should send "Roger" back.
# (s)tatus - Grab a snapshot of all instrument readings plus any other status info that the UAV can support
# (e)levators - Set the elevators. The command supports two parameters:
# direction - enter 'u' for up, 'c' for centered, or 'd' for down
# deflection - enter an angle between 0 and 90 degrees
# (r)udder - Set the rudder. This command supports two parameters:
# direction - enter 'l' for left, 'c' for centered, or 'r' for right
# deflection - enter an angle between 0 and 90 degrees
# (t)hrottle - Set the throttle. This command supports two parameters:
# direction - enter 'f' for forward, or 'r' for reverse
# speed - enter a percentage from 0 to 100
# (i)nstruments - Read the current data for one of the installed instruments on the UAV. This command supports one parameter:
# id - enter an integer for which instrment readings should be returned from. If there is not an instrument installed
# for that id 'Invalid instrument' should be returned
#
class FlyingExample < ArduinoSketch
serial_begin :rate => 9600
# main command loop, required for any arduino program
def loop
be_flying_robot
process_command
end
# flying robot interface, implement these for your own hardware set
def hail
serial_println "Roger"
end
def status
serial_println "Status: operational"
end
def elevators
print_current_command("Elevators", current_elevator_deflection)
end
def rudder
print_current_command("Rudder", current_rudder_deflection)
end
def throttle
print_current_command("Throttle", current_throttle_speed)
end
def instruments
serial_print "Instruments command - request:"
serial_println current_command_instrument
end
end
view raw gistfile1.rb hosted with ❤ by GitHub


As you can tell, there is not all that much to it. The base for a UAV in 34 lines of code.

The most current code for the actual "Rogue 1" LTA vehicle is being committed to http://github.com/deadprogrammer/flying_robot_rogue_one/tree/master if you want to follow along with our progress.

Next post, we test the main thrusters and vectoring controllers, and nearly start a fire...

No comments: