Pixhawk + ODROID + MAVLinkAutoPylot

3689660571?profile=original

After we demoed a little five-channel "AutoPylot" program on a Naze32 with ODROID companion board, our friends at A2USA, Inc . asked us whether we could do the same for the Pixhawk that they use for flying their big birds.  We started modifying our MSPPG parser generator to output MAVLink messages, but soon stumbled across some awesome gists by Christopher Vo  that showed a better way, using Tridge's pymavlink.mavutils library.  Thanks to their work, we were able to create a little Python class that automates much of the programming.  


As with our ARDroneAutopylot and PyQuadSim packages, the autopilot kicks in when you hit a switch (default = channel5, which I've configured as SC on my Taranis), and automatically calls a Python method that you write, which returns the other four RC channel overrides (pitch, roll, yaw, throttle).  By overriding the getChannelsPos1() and getChannelsPos2() methods, you can create two different automated behaviors based on the two non-default switch positions.  Our code includes a simple example that you can run from an ordinary computer, where getChannelsPos1() cycles the throttle up and down, and getChannelsPos2() cycles the roll.  To help avoid accidents, these methods will not get called until the switch has first been reset to its default position.  Because our goal is to put this code on an ODROID to support missions like the one simulated in this video, we have also included an ODROID-specific copy of this example in the repository.

To run on ODROID, you'll need an inexpensive Pixhawk telemetry cable from 3DR and a level-shifter board  to step up the ODROID 1.8v UART to the 5v required by the Pixhawk's telemetry ports.  (We followed advice from A2USA about not using the simpler USB connection, whose rigid cable can transmit vibrations from the ODROID to the Pixhawk).   Our video shows us using an older level shifter on a breadboard, but as soon as our new level shifter arrives from Sparkfun, we'll make up a little cable to go directly from the ODROID to the Pixhawk through the shifter. The video also shows 5v power from a Castle Creations CC BEC, but on an actual vehicle the 5v would likely come from the BEC output of one of the Electronics Speed Controller (ESC) units. We're going into the Pixhawk through its TELEM 2 port, so TELEM 1 can be used for the 3DR Radio talking to Mission Planner on our Windows box.  

WARNING:  We have not flight-tested this system and will doubtless encounter bugs once we do.  Obviously you should (1) know how to program in Python and (2) thoroughly bench-test your autopilot solution before flying.

E-mail me when people leave their comments –

You need to be a member of diydrones to add comments!

Join diydrones

Comments

  • Hi nice post!!

    I want to connect an odroid XU4 to pixthauk and I want to try UART -UART.

    If you have some kind of schematics of uart - uart connection it will be very usefull just to check and avoid a posible wiring mistake.

    Thank you!!

     

  • @Ben: yes, pretty much.  But ODROID can do lots more than collision-avoidance.

  • Interesting, is ODROID to augment a potential collision avoidance system processing power, while the Pixhawk takes care of the flight controls?

  • Once again, I appreciate your encouragement Randy!  This is a really supportive and enthusiastic community.

    As for FTDI cables: yeah, been using 'em for a couple of years, but wanted to try the direct UART on the ODROID. Partly just to see whether I could do it ;^), and partly because we'd found that the ODROID's USB can get overwhelmed when you plug in more than one perhipheral (currently we're going with a webcam, which I'm guessing his a pretty high current draw).

    Also appreciate the tip about guided mode.  That's what A2USA guys suggested, too.  As you suggest, what I've done with this little library is just the tip of the iceberg of what you can do with mavutils, I think!

  • Developer

    Looking good.

    Good advice from A2USA not to use the usb connection.  The reason is that there's a side effect that battery failsafe and EKF failsafes will be disabled because the code assumes the vehicle thinks it's being benchtested if the USB cable is connected.

    In the past when I've connected an Odroid to a Pixhawk I used a USB-to-serial converter.  It's labelled as an "ftdi cable" on this setup wiki page which is perhaps not quite correct.

    Also, I can't speak for planes but for copters, I find the best way to control the vehicle is through Guided mode.  The odroid "companion computer" can send all kinds of mavlink commands to change it's mode, provide position and velocity requests, etc.  It's even possible to take commands from the odroid during some defined periods during a mission using the "NAV_GUIDED" mission command.

    Anyway, it's interesting what you're doing.

This reply was deleted.