Map a Joystick Button to Take a Picture

Hello all,

I would like to map a button on my joystick to take single pictures and store them locally on the companion in full resolution (the video streamed to surface will be lower resolution than camera is capable of).

I do not believe this is really doable through joystick.cpp in ardusub, so instead I planned on making a python script that ran on the companion that would intercept the ‘MANUAL_CONTROL’ messages that include the joystick inputs from QGC.

so essentially this would mean both things (my script and joystick.cpp) would be handling the joystick inputs in parallel. While that’s obviously not ideal, it would be good enough for now if I set the buttons I want to use to disabled or an unused custom in QGC.

I was able to get this to work just fine in SITL; however I’ve not been able to get it to work with the actual ROV. I believe this is due to me making the mavlink connection incorrectly, so now I will post some details of it:

snippets of my python script :

master = mavutil.mavlink_connection('udp:0.0.0.0:14550')
master.wait_heartbeat()
.
.
.
while True :
    msg = master.recv_match()
    if not msg:
        continue
    if msg.get_type() == 'MANUAL_CONTROL' :
        js_buttons = msg.buttons

and then my mavproxy options have :

--out udpin:localhost:9000
--out udpbcast:192.168.2.255:14550
--out udpbcast:192.168.2.255:14551

I found that I could not a heartbeat when connecting to either of those (presumably bc they were already in use) so I tried adding a --out udpbcast:192.168.2.255:14552, and then connecting to that instead. At which point I was getting a heartbeat, but it was not getting the input messages.

I’ve also considered making this in a mavproxy module, but it seemed like it was not updating often enough when I put the contents of the while true into the idle task function, and I believe it might just be better practice to keep it separate.

Hopefully this will be as simple as adding an endpoint somewhere and pointing my script to it!

Good news!

I was able to get it working pretty well as a mavproxy module (the problem before was due to poor implementation)!

While this is great, I would prefer this to be a stand-alone script. So I would still appreciate some help with the connection stuff above!


I spoke too soon. this did not work on the physical rov. In SITL, I was able to loop through each message in self.status.msgs and look for the MANUAL_CONTROL message; however, in the physical rov I did not seem to get that message…

OKAY

so it turns out that the message was simply not part of the self.status.msgs, but it was inside a mav message from one of the slave connections.

As this has been a time sink for me, I will try to post some useful portions of this code once I get the chance.

Also, I would still appreciate some help on getting a stand-alone version (not a mavproxy module) working.