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

Add support for Baro/Vario in CRSF #26880

Merged
merged 3 commits into from
May 22, 2024
Merged

Conversation

andyp1per
Copy link
Collaborator

@andyp1per andyp1per commented Apr 24, 2024

Fixes the CRSF part of #26699

@Merga189
Copy link

Is it possible for me to do some test?

Hardware Kakute F7 Mini and SpeedyBee F405 Wing Mini.

br Karl

@Target0815
Copy link

With a SpeedyBee F405 Wing I would also like to have a look at this. I would just need the right firmware for it ...

@Merga189
Copy link

If it is OK!?

I build for the SpeedyBee F405 WING

parameter list version: 4.6.0 dev

Speedy_Test.params.txt

FW

bin.zip

Karl

@Merga189
Copy link

No baro values on SpeedyBee F405 WING mini with FW 4.6.0 dev.

FrSky X10S Express, EdgeTX 2.9.4, HiYounger TX module + BETAFPV 2.4GHz Nano RX ELRS 3.3.2, SppedyBee F405 Wing mini only with BT slave on Serial 6 for communication. No GPS connected.

xxx.params.txt

@andyp1per
Copy link
Collaborator Author

Do you get any extra sensors if you search for them? I only did ID 9, not ID 7 (Baro only)

@Target0815
Copy link

@andyp1per Can you please provide a firmware for SpeedyBee F405 Wing?

@Merga189
Copy link

Merga189 commented Apr 25, 2024

Deleted all sensor and searched again.

That is, what I have here on the table

Screenshot_2024-04-25_20-55-31

It is just a F405 WING Mini with RX and BT module, nothing else. The parameter list with your Version: 4.6.0 dev I posted before. No changes made.

Here the radio telemetry screen and the companion telemetry screen -fresh-
1

2

No id 9

br Karl

PS. If helpful, can post same pics with Kakute F7 mini. But there id 9 also did not show up ....

@Merga189
Copy link

@andyp1per

I think, there is an error on my side.

I cloned your fork ~$ git clone --recurse-submodules https://github.com/andyp1per/ardupilot.git and just build the firmware.

But checking, if your modifications like

Screenshot_2024-04-26_08-50-52

are actually in the code I did build here I see that

Screenshot_2024-04-26_08-47-00

My apologize for the confusion

Best you provide a firmware for the SpeedyBee F405 Wing

Karl

@andyp1per
Copy link
Collaborator Author

arduplane.apj.zip

@Merga189
Copy link

Merga189 commented Apr 26, 2024

ID 9 shows up! Wrong value, but it is there .....

screen-2024-04-26-093844
screen-2024-04-26-093854

Values jumping between -xxxx m and +xxx m here

@andyp1per
Copy link
Collaborator Author

ID 9 shows up! Wrong value, but it is there .....

screen-2024-04-26-093844 screen-2024-04-26-093854

Values jumping between -xxxx m and +xxx m here

Do you have a GPS? Worth checking this when armed and outside as it is relative alt above home position which needs to be set. I used the code from the CRSF spec, so it could be wrong - but not sure how I would tell. What about the vario data?

@andyp1per
Copy link
Collaborator Author

arduplane.apj.zip

Try this one, I think I need to invert the sign since AP deals in down rather than up

@Merga189
Copy link

GPS attached. FW changed. Have the FC here on the window sill

Untitled

@Target0815
Copy link

With Ethos 1.5.6

screenshot-2024-04-26-41102

I still have to test whether the values are correct ...

@Target0815
Copy link

Target0815 commented Apr 26, 2024

Ethos can evaluate the frame CRSF_FRAMETYPE_BARO_ALTITUDE with ID9 (Alt and VSpd). EdgeTX only evaluates CRSF_FRAMETYPE_VARIO with ID7 (VSpd).

It would be an advantage for Ardupilot if we could use both. Possibly switchable with a flag in RC_OPTIONS or similar. This would cover all transmitter systems.

As for the values themselves, the calculations used for the S.Port protocol can be found in AP_Frsky_Telem. Presumably you can see there which sign is used and adopt this in part for CRSF.

@andyp1per andyp1per force-pushed the pr-vario-crsf branch 2 times, most recently from b38b880 to 52b0788 Compare April 27, 2024 14:08
@andyp1per
Copy link
Collaborator Author

This includes ID 7 - please try it
arduplane.zip

@Target0815
Copy link

EdgeTX 2.9.4
VSpd - ID7 - shows changing values between -25.x m/s to +50.x m/s without movement (incorrect)
Alt - ID9 - constantly shows -586.5m (incorrect)
for comparison Alt - ID2 - shows 0 (correct)

Ethos 1.5.6
VSpd - ID7 - shows changing values between -25.x m/s to +50.x m/s without movement (incorrect)
Alt - ID9 - 0 m (correct)
VSpd - ID9 - shows a constant 1.43 m/s (incorrect)

@Merga189
Copy link

Alt and VSpd show up, but irregular values.

50' YT video showing first baro values on QGroundcontrol and then values on my radio.

https://youtu.be/iiIft0VpIOk

@andyp1per
Copy link
Collaborator Author

So there was a bug in the new code where it was using absolute alt instead of relative. Should be fixed now.

arduplane.zip

I think the errors in vspd are actually quantization errors since this is only an 8-bit int. We might have to special-case 0 to return 0;

@Merga189
Copy link

VSpd id 7. moving up down in between +1xx.x m/s and -9x.x m/s

ALT id 9. -1000.0 m fix, not moving at all

ELRS

@andyp1per
Copy link
Collaborator Author

arduplane.zip - think there was a sign conversion issue.

Can you send me a disarmed log of your vehicle? There is not a lot going on in these calculations, but there is some weird conversion.

@Merga189
Copy link

arduplane.zip - think there was a sign conversion issue.

Can you send me a disarmed log of your vehicle? There is not a lot going on in these calculations, but there is some weird conversion.

I am just a user and at the moment there is no vehicle. It is just the SpeedBee in the window sill.
MP or QG?
But I'll flash now and come back ....

@Merga189
Copy link

VSpd - varying between -/+ xxx m/s
Alt - crazy numbers -/+ xxxxx m

What is that "disarmed log"?? MP or QG

@Merga189
Copy link

I think, 'data log' in MP. I am on Linux here with QG, but I have a WIN with MP in a Vbox. So I'll try ....

@Target0815
Copy link

Andy_log.zip

Log 1: original 4.6.0 with ER8GV Vario RX
Log 4: Andy 4.6.0 with Standard ELRS RX

You should be able to make a good comparison.

@Merga189
Copy link

2024-04-27 22-56-34.tlog.zip

Hope, that is the right one.

Good night, shut down now ;-)

@Merga189
Copy link

I see on MP, that the FC is ARMED (ARM/DISARM on toggle switch) Alt here with me rock solid -4.5m. Putting a plastic bag over the FC and putting hand pressure on the bag, in MP see - 30 ... -40m, but value is 9 rock solid. For VSpd same. a little variation, but not a measurement as expected ... ELRS

@andyp1per
Copy link
Collaborator Author

I see on MP, that the FC is ARMED (ARM/DISARM on toggle switch) Alt here with me rock solid -4.5m. Putting a plastic bag over the FC and putting hand pressure on the bag, in MP see - 30 ... -40m, but value is 9 rock solid. For VSpd same. a little variation, but not a measurement as expected ... ELRS

Do you have a GPS? Its the same code as FPort, will only work with GPS

@Merga189
Copy link

Then the fault is on my side. I removed the GPS for the bag testing.
So it need ARMING and GPS! GPS has to have a lock?
Repeat the test and report.

So, ARMED, GPS has fix. Ratio VSpd 0.1, Alt Ratio 0.1
VSpd +/- 0.3 m/s, Alt -3.3 to -3.4 m. Looks good!

But how to verify those values?

I used this here to simulate altitude changes with baro sensors some years ago, but this is to small to take it all inside.

20240429_081711

Or I need a plane and record, but I don't have that at the moment.

@andyp1per
Copy link
Collaborator Author

Pete showed me perhaps a better way to determine the altitude which will not require GPS. I'll chat to Alex about using this.

@Merga189
Copy link

The good thing is, ID 7 and ID 9 are on the radio and we do have values.

@Target0815
Copy link

I'll chat to Alex about using this.

Do this ... Alex has conjured up a quick Vario / VSpd for S.Port. I actually wanted to test your current solution against F.Port, but I should probably wait a little longer?

@andyp1per
Copy link
Collaborator Author

Can you try this? This adds better support for relative home, so baro on its own should work.
arduplane.zip

@Target0815
Copy link

Looks the best so far. However, I still have to test it tomorrow outdoors with a GPS fix.

@Merga189
Copy link

Works here without arming and without GPS.

RATIO to 0.2 for quite reasonable values VSpd and Alt. x.x m/s and x.x m.

But how to verify?

@Target0815
Copy link

RATIO to 0.2 for quite reasonable values VSpd and Alt. x.x m/s and x.x m.

So only 20% of the respective value would be displayed? Because according to the EdgeTX manual:

Ratio: Specifies the ratio value to multiply with the sensor value as needed by some sensors.

But how to verify?

I will compare with another Vario sensor. oXs would be a candidate or like here a Radiomaster ER8GV.

@andyp1per
Copy link
Collaborator Author

Works here without arming and without GPS.

RATIO to 0.2 for quite reasonable values VSpd and Alt. x.x m/s and x.x m.

But how to verify?

vspd is an exponential value, so simple multiplication will not give you correct values. You really need EdgeTX to decode this properly.

image

@Target0815
Copy link

Alt (ID 9) is still strange here. Immediately after resetting the telemetry, -380 m is displayed here. Mostly values in the minus range.

There is another Alt value (ID 2/4) which is approximately at the height of the location (27 m).

@tridge
Copy link
Contributor

tridge commented May 1, 2024

can be merged once testing passes

@andyp1per
Copy link
Collaborator Author

Alt (ID 9) is still strange here. Immediately after resetting the telemetry, -380 m is displayed here. Mostly values in the minus range.

There is another Alt value (ID 2/4) which is approximately at the height of the location (27 m).

For ID9 to be displayed correctly your TX needs to know how to decode it

@andyp1per
Copy link
Collaborator Author

Tested ok. Can be merged now.

@tridge tridge merged commit 3a4fdb1 into ArduPilot:master May 22, 2024
91 checks passed
@IamPete1 IamPete1 removed the DevCallEU label Jun 4, 2024
@andyp1per andyp1per deleted the pr-vario-crsf branch July 11, 2024 12:00
@Matvey546436
Copy link

Matvey546436 commented Sep 25, 2024

I flashed my speedybee F405 wing is a test firmware. Vspd shows random values, although mission planner displays correctly in the status window.
photo_5449693189838597147_y
photo_5449693189838597146_y
photo_5449693189838597145_y
photo_5449693189838597144_y

@Frank0587
Copy link
Contributor

I think there is still a little/big endian issue in the code.
A Ratio of 0.1 means in OpenTx a factor of 1/255 (and not 10%). Therfore this ratio acts like a 8bit right shift, so the upper bytes is used as lower byte. For values <255 (altitude = 25.5m) this "workaround" is ok. But a code fix will be better... #28478

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

Successfully merging this pull request may close these issues.

Missing barometer telemetry values in AP Plane, yaapu and ExpressLRS.
7 participants