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

crsf_rc: add bind command #23294

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

crsf_rc: add bind command #23294

wants to merge 4 commits into from

Conversation

benjinne
Copy link
Contributor

@benjinne benjinne commented Jun 18, 2024

Solved Problem

Ability to bind using the crsf protocol

Fixes #23281

Solution

  • based on spectrum bind method in rc_input and bind packet from betaflight source code
  • adds capability to the crsf_rc module using cli or vehicle_command

Changelog Entry

For release notes:

crsf_rc: add bind command

Alternatives

Add to rc_input module if needed

Test coverage

  • todo test on hardware

Waiting on:

Finally update docs:

@benjinne benjinne marked this pull request as ready for review June 25, 2024 17:36
@benjinne
Copy link
Contributor Author

@dagar I've tested and verified that this works.
I verified both crsf_rc bind and using the spectrum bind button in QGC works although any spectrum option will work and it's a bit confusing. We'll need to update QGC to have a generic bind for crossfire and ELRS receivers.

@hamishwillee
Copy link
Contributor

hamishwillee commented Aug 21, 2024

The https://mavlink.io/en/messages/common.html#MAV_CMD_START_RX_PAIR message that this hooks into assumes you're going to specify a type of RC. If it is possible to have multiple radios that might pair on a vehicle then you should add ELRS as an option to https://mavlink.io/en/messages/common.html#RC_TYPE and check the command for the type being set.

@hamishwillee
Copy link
Contributor

QGC assumes Spektrum RC because that is the only thing that is supported by the message. Do you plan to update that section of QGC to allow ELRS to to be configured too? If not, how were you expecting this to be called?

Either way, we should document that this can be used and how in https://docs.px4.io/main/en/config/radio.html#additional-radio-setup

@benjinne
Copy link
Contributor Author

The https://mavlink.io/en/messages/common.html#MAV_CMD_START_RX_PAIR message that this hooks into assumes you're going to specify a type of RC. If it is possible to have multiple radios that might pair on a vehicle then you should add ELRS as an option to https://mavlink.io/en/messages/common.html#RC_TYPE and check the command for the type being set.

Yeah I agree. Right now it accepts any bind message since most vehicles just have one RC receiver, but I can imagine having multiple. Not sure when I'll get around to it

QGC assumes Spektrum RC because that is the only thing that is supported by the message. Do you plan to update that section of QGC to allow ELRS to to be configured too? If not, how were you expecting this to be called?

Either way, we should document that this can be used and how in https://docs.px4.io/main/en/config/radio.html#additional-radio-setup

Either with the command-line or with a QGC button. Currently the spektrum bind button works, but it's a little confusing. I'm also not sure when I'll get around to it

@benjinne
Copy link
Contributor Author

benjinne commented Nov 5, 2024

@hamishwillee could you take another look at these changes? I think I addressed all your concerns

uint8_t cmd_ret = vehicle_command_ack_s::VEHICLE_CMD_RESULT_UNSUPPORTED;

if (!_is_singlewire && !_armed) {
if ((int)vcmd.param1 == 1) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should change this to not be a magic number. I'll discuss the MAVLink PR this evening.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P.S. I won't be reviewing this other than the MAVLink aspects (not a developer)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, if the mavlink PR goes in, will the enum be available here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I merged your mavlink PR (thanks!).

I believe that this mavlink PR will automatically get updated with the changes in the mavlink/mavlink submodule, and when it gets merged that will include the update #23495

@dagar That's how it works right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hamishwillee I was able to use the updated mavlink enum in QGC, however it doesn't appear available in PX4.
mavlink/qgroundcontrol@2a8bcdf

I've seen duplicate enum definitions copied from the common.xml into header files for different modules. Should I do the same here, or is there a way to map to the mavlink common.xml?

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

Successfully merging this pull request may close these issues.

Add feature for CRSF RX binding via cli or vehicle_command
3 participants