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 3 commits into
base: main
Choose a base branch
from
Open

crsf_rc: add bind command #23294

wants to merge 3 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

I assume vehicle command to bind comes from QGC and we may need to update QGC's UI

if (!strcmp(verb, "bind")) {
uORB::Publication<vehicle_command_s> vehicle_command_pub{ORB_ID(vehicle_command)};
vehicle_command_s vcmd{};
vcmd.command = vehicle_command_s::VEHICLE_CMD_START_RX_PAIR;
Copy link
Member

Choose a reason for hiding this comment

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

FYI this might get weird if other modules (px4io, other rc_input, etc) are running.

Copy link
Contributor Author

@benjinne benjinne Jun 18, 2024

Choose a reason for hiding this comment

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

I think in general there's only one rc module running per vehicle. If we expect multiple, then maybe we can handle this with the command parameters

0xE8, // Packet CRC8
};

return _uart->write((void *) bindFrame, 9);
Copy link
Member

Choose a reason for hiding this comment

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

Is there any acknowledgement or mechanism for checking?

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 didn't see any in the betaflight code or ardupilot code. To verify it was successful I think the assumption is you verify the receiver lights blink rapidly signifying it's in bind mode

@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.

@github-actions github-actions bot added the stale label Jul 26, 2024
@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

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