Connecting a Pixhawk to Raspberry Pi

3,038 views
Skip to first unread message

Randy Mackay

unread,
Feb 20, 2014, 8:58:52 AM2/20/14
to drones-...@googlegroups.com

 

     I’ve added a wiki page on how to connect a Raspberry Pi to a Pixhawk using MavLink / MavProxy.

            http://dev.ardupilot.com/wiki/raspberry-pi-via-mavlink/

 

     ..I wasn’t actually quite able to get the two to communicate although I can see the characteristic MAVLink garble appearing on the RaspberryPi end of the connection.  Perhaps the baud rate is incorrectly set (I’ll probably work this out with Tridge tomorrow).

 

     This might be useful in case someone attempts to use a Raspberry Pi + camera to target the balloons in this year’s Sparkfun competition.

 

     There are other boards and probably other methods of doing the communication but this is the board I have and the method that first came to mind for me.  All feedback welcome.

 

-Randy

Erik V

unread,
Feb 27, 2014, 5:45:33 AM2/27/14
to drones-...@googlegroups.com
Hi !

First af all, sorry for my english.

I used your wiki ( easy to understand ! thanx) to communicate from a Raspberry to the Pixhawk and it works well ! I can get and set parameters for the Pixhawk.
Now I'm trying to send simple movement commands, I used a XTion (like kinect) embeded on the drone. But I can not find any commands that work to get some reaction from the drone !
I tried different modes and read all Mavproxy's documentation... but nothing works.

Do you have some examples of commands to get the drone moving ?

best regards

Erik

Randy Mackay

unread,
Feb 27, 2014, 7:19:43 PM2/27/14
to drones-...@googlegroups.com

Erik,

 

     Great, glad that the page has been useful.

 

     So you can override the rc inputs using commands like this:

            rc 3 1200          ß this will raise the throttle slightly.  It uses the same range as you’ve set up with the radio calibration through the mission planner so it depends on your setup a bit.  Normally around 1500 is mid throttle, 1900 or 2000 is full throttle.  1000 is off.

            rc 1 1700         ß will make the copter roll right

            rc 2 1700         ß will make the copter pitch back

 

     You can change the flight mode in a couple of ways.  Some flight modes are coded in so I think for example you can enter rtl and it will switch to RTL mode.  Some are not supported though in which case you need to override the flight controller’s flight mode switch.

        switch 0    ß will switch the flight mode to the mode held in the FLTMODE1 parameter.  This is the top item on the Flight mode set-up screen in the mission planner.  

 

     One thing not yet discussed on that page is how to take back control from the RPi.  There is a way (because all the android GCSs use it) but I don’t actually know what it is yet.

 

     I imagine you’re doing your testing indoors so I’d say you should stick with stabilize and AltHold flight modes.  Also make sure that your throttle failsafe and geofence are disabled, you may even want to disconnect the GPS if you’re indoors.

 

    Best of luck.

 

-Randy

--
You received this message because you are subscribed to the Google Groups "drones-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to drones-discus...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Randy Mackay

unread,
Feb 27, 2014, 7:36:20 PM2/27/14
to drones-...@googlegroups.com

Erik

 

      Kevin Hester (creator of the ArduPilot app and much more)  has told me that it should be possible to return control to the pilot’s transmitter by sending zero for all channels:

rc 1 0

rc 2 0

rc 3 0

…

rc 8 0

    

     We should add a way to allow the pilot to yank control away from the RPi but we don’t have that yet (it’s on the to-do list).

 

-Randy

 

From: Randy Mackay [mailto:rmac...@yahoo.com]
Sent: February 28, 2014 9:20 AM
To: 'drones-...@googlegroups.com'
Subject: RE: [drones-discuss] Re: Connecting a Pixhawk to Raspberry Pi

 

Erik,

 

     Great, glad that the page has been useful.

 

     So you can override the rc inputs using commands like this:

            rc 3 1200          ß this will raise the throttle slightly.  It uses the same range as you’ve set up with the radio calibration through the mission planner so it depends on your setup a bit.  Normally around 1500 is mid throttle, 1900 or 2000 is full throttle.  1000 is off.

            rc 1 1700         ß will make the copter roll right

            rc 2 1700         ß will make the copter pitch back

 

     You can change the flight mode in a couple of ways.  Some flight modes are coded in so I think for example you can enter rtl and it will switch to RTL mode.  Some are not supported though in which case you need to override the flight controller’s flight mode switch.

        switch 0    ß will switch the flight mode to the mode held in the FLTMODE1 parameter.  This is the top item on the Flight mode set-up screen in the mission planner.  

 

     One thing not yet discussed on that page is how to take back control from the RPi.  There is a way (because all the android GCSs use it) but I don’t actually know what it is yet.

 

     I imagine you’re doing your testing indoors so I’d say you should stick with stabilize and AltHold flight modes.  Also make sure that your throttle failsafe and geofence are disabled, you may even want to disconnect the GPS if you’re indoors.

 

    Best of luck.

 

-Randy

 

From: drones-...@googlegroups.com [mailto:drones-...@googlegroups.com] On Behalf Of Erik V
Sent: February 27, 2014 7:46 PM
To: drones-...@googlegroups.com
Subject: [drones-discuss] Re: Connecting a Pixhawk to Raspberry Pi

 

Hi !

--

Kevin Hester

unread,
Feb 27, 2014, 7:47:18 PM2/27/14
to drones-discuss
also: You should only really override channels you _need_ to override - so that the RC can control any of the other channels.  

If you want to make your RPi code 'safe' (ish): You should never override the channel used for RC mode control (7 or whatever).  In your RPi code you should monitor the current vehicle mode (as sent periodically in the heartbeat msg).  If you see the mode change to some mode that you did not select (i.e. the user freaks out and toggles the RC switch to STABILIZE or whatever...) then you should cancel all of your overrides until the vehicle is back in a mode where your app expects to be the driver (probably AUTO or GUIDED)

(when I start in earnest on the API project (March 9) the python lib in that project should make this all much easier)

Erik V

unread,
Feb 28, 2014, 9:15:47 AM2/28/14
to drones-...@googlegroups.com
It WORKS !! \o/

I had already try these cmd but with your help i tried again and everything work ! Thanks a lot !
For other people, juste follow the wiki ( http://dev.ardupilot.com/wiki/raspberry-pi-via-mavlink/), hold the safety button to arm, and enter "arm throttle" in mavproxy, change mode as you want.
 
Juste I don't know why sometimes it disarmed by itself ? it's because of the mode ?

Erik

Erik Vanhoutte

unread,
Feb 28, 2014, 11:26:34 AM2/28/14
to drones-...@googlegroups.com
oups ! Sorry, it's just because when the Throttle value is minimum (1100 for me), the pixhawk is automatically disarmed.


--
You received this message because you are subscribed to a topic in the Google Groups "drones-discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/drones-discuss/gT9vSoHYTZ8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to drones-discus...@googlegroups.com.

Nicolas-Michael El Jamal

unread,
Mar 9, 2015, 3:38:15 AM3/9/15
to drones-...@googlegroups.com
Hey all, 

This is just to ask you if someone managed to control a quadcopter by overriding the RC channel. I was able to override the channel but I didn't test it with propellers yet.
One more question: is it possible to do the following in a c/c++ code:

//Image processing code...

system("mavproxy.py mavproxy.py --master=/dev/ttyAMA0 --baudrate 57600 --aircraft MyCopter --cmd rc 2 1500");
system("kill");
//wait for 2 seconds
system("mavproxy.py mavproxy.py --master=/dev/ttyAMA0 --baudrate 57600 --aircraft MyCopter --cmd rc 2 -1");

I don't know if this might work, but the purpose of this code is to get information from the image processing code and move for instance to the right. Do you think that will be efficient?

Thank you!

Cheers!

Kevin Hester

unread,
Mar 9, 2015, 12:59:45 PM3/9/15
to drones-...@googlegroups.com
Yes, you can send rc-overrides similar you describe, but almost always there are better ways.  Sending rc channel values like that are really missing many of the more automated sort of control that you can get by sending nav commands etc...

I suspect rather than firing up a series of mavproxy processes you'd be much happier with something like this: http://dev.ardupilot.com/wiki/droneapi-tutorial/

You received this message because you are subscribed to the Google Groups "drones-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to drones-discus...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages