Customize controller buttons to control raspberry pi?

Joined
Mar 23, 2018
Messages
2
Reaction score
1
Age
36
New user here, and very grateful for the wealth of information on these forums. I am using the Solo as a mobile platform for a sensor that I am controlling using a raspberry pi via Mavlink. I have written a script to control the sensor through SSH via my phone or laptop, as long as the rpi is connected to the controller-broadcasted wifi. Currently, the program runs by activation on the phone/laptop, which sends the drone into an autonomous flight across several GPS points. At each point it hovers and triggers the sensor to take measurements. Upon completion of the list of points it returns home. I would like to know if it is possible to reprogram one of the controller buttons to trigger the sensor activation, thereby allowing me to fly manually and take measurements on a given point with a simple button press, instead of having to hover and type commands.

The rpi is connected to the drone through a USB directly connected to the Pixhawk (stock 2.0). I read on another thread that it is possible to reprogram the controller buttons to drive servo motors using PWM, but I am not sure if I can send some kind of command that the rpi could detect through the USB? Any advice or suggestions would be greatly appreciated.
 
First, welcome here!
In principle this is pretty straightforward. There is the buttonmanager.py script which handles all controller button events. You can add additional button events there.
Here is an example I wrote to turn a lidar scanner on and off by a long press of the paddle button. I have connected an Arduino which runs the scanner code.
mtbsteve/3DR-Solo-Object-Avoidance

Now my question: how did you setup the communication between the IMX and the RPI? For the Arduino, I am using the Pymata library. What is the approach for an RPI? Thanks!
 
  • Like
Reactions: XevetS and cyc54
Thanks, fpvsteve. Just took a look at your videos. Thanks for sharing your awesome project! I think I can definitely adapt this.

For my project, I am looking to get some telemetry data from the Pixhawk in addition to triggering scans, etc. - so it made more sense for me to connect to the pixhawk instead of to the IMX. Instead of using the accessory bay ports, I am using a USB connection from the pi to the mini USB port directly on the Pixhawk. I communicate with it via a script that uses the pyusb module (pyusb/pyusb) to transmit commands over USB - mainly, setting and detecting GPS positions.

Initially I was trying to get the pi to connect via Tx/Rx in the accessory bay, but this seems to be tricky (and apparently, many others have also had issues with this connection method). For some reason I have only been able to get the pi to communicate successfully through Mavproxy over direct USB, when the Solo is already turned on. However, communication via Tx/Rx only works when I have removed the battery of the Solo, then supplied power to the Pixhawk through the 5v pin. If I do not remove the battery, the Pixhawk turns on the battery when the 5v wire is connected, and then power starts flowing to the Pi through 5v pin. If I do not have the 5v connection, it stalls out with message "Waiting for heartbeat from /dev/ttyS0"... Maybe I am doing something wrong...

But since the direct USB connection is very solid, I just go with that for now. :)
 
  • Like
Reactions: XevetS
Thanks for the pyusb link. Very helpful.
Good luck with your project!
 

New Posts

Members online

No members online now.

Forum statistics

Threads
13,094
Messages
147,748
Members
16,058
Latest member
Gabriela