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

[Sponsored by Cubepilot and Holybro] Cube ID via DroneCAN #23113

Merged
merged 10 commits into from
Sep 2, 2024
Merged

Conversation

julianoes
Copy link
Contributor

@julianoes julianoes commented May 9, 2024

This adds support for Cubepilot's Cube ID modules via DroneCAN, so that users are not limited to the Cube ID serial variant.

Thanks to dirksavage88, I borrowed quite a bit of code from #21647.

Tested using QGC master and DroneScanner.
QGC v4.4.0 doesn't properly implement the "Fixed GPS GCS" setting (see mavlink/qgroundcontrol#11673).

Initial work for CubeID was sponsored by CubePilot.
Additionally, testing/fixup for the Holybro Remote ID was sponsored by Holybro.

@PetervdPerk-NXP
Copy link
Member

Awesome, you managed to update the libuavcan and dsdl dependencies so that we can generate latest data types?

@julianoes
Copy link
Contributor Author

@PetervdPerk-NXP I just updated it and nothing seemed to break, so I'm not sure I did it right...

@henrykotze
Copy link

We definitely need to test it on hardware, since I have updated previously to support newer data types, but there were issues translating the messages between FMU and Cannodes. I specify remember that the Servo Array Command didnt work as expected.

I will see if I can find the Issue or some internal doc which describes the issue.

@github-actions github-actions bot added the stale label Jun 20, 2024
@julianoes
Copy link
Contributor Author

@henrykotze or @AlexKlimaj any tips how I test whether the DroneCAN update breaks anything?

@dagar
Copy link
Member

dagar commented Jul 11, 2024

Add a parameter to enable/disable this in UAVCAN? Only allocating UavcanRemoteIDController at init if enabled would suffice, then this doesn't cost anything.

@julianoes
Copy link
Contributor Author

@dagar what param name do you suggest, given this has subscriptions as well as publications? UAVCAN_EN_RID?

@julianoes julianoes requested a review from dagar July 11, 2024 02:46
@julianoes julianoes marked this pull request as ready for review July 11, 2024 02:49
@julianoes
Copy link
Contributor Author

julianoes commented Jul 11, 2024

This is working on my bench, I'd say this is on par with the serial implementation and we should be able to merge it once reviewed and flash issues are resolved.

@julianoes
Copy link
Contributor Author

@dagar let me know what param name you want, and what else you need me to do to merge this.

@julianoes
Copy link
Contributor Author

@henrykotze or @AlexKlimaj, please speak up how I have to test this, otherwise I'd like to get this in.

@AlexKlimaj
Copy link
Member

I can test in a few days. @dakejahl may be able to test sooner.

@dakejahl
Copy link
Contributor

I don't have the CAN version of the CubeID

@julianoes
Copy link
Contributor Author

@dakejahl

I don't have the CAN version of the CubeID

That's what I have tested already.

However, I was told that other CAN devices such as CANnodes with servo array might be broken with the update.

@julianoes
Copy link
Contributor Author

image

Updated and extended after testing with Holybro's Remote ID module as well which is running ArduRemoteID v1.14.

@julianoes
Copy link
Contributor Author

FYI @BluemarkInnovations and @dirksavage88

@dirksavage88
Copy link
Contributor

FYI @BluemarkInnovations and @dirksavage88

@julianoes I can test the holybro, but I don't have the Cube ID CAN either

@dagar dagar removed the stale label Jul 19, 2024
@dagar
Copy link
Member

dagar commented Jul 19, 2024

This largely looks good, I'm just not sure about some of the message flow specifics given the range of different use cases (more convoluted than you might expect).

For example rather than just copying around OPEN_DRONE_ID_ARM_STATUS into uORB and then Mavlink streaming it out verbatim, shouldn't PX4 itself be generating OPEN_DRONE_ID_ARM_STATUS based on its overall ability to actually arm which INCLUDES consuming a remote id module's OPEN_DRONE_ID_ARM_STATUS?

@dagar
Copy link
Member

dagar commented Jul 19, 2024

Another case is OPEN_DRONE_ID_SYSTEM. It some cases it needs to be forwarded through from the GCS (with GPS) to the remote id module. In other cases it can be generated by PX4 itself using the takeoff location for operator_latitude/operator_longitude. It needs to be one or the other, but definitely not both right?

@julianoes
Copy link
Contributor Author

Thanks for the review and comments:

For example rather than just copying around OPEN_DRONE_ID_ARM_STATUS into uORB and then Mavlink streaming it out verbatim, shouldn't PX4 itself be generating OPEN_DRONE_ID_ARM_STATUS based on its overall ability to actually arm which INCLUDES consuming a remote id module's OPEN_DRONE_ID_ARM_STATUS?

The way it seems to work is that the remote ID module sends this message out and PX4 parses it, and sends it out to the GCS via MAVLink.

Are you saying PX4 should modify the message?

Another case is OPEN_DRONE_ID_SYSTEM. It some cases it needs to be forwarded through from the GCS (with GPS) to the remote id module. In other cases it can be generated by PX4 itself using the takeoff location for operator_latitude/operator_longitude. It needs to be one or the other, but definitely not both right?

That's how I did it for the DroneCAN ones. If the GCS has sent a system message, then it is just forwarded. If not, then it will fall back to the takeoff location.

If you want we can add a param to explicitly configure that.

@julianoes julianoes force-pushed the pr-cubeid-can branch 3 times, most recently from c3143dd to 5342dfe Compare August 29, 2024 01:42
@julianoes
Copy link
Contributor Author

@dagar: regarding the last commit:

I did not manage to properly extract the open_drone_id MAVLink helpers into its own library. At build time there seemed to be a race condition between the MAVLink headers having been generated and the library requiring it.

Making the library depend on mavlink_c_generate seemed to work but made the IO boards fail which don't have MAVLink obviously.

Using ifs to avoid the open_drone_id files to be built for IO failed, as well as making it dependent on the MAVLink module. I assume that's because it is a circular dependency.

Instead I went with just moving the helpers into the MAVLink module and including the file in the UAVCAN driver as well.

Any other idea how I ought to do that?

@julianoes
Copy link
Contributor Author

@mrpollo it would be good not to cancel all other builds when one fails. Otherwise, I have to fix one board at a time and then try again, just to find the next one that fails.

This extracts the function mapping from MAV_TYPE to MAV_ODID_UA_TYPE to
the library, so that it can be re-used later by the remote ID
implementation over DroneCAN.

Signed-off-by: Julian Oes <[email protected]>
In order to have operator ID be sent by QGC, we need to forward
ArmStatus from the remote ID module (here on DroneCAN) to MAVLink.
This will send the System message if it is already being sent by a ground
station. Otherwise, it will assemble the message itself using the
takeoff/home location.
I could not extract the open_drone_id helpers to a separate lib because
it would require the mavlink headers while the mavlink library would
also depend on it, so it ended up being a circular dependency.

Instead, I'm now just using the headers from within the mavlink module
as well as from the uavcan driver.
@julianoes julianoes merged commit 8f6ce4e into main Sep 2, 2024
55 checks passed
@julianoes julianoes deleted the pr-cubeid-can branch September 2, 2024 04:20
@hamishwillee
Copy link
Contributor

@julianoes I've added the new uORB messages in PX4/PX4-user_guide#3370

Are there any docs implications to https://docs.px4.io/main/en/peripherals/remote_id.html ?

@julianoes
Copy link
Contributor Author

I think we already updated the docs @hamishwillee.

@AlexKlimaj
Copy link
Member

I actually need sd bench in the ARV6X build. I use it on the production line to test the SD card.

@julianoes
Copy link
Contributor Author

Oh, I'm sorry! Anything else you can remove instead?

Although, you could consider having a separate test image that gets reflashed with the production image once all tested.

@AlexKlimaj
Copy link
Member

It looks like it all fits just adding it back in. I want to avoid having to flash multiple times in production. The time it takes really adds up.

@julianoes
Copy link
Contributor Author

Ok good. Again, sorry about that but I find it super hard to get anything merged as any feature is going to hit the flash limit on at least some boards, and they all come with a slightly different set of modules and drivers installed, so it's impossible to know what's actually needed on each of them. The PR had been dragging for weeks, so I just took things in my own hands, disabled what I thought was "safe" and merged it. In an idea world I'd wait for everyone to give a thumbs up. Next time I know to ping you when I mess with an ARK board.

@dakejahl
Copy link
Contributor

Looks like the libuavcan update breaks CAN FW updating. I just tested the commits before and after this PR and confirmed it.
#23727

dagar added a commit that referenced this pull request Oct 16, 2024
…ory)

 - upstream libuavcan was broken and then marked deprecated, this fully absorbs the submodule (renamed libdronecan to deconflict) up to our last good working commit and all commit history is kept
 - fixes #23727 (regression introduced in #23113)
 - this puts us in a much better position to evolve the library as needed now that we have full control
dagar added a commit that referenced this pull request Oct 16, 2024
…ory)

 - upstream libuavcan was broken and then marked deprecated, this fully absorbs the submodule (renamed libdronecan to deconflict) up to our last good working commit and all commit history is kept
 - fixes #23727 (regression introduced in #23113)
 - this puts us in a much better position to evolve the library as needed now that we have full control
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

8 participants