Home        Store        Learn        Blog

Standard way of starting script on companion from controller

Dear All,
Is there any way to start a custom script on the Raspberry Pi companion computer from the controller? I have external devices that communicate with the main electronics compartment via IR, would be very comfortable to initiate communication with just a joystick button press.
Also, when I use the GPIO pins of the Raspberry from a python script, I’ve got a warning that the GPIO is already reserved. Which pins are reserved and which are free to use on the BlueROV2?
best regards,

Joystick inputs are in general handled by QGC, which does things with them by sending mavlink messages. You’ll need to make a script on the companion computer that is waiting for input, which means it should start when the RPi is turned on (e.g. start it in a screen session in .companion.rc). Your options for input are basically:

  1. Have your script accept a mavlink command that isn’t otherwise used/doesn’t affect operation (probably using pymavlink), and set up QGC to send that command on press of your joystick button
  2. Build a custom QGC where you register a custom mavlink command as a button option and then do option 1. using this custom command (quite a bit more involved, for basically just more certainty that the command sent won’t affect other operation)
  3. Get ‘something else’ to accept joystick input on your top computer at the same time as QGC (not sure if possible) or pipe joystick input via the ‘something else’ such that your special button gets handled in the ‘something else’ and everything else is just passed to QGC; then set up a server on the RPi with your ‘something else’ as its client, in which case you can send whatever information/commands you want (no requirement to use mavlink).

Option 1. is likely the easiest, since if you can find an otherwise unused mavlink command then all you have to do is set up something to receive that on the companion computer. Options 2. and 3. are a bit more extensible, and the tradeoff is basically 2 will let you keep everything inside QGC (which is neat) but requires figuring out how that works and working within that framework, whereas 3 gives you a lot more freedom but requires finding something that can handle and pass through joystick input, and requires you to set up the communications side of thing by yourself instead of just leveraging the existing communication from QGC.

From the ArduSub connection diagram I’d expect the BlueROV2 to not actually be using any of the GPIO pins from the Raspberry Pi. Most likely you’re having a similar misunderstanding to this person and misreading the pinout/pin functionality options on the RPi datasheet.

I’d suggest you make sure you’re using the correct datasheet for your Raspberry Pi device, double-check what’s written in there, and if you’re still having trouble after that you can ask about the specific pins you’re wanting to use and what you’re wanting to use them for, and we can try to figure out what’s not working or being set up correctly :slight_smile: