Can I set desired roll, pitch via companion computer?

Hello, I am using dronekit python on Raspberry Pi 2 and I was wondering if we can set roll and pitch directly (Arduplane). The dumb way would be to use RC override but this is really not what I am looking for, I want to set a target, say, bank 10 degrees to the right, pitch 5 degrees down or something and let the Arduplane PID take care of the implementation. With RC override, I would be second guessing the PID controller and trying to implement my own, very primitive, controller in the companion.

For pitch, I can kind of cheat by mucking about with PITCH_TRIM_CD, it’s ugly but it’s actually what I am after in that it sets a target pitch, even if it’s totally the wrong way to go about it. The downside is, of course, that if the script goes south, I might have a plane that’s so out of trim it’s unflyable in anything other than manual, not ideal.

For roll, there is nothing that I am aware of that might do that other than RC override.

Does anyone have any experience of this? I there a way of doing it via a raw MAVLINK message or something?

1 Like

Can someone answer this question, please?

Hello @py_py , it’s been a long time since I asked that and I have not got an answer either. However, with the new capabilities of Arduplane, it might be possible to use lua scripting to do this, see Scripted Aerobatics — Plane documentation.
I have not tried it myself but it’s probably a good approach today.

thank you @armadillo, probably I will try this thank you.

Another thing that you might find useful. If you want to send info over mavlink and don’t want to go to the trouble of adding your own messages with mavgen, you can send STATUSTEXT from the companion.

This is an awful hack but it should work, the idea is, for something that doesn’t get sent too often (such as an attitude command), you can make your own “protocol” that will be received and ignored by the autopilot but can be intercepted and understood by a Lua script running in the autopilot (again, I have never tried it but it should work in principle). So, STATUSTEXT takes a bunch of bytes. Make the first byte something unlikely to be used in polite conversation that will signal to the script that this is one of your commands. Follow it up with another byte specifying the type of command. Follow that by the payload specific to the command.

For example, let’s say @ is your start byte and # specifies an attitude command, which you have decided contains two bytes for each of pitch, roll yaw. You would send something like:
@#pprryy
and have your Lua script keep an eye on incoming STATUSTEXT messages starting with @. The rest is up to you, you would need to decode the pprryy and then somehow command the autopilot to achieve this attitude.