Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AP_MSP: Use scaled RC inputs instead of direct RC in #26304

Merged
merged 1 commit into from
Mar 7, 2024

Conversation

MichelleRos
Copy link
Contributor

@MichelleRos MichelleRos commented Feb 23, 2024

This makes the MSP RC output scaled RC inputs instead of just passing through the received RC input.
This is especially useful if you have RC reversals, so that ArduPilot's _REVERSED parameters still apply.

Tested with a copter with an HDZero VTX which uses stick commands.
I've also reversed pitch because ArduPilot's pitch is inverted relative to other flight controllers (eg Betaflight) and OpenTX and thus how devices like the HDZero VTX expect it to be.

@yaapu Re our previous discussion - not sure if this would affect other (non-VTX/OSD) MSP devices that wouldn't expect pitch to be reversed? At the moment, if people using MSP devices used ArduPilot's _REVERSED parameter to reverse pitch instead of reversing it on their transmitter, then how I've currently done it should result in no change of behaviour, whereas if they've done it on their transmitter then this should result in pitch being the opposite way around...
Not sure if we need a parameter to decide which of the two doesn't get a change in behaviour?

@andyp1per
Copy link
Collaborator

I'm not sure about reversing pitch just here. We don't do that in other places (e.g. CRSF) and people generally then setup the channel as reversed in AP. Does that not work here?

(I like the change BTW!)

@MichelleRos
Copy link
Contributor Author

MichelleRos commented Feb 23, 2024

@andyp1per It depends on which one they did (OpenTX or AP parameters)... If they did it in AP's parameters, then this PR should actually result in no change in behaviour for them.

I don't know what CRSF does with RC input, but if it's using RC input directly instead of the "scaled" one, then it will also be this situation.

@tridge
Copy link
Contributor

tridge commented Feb 23, 2024

Great!
this should result in the stick movements for VTX control being independent of the R/C settings, right?

@timtuxworth
Copy link
Contributor

I seem to have HD Zero goggles running fine without this. What problem is it solving exactly?

@MichelleRos
Copy link
Contributor Author

Great! this should result in the stick movements for VTX control being independent of the R/C settings, right?

Independent of R/C input, actually. Currently, if for example your roll is reversed in your transmitter and you use the _REVERSED parameter to correct it, then MSP will still get the roll directly from the transmitter. With this PR, MSP will get the corrected roll - i.e. the same roll that ArduPilot uses for flight control.

I seem to have HD Zero goggles running fine without this. What problem is it solving exactly?

I'm also using HDZero Goggles and yes, they do work fine, just with a few caveats. If some of your RC channels are coming in reversed and you're using the _REVERSED parameters to fix it, then stick commands for the VTX menu, camera menu etc will be the wrong way around. Except for pitch, where the problem comes if you don't have _REVERSED = 1.

If you use OpenTX's default directions, then it'll work fine, and of course, if you don't use the stick commands then you won't notice it either.

@MichelleRos
Copy link
Contributor Author

@tridge Not quite sure if this needs static, const or both in front of the float variables?

@yaapu
Copy link
Contributor

yaapu commented Mar 7, 2024

@MichelleRos as far as I'm concerned nobody but VTX vendors use MSP RC telemetry frames so impact would probably be minimal, what I mean is that I received "complaints" about the inversion only from VTX users :-)
I'm happy with this change

@tridge tridge merged commit 3ff7901 into ArduPilot:master Mar 7, 2024
92 checks passed
@timtuxworth
Copy link
Contributor

This causes the sticks to work differently on different vehicles. On one plane I hold the sticks / \ to get to the menu, on a different plane, with yaw reversed I have to use / / (I fly mode 3).
I don't think it's a good change @MichelleRos - it took me hours of debugging to figure out why my OSD menu worked perfectly on one plane and not on the other.

@MichelleRos
Copy link
Contributor Author

MichelleRos commented Apr 26, 2024

@timtuxworth I'm not sure what you mean. If yaw is coming in reversed from scaled input, then AFAIK that means it has to be going in reversed into your PIDs...

@timtuxworth
Copy link
Contributor

timtuxworth commented Apr 28, 2024

@timtuxworth I'm not sure what you mean. If yaw is coming in reversed from scaled input, then AFAIK that means it has to be going in reversed into your PIDs...

Yes it's reversed into the control loop because that's what this plane needs, but this method is to send the stick values to the VTX. My comment was about using the sticks to get to the VTX menu on the HD-Zero googles, which currently works "backwards" on this one plane to how it works on my other plane and both drones, which do not have RC Yaw reversed.

I'm going to see if I can get it working how I want, if I can, I'll do a PR.

@tridge
Copy link
Contributor

tridge commented Apr 29, 2024

Yes it's reversed into the control loop because that's what this plane needs, but this method is to send the stick values to the VTX. My comment was about using the sticks to get to the VTX menu on the HD-Zero googles, which currently works "backwards" on this one plane to how it works on my other plane and both drones, which do not have RC Yaw reversed.

it sounds like you have the RCn_REVERSED set incorrectly on this aircraft for rudder. The "that's what this plane needs" makes no sense.
note that if an aircraft needs reversal in rudder it should be set on SERVOn_REVERSED not in RCn_REVERSED
SERVOn_REVERSED is for the control surface. RCn_REVERSED is for the stick input. Don't change stick input to reverse a rudder

@timtuxworth
Copy link
Contributor

timtuxworth commented Apr 29, 2024

Yes it's reversed into the control loop because that's what this plane needs, but this method is to send the stick values to the VTX. My comment was about using the sticks to get to the VTX menu on the HD-Zero googles, which currently works "backwards" on this one plane to how it works on my other plane and both drones, which do not have RC Yaw reversed.

it sounds like you have the RCn_REVERSED set incorrectly on this aircraft for rudder. The "that's what this plane needs" makes no sense. note that if an aircraft needs reversal in rudder it should be set on SERVOn_REVERSED not in RCn_REVERSED SERVOn_REVERSED is for the control surface. RCn_REVERSED is for the stick input. Don't change stick input to reverse a rudder

I say "needs" because it's a pretty mechanical process following the Wiki "4 Channel Plane" setup https://ardupilot.org/plane/docs/guide-four-channel-plane.html#servo-function-reversal - following these instructions you could technically have both/either SERVOn_REVERSED and/or RCn_REVERSED for a particular surface.

That said this is an A Tail, so it is possible I've gotten it wrong, although it does fly! I'll re-check the V-Tail/A-Tail instructions https://ardupilot.org/plane/docs/guide-vtail-plane.html#servo-function-reversal and report back.

@tridge
Copy link
Contributor

tridge commented Apr 30, 2024

@timtuxworth i'm really quite sure your plane is setup incorrectly. Rudder will work with R/C input, but the automatic rudder mixing will be backwards. It means your plane will sideslip in auto flight modes.
The change from @MichelleRos is correct. You need to reverse your RC4 input and reverse your A-tail setup.
You must get your R/C setup so that when you put in right rudder on R/C you get a higher PWM value in the R/C channel monitor. When you put in left rudder you should get a lower PWM

@timtuxworth
Copy link
Contributor

@timtuxworth i'm really quite sure your plane is setup incorrectly. Rudder will work with R/C input, but the automatic rudder mixing will be backwards. It means your plane will sideslip in auto flight modes. The change from @MichelleRos is correct. You need to reverse your RC4 input and reverse your A-tail setup. You must get your R/C setup so that when you put in right rudder on R/C you get a higher PWM value in the R/C channel monitor. When you put in left rudder you should get a lower PWM

Thanks Tridge - yes I think you are right, the A-Tail setup needed to be reversed. I hope to test fly this soon. I did a detailed write up and video because I thought it might also help others. Posted on discuss here: https://discuss.ardupilot.org/t/a-tail-servo-and-rc-reversed-settings/117059/9 I'll be updating this post when I fly it.

@timtuxworth
Copy link
Contributor

timtuxworth commented May 5, 2024

@timtuxworth i'm really quite sure your plane is setup incorrectly. Rudder will work with R/C input, but the automatic rudder mixing will be backwards. It means your plane will sideslip in auto flight modes. The change from @MichelleRos is correct. You need to reverse your RC4 input and reverse your A-tail setup. You must get your R/C setup so that when you put in right rudder on R/C you get a higher PWM value in the R/C channel monitor. When you put in left rudder you should get a lower PWM

Yes this is correct on this setup, my golden rule is "never change the RC on the TX - let AP do it", so with my TX16S, my PWM values are always as you described.

I think you are also correct that my plane wasn't set up correctly. I followed the wiki and ended up reversing my ATailLeft and ATailRight functions on the servos so that "Right" is actually on my left ruddervator and "Left" is actually on my right ruddervator. It felt ok to fly it, but looking at the log I'm not so sure. Here is the log I just flew with 4.5.2 beta 1.
https://www.dropbox.com/scl/fi/82ze5lrdncc0x0m8aoalv/log_87_2024-5-4-17-38-40.bin?rlkey=szj6880f2a26eyygjrey8yluv&st=m63prdw9&dl=0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants