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 Zenoh pico support #22017

Merged
merged 2 commits into from Oct 18, 2023
Merged

Add Zenoh pico support #22017

merged 2 commits into from Oct 18, 2023

Conversation

PetervdPerk-NXP
Copy link
Member

@PetervdPerk-NXP PetervdPerk-NXP commented Aug 29, 2023

Zenoh is a publish/subscribe protocol supporting peer-to-peer (FMU-to-FMU) and routed communication (FUM-to-Companion/Linux). Zenoh is plug-gable and on Linux it can be bridged to ROS2/DDS through zenoh-plugin-dds.

Zenoh-Pico is an implementation of Zenoh in C for constrained devices, it's fully compatible with the Rust Zenoh implementation.

For serialization of the messages the CycloneDDS CDRSTREAM library is used to generate DDS/ROS2 byte compatible serialization. This is decoupled from Zenoh so that other modules can re-use the serialization library.

Setup (FMU-to-Companion/Linux)

Companion/Linux

  • Setup Zenoh version on a Linux system https://github.com/eclipse-zenoh/zenoh#how-to-install-it
    • Tested with zenohd v0.7.0-rc-401-gb9103c3d and zenohd v0.10.0-dev-23-g44875300 (Needed for multicast support)
  • Setup Zenoh-plugin-dds on the Linux system https://github.com/eclipse-zenoh/zenoh-plugin-dds#how-to-install-it
    • Tested with zenoh-bridge-dds v0.7.2-rc built with rustc 1.70.0 (90c541806 2023-05-31)
  • Start a Zenoh router on the Linux machine connected to your FMU
    • For client mode use zenohd
    • For multicast mode use zenohd -e udp/224.0.0.225:7447 note zenohd v0.10.0-dev-23-g44875300 or newer required
  • Start Zenoh dds bridge on the Linux machine zenoh-bridge-dds -m client

FMU

  • Enable the Zenoh module on your FMU build CONFIG_DRIVERS_ZENOH.
  • Add a uORB topic to published i.e. zenoh config addpublisher sensor_combined sensor
  • Start Zenoh zenoh start

Companion/Linux

  • Make sure you've got ROS2 installed (in my case I've been testing ROS2 Galactic but newer should also work)
  • Clone https://github.com/PX4/px4_msgs and build px4_msgs
  • Source ROS2 and compiled px4_msgs
  • Type ros2 topic echo sensor px4_msgs/SensorCombined to receive msgs from the FMU
timestamp: 5101022267
gyro_rad:
- 0.00033584635821171105
- 0.001161606633104384
- 0.0029726973734796047
gyro_integral_dt: 4390
accelerometer_timestamp_relative: 0
accelerometer_m_s2:
- -0.1838383674621582
- -0.04610908403992653
- -9.762420654296875
accelerometer_integral_dt: 4390
accelerometer_clipping: 0
gyro_clipping: 1
accel_calibration_count: 1
gyro_calibration_count: 1

Current shortcomings

  • Naive CSV file method for storing configuration and publishers/subscribers, would be nice PX4 param system can be expanded to support custom key/value storage i.e. json/xml like.
  • No message checking i.e. different versions of PX4 might produce corrupted data
  • No rate limiting yet
  • No timesync
  • FMU-to-FMU communication no distinction between own msgs and from incoming from Zenoh
  • Zenoh 0.7.X based protocol, new 0.10.0 upcoming but probably stabilize around Q1 2024
  • Documentation, I would consider Zenoh for now to experimental when all stabalizes I think we could add documentation.

@dagar
Copy link
Member

dagar commented Aug 29, 2023

This will take a little bit to review, but in the meantime can you get it through CI cleanly?

Screenshot 2023-08-29 at 10 21 51 AM

@PetervdPerk-NXP
Copy link
Member Author

Hm to get Zenoh-pico to build, I think CMake 1.14 is mandatory need to check if CMake 1.13 might work as well.

.gitmodules Outdated Show resolved Hide resolved
@dagar
Copy link
Member

dagar commented Aug 29, 2023

Hm to get Zenoh-pico to build, I think CMake 1.14 is mandatory need to check if CMake 1.13 might work as well.

We can re-evaluate the actual requirement if you're hitting it somewhere. Some of the older containers might just need a bump.

@PetervdPerk-NXP PetervdPerk-NXP force-pushed the zenoh_px4_rb branch 2 times, most recently from 99dfef4 to 68bbdae Compare August 31, 2023 11:39
@Jaeyoung-Lim
Copy link
Member

Yay!

@PetervdPerk-NXP
Copy link
Member Author

These are the blocker for moving to CMake 3.14

CI task Container CMake version
mavros_mission_tests px4io/px4-dev-ros-melodic:2021-09-08 3.10.2
mavros_offboard_tests px4io/px4-dev-ros-melodic:2021-09-08 3.10.2
compile_linux_arm64 px4io/px4-dev-aarch64:2022-08-12 3.13.4
clang-tidy px4io/px4-dev-clang:2021-09-08 3.10.2

@PetervdPerk-NXP
Copy link
Member Author

PetervdPerk-NXP commented Sep 4, 2023

Okay CI is successful now, (CMake 3.9 works and rosidl)

I've added 2 targets that can Zenoh and communicate with ROS2

nxp_mr-canhubk3_zenoh
px4_fmu-v6x_zenoh
px4_sitl_zenoh

@dirksavage88
Copy link
Contributor

Okay CI is successful now, (CMake 3.9 works and rosidl)

I've added 2 targets that can Zenoh and communicate with ROS2

nxp_mr-canhubk3_zenoh
px4_fmu-v6x_zenoh
px4_sitl_zenoh

I would be interested if this could work on the fmuk66 target as well since zenoh pico is supposed to be lightweight?

@PetervdPerk-NXP
Copy link
Member Author

I would be interested if this could work on the fmuk66 target as well since zenoh pico is supposed to be lightweight?

Albeit zenoh-pico is lightweight the current implementation might still be too big for the fmuk66.
Probably we could tune the profile by disabling multicast, tune the buffers and take a subset of uORB (currently we can convert all uORB messages to Zenoh and vice-versa).

Personally I would like to develop and improve zenoh-pico for mr-canhubk344 or other bigger targets before moving over to smaller targets.

@PetervdPerk-NXP PetervdPerk-NXP force-pushed the zenoh_px4_rb branch 3 times, most recently from 19f2e7c to 3b5af6c Compare September 15, 2023 08:38
@PetervdPerk-NXP PetervdPerk-NXP force-pushed the zenoh_px4_rb branch 3 times, most recently from 7d8752b to 0480569 Compare September 28, 2023 07:14
@dagar dagar merged commit 019d232 into PX4:main Oct 18, 2023
86 checks passed
@DronecodeBot
Copy link

This pull request has been mentioned on Discussion Forum for PX4, Pixhawk, QGroundControl, MAVSDK, MAVLink. There might be relevant details there:

https://discuss.px4.io/t/zenoh-on-px4/35267/2

@uupks
Copy link

uupks commented Jan 31, 2024

Hi, i'm facing the problem when i try to make px4_sitl_zenoh.

[  7%] Generating px4/msg/ActionRequest.c, px4/msg/ActionRequest.h
[  8%] Built target cdr
idlc/bin/idlc: illegal option -- f cdrstream-desc
Usage: idlc [OPTIONS] FILE
Try 'idlc -h' for more information.

@PetervdPerk
Copy link
Contributor

That errors seems to indicate there's a problem with a preinstalled version of idlc and then the cmake builds.

@uupks
Copy link

uupks commented Feb 1, 2024

it seems like that idlc doesn't support "-f cdrstream-desc" option

@PetervdPerk-NXP
Copy link
Member Author

It does but you've got a "preinstalled" version. Are you by any chance running the px4 build after sourcing ros2?

@uupks
Copy link

uupks commented Feb 1, 2024

i build px4_sitl_zenoh with a new shell environment , now it works..

Thanks !!

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

Successfully merging this pull request may close these issues.

None yet

7 participants