-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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
DroneCAN: Add support for few more statistics to DroneCAN RC #28390
base: master
Are you sure you want to change the base?
Conversation
Related Issue: #28295 Tested with both CRSF and DroneCAN RC - OSD elements behaved as expected when using RC_PROTOCOLS bitmask to switch between the two protocols. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, we must not have communicated our thoughts well on how we'd like this shaped.
We wanted three bits set aside which would specify a value out of an enumeration, not three bits, one for each of the types (and re-use of valid as RSSI, it seems?)
int8_t rssi_dbm = -1; | ||
int8_t snr = INT8_MIN; | ||
}; | ||
volatile struct RcLinkStatus _rc_link_status; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
volatile struct RcLinkStatus _rc_link_status; | |
volatile struct RCLinkStatus _rc_link_status; |
Why volatile
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this I didn't understand too ... so I was just closily following what is done for the CRSF class
https://github.com/ArduPilot/ardupilot/blob/master/libraries/AP_RCProtocol/AP_RCProtocol_CRSF.h#L310-L314
https://github.com/ArduPilot/ardupilot/blob/master/libraries/AP_RCProtocol/AP_RCProtocol_CRSF.h#L361
assuming that someone had a good reason which is above my paygrade
pl say clear "yes volatile" or "no voloatile" and I will do
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
has the "volatile" thing been sorted out? It should stay?
so as @tpwrules said in dronecan/DSDL#56 :) Question: Would it be acceptable to send two data types in one transmission, i.e. to bitmask the quality field? Specifically: The LQ data only needs 7 bits of the unit8 quality, so the 8th bit could be used e.g. for reproting the active antenna. Since the data has to be send round robin, this would be highly benefitial, i.e., adding an extra type just for that one bit would be sad as it would need an extra slot, The type could be named TYPE_LQ_ANT. |
60994b4
to
9fb9ffe
Compare
made the changes as suggested - I hope at least. also added the option for tx_power (mLRS doesn't use it but orther systems may) changes were tested by @jlpoltrack and found to work for both normal CRSF and DroneCAN rc. I'd like to reiterate the question if it would be acceptable to pack both LQ and active_antenna into the quality field |
Please do add the active antenna bit. We need to know what older versions of ArduPilot (eg. 4.5) will shows when a RC receiver sending this new style of packet is used. |
great, will do.
in the OSD it will show nothing since there is no code path for how the data received by DroneCAN can go to the OSD. The OSD uses the crsf() singleton. E.g. https://github.com/ArduPilot/ardupilot/blob/master/libraries/AP_RCProtocol/AP_RCProtocol_DroneCAN.cpp#L97-L98, and similarly for the other ext stats fields. as regards AP_RCpororocol_DroneCAN it will set rssi to 0 if the QUALITY bit is not set: https://github.com/ArduPilot/ardupilot/blob/master/libraries/AP_RCProtocol/AP_RCProtocol_DroneCAN.cpp#L97-L98. So, if in the new message other bits are set rssi will be set to zero - like before. IMHO I did consider backwards compatibilioty properly when I made that suggestion
|
9fb9ffe
to
aebad75
Compare
active_antenna bit added also noted that tx_power is only uint8_t so made it to be in units of 5 mW, to cover the range of 0 ... 1000 mW as before, tested by @jlpoltrack and found to work fine, both with CRSF and with DroneCAN rcinput |
This only allows for 2 antennas. Note that the RadioMaster DBR4 has 4 antennas! Just an example - but assuming 2 antennas will be a problem soon, if not right away. (You always need more). https://www.radiomasterrc.com/products/dbr4-dual-band-xross-gemini-expresslrs-receiver |
it needs to be understood that the mechanism used here isn't and can't be a full fledged link statistics if 4 antenna is really intended one could add an EXTRA_ANTENNA flag (in addition, in case it is needed) |
while the explanation given in the above based on the code might be compelling enough, @jlpoltrack has explicitely tested this with result "AP 4.5.7 + mLRS Latest w/ if(1) works fine too. RC Works and OSD Elements don't show (as expected)" |
This PR adds support for few more link statistics to the DroneCAN RC.
Specifically, it adds the support of three status flags which are propsoed to be added to the DroneCAN RCInput message (dronecan/DSDL#56), which allows to also send LQ, RSSI_DBM, and SNR, in addition to RSSI, via that message. These data are then made available to the OSD.
This PR is in principle dependent on dronecan/DSDL#56, but it doesn't need it, i.e. compiles and works fine without this being merged, since the code uses bit fields, and none of the flags defined in dronecan/DSDL#56.
I could test this only very lightly myself on my bench setup, but @jlpoltrack did test this carefully on a matekh743 with plane firmware. He found the CRSF to still work and also the new DroneCAN support to work.
The PR has a slight change in behavior as compared to before, namely that then no STATUS flags is set it now reports -1 to the add_input() rssi field, whereas before it was reporting 0. (old behavior: https://github.com/ArduPilot/ardupilot/blob/master/libraries/AP_RCProtocol/AP_RCProtocol_DroneCAN.cpp#L97).
The OSD was using so far only the crsf() singleton, so it needed now some abstraction so either the DroneCAN or the crsf class is used by the OSD, dependent on which RC protocol is configured by the user. I found that all a bit strange code, and as result of a struct being used the abstraction doesn't look like it is for other frontedn/backend examples. Bit it's aligned with how the crsf() singleton works.
As regards the receiver side, an example implementation of the proposed support is in the main branch of mLRS: https://github.com/olliw42/mLRS/blob/main/mLRS/CommonRx/dronecan_interface_rx.h#L339-L394