Using Raspberry Pi with APM 2.6

Hi,

I asked this question here, but am not getting very many responses so I am trying on this forum.

http://ardupilot.com/forum/viewtopic.php?f=100&t=10919

A basic run-down of what I am trying to do. 


I was wondering if someone could point me in the right direction. I plan on using a APM 2.6 autopilot along with a Raspberry Pi with a CMOS camera connected for visual guidance. My main question is what is the best way to get the Pi and the autopilot to communicate with each other? Will USB work? If USB will not work is there a way to use the A pins for some type of serial communication with external devices like a UART? 

Once I have them talking is it possible for the Pi to send auto guidance commands to the controller during an AUTO mission? For instance, if I send a copter to a location and was looking for a red square on the ground; if it sees a red square it should land on it; if it does not see a red square it should return to home.

If the above will not work, and it is not possible for the Pi and the autopilot to play nice with each other, Is it possible to change mission script commands while the autopilot is in a current mission? For instance, I send the copter to a location, it hovers, the Pi communicates with my ground station, and I have a program that writes commands to send to the APM over the telemetry link? I guess what I am asking is there a way to send terminal commands using something like a python script, to the autopilot over the telemetry link?

I have read a little about this I just want to make sure I have a clear understanding. If I cut the upper bridges and bridge the bottom pads it will allow me to use the USB and the 3DR telemetry radios together? Will this disable being able to power the APM through USB for setup etc, can I still connect to my computer? Also having USB and the power plug connected will not cause an issue during operation right?

If this is the case will it then be possible to send commands from a USB connected Pi to the APM 2.6 with MAVlink? It seems you can use MAVlink https://code.google.com/p/ardupilot-mega/wiki/Commands to send commands to the APM 2.6. Is it possible to run interrupts during a mission then? What I am wanting to do is something like this; I plan a full mission with Mission Planner. The copter moves to the first waypoint and Loiters for 5 seconds, During this time the Pi will search for a set of colors at that waypoint. The colors would correspond to what the Copter should do next. If it sees no color it should continue to the next location. If it sees one of the command colors it should interrupt the mission and do a command. After the command has been executed it should continue with the mission. Is this possible to do without re-writing the mission list? Can I simply pass a new mission waypoint with a higher priority to the existing mission list?

Thanks again.

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

Join diydrones

Email me when people reply –

Replies

  • An update on our progress http://www.ece.msstate.edu/courses/design/2015/team_tate/

    We got the system to work using MavProxy. We are currently in the process of improving. 

  • Hi James,

    As Drew mentioned, you'll have to read tutorials on how to modify waypoints using the mission list. It becomes an exhaustive task at times to inquire about the mission list from the APM each time. I'm sure the guided mode can be fairly easy to manipulate for your purposes here. Regarding the communication between APM and Pi, I would strongly suggest a very bare-boned communication protocol such as RS232 or RS422. The reason I'm suggesting this is because your way-point guidance is crucial information for the APM and you need to have a very reliable communication protocol for such information transfer. Do update us about your experience.

    Regards,
    Sohaib Jaffar 

  • Short answer:  Buy or make a cable linking the 6-pin telem2 port on your pixkawk to 4 pins on your Pi's GPIO pins (check http://dev.ardupilot.com/wiki/companion-computers/raspberry-pi-via-... to see which pins go where).  The default baud rate for this connection is 57600 on the APM and 115200 for the Pixhawk.  You'll first need to disable console login on your Pi's serial port so that it doesn't conflict (lots of guides for doing this on the web).  It's easier/faster to simply connect the APM's USB port to the Pi's USB port, but I've found that using the USB interface for telemetry (at least on my pixhawk) seems less reliable than the above telem-port-to-GPIO connection.  Once connected, the Pi can control the APM/Pixhawk via mavlink messages (have a look at the mavutil library).  

    Regarding your specific question, I'm sure it could be done.  Since you posted this back in January, 3DR has now released the DroneKit SDK which makes doing things like you propose pretty simple by using the MAVproxy utility.   I'd have to think about how optimally implement your mission requirements.  Worst case, when you see the "Command Color" you could always just have the Pi do a Get Mission COMMAND/ACK with APM to download the mission list, insert the new waypoint, and do a Set Mission COMMAND/ACK exchange.  Like a lot of these tutorials, this site is deprecated (anytime you see the word "WAYPOINT" in a mavlink message name, just replace it with "MISSION") but it gives you the step-by-step on which mavlink messages need to be exchanged for your Pi to download the mission plan from the APM or set a mission (http://qgroundcontrol.org/mavlink/waypoint_protocol).  Not sure, but look into whether (when your drone sees the "Command Color") you could just put the Pixhawk/APM into GUIDED MODE, do your new commands, and then put it back into AUTO mode.  I can't remember whether, upon going back into AUTO mode after executing GUIDED mode commands, the APM would resume at the waypoint where it left off or restart the  mission -- but you could test that behavior pretty easily.  Good luck. 

This reply was deleted.

Activity

Neville Rodrigues liked Neville Rodrigues's profile
Jun 30
Santiago Perez liked Santiago Perez's profile
Jun 21
More…