Timesync in MicroDDS

Dear all,

I am trying to switch the flight controller ↔ companion computer communication from RTPS to microDDS with the latest release of PX4 1.13.2. I compiled the px4_fmu-v5_rtps target for the flight controller and started the micordds client on the flight controller. On the companion computer, I have ROS2 Humble and followed @JulianOes tutorial on how to run the microDDS bridge on ROS2. I see the topics on ROS2 and can even echo the VehicleState. So far, so good :slight_smile:

I noticed the Timesync message was deleted in one of the latest px4_msgs updates. Thus, it got not compiled and is not available in ROS2. However, I still see a Timsync message (in/out) in the topic list output and a TimesyncStatus (out). However, I do not receive any data on either of these topics. Can anyone explain how the time sync between the companion computer and the flight controller works with microDDS or point me to a tutorial?

Looking forward to getting in touch with you. Best,
Julia

List of standard topics published by PX4 1.13.2:

/fmu/in/DebugArray
/fmu/in/DebugKeyValue
/fmu/in/DebugValue
/fmu/in/DebugVect
/fmu/in/OffboardControlMode
/fmu/in/OnboardComputerStatus
/fmu/in/OpticalFlow
/fmu/in/PositionSetpoint
/fmu/in/PositionSetpointTriplet
/fmu/in/TelemetryStatus
/fmu/in/Timesync
/fmu/in/TrajectoryBezier
/fmu/in/TrajectorySetpoint
/fmu/in/VehicleCommand
/fmu/in/VehicleLocalPositionSetpoint
/fmu/in/VehicleMocapOdometry
/fmu/in/VehicleTrajectoryBezier
/fmu/in/VehicleTrajectoryWaypoint
/fmu/in/VehicleVisualOdometry
/fmu/out/CollisionConstraints
/fmu/out/SensorCombined
/fmu/out/Timesync
/fmu/out/TimesyncStatus
/fmu/out/TrajectoryWaypoint
/fmu/out/VehicleControlMode
/fmu/out/VehicleOdometry
/fmu/out/VehicleStatus
/fmu/out/VehicleTrajectoryWaypointDesired

Hi @Julia_Nitsch! Nice to see an ASL alumni here :smile:

You would need to use a newer version of PX4 (main) which uses XRCE-DDS and has better time synchronization. PX4 has moved away from fastRTPS After v1.13, and the px4_msgs have been updated against main

Hey,

haha yes the world is simply too small :sweat_smile:

Great thanks for the information! You are right, on the current main-branch the micro-dds has a timesync synchronization which is missing on 1.13.2. I will look into the sync in the main.

Hey,

many thanks for your hint with the time sync, you are right the timesync was added later on. Thus I tried to compile the current main and connect it to my companion computer, however I cannot establish a microdds communication (simulation is working fine).
On the main, I ran make px4_fmu-v5 upload and adopted the rcS to work with the serial connection microdds_client start -t serial -d /dev/ttyS1 -b 921600 -l. With this setting, my companion computer does not find any published topic when I run ros2 run micro_ros_agent micro_ros_agent serial -D /dev/ttyTHS0 -b 921600.
However, this setup is working fine on 1.13.2 when running make px4_fmu-v5_rtps upload.

Am I missing here something?

@Julia_Nitsch Some things you might want to check

  • Were you running the micro_ros_agent also with RTPS? Have you checked on the fmu side if no other mavlink instance is using ttyS1?
  • In case you are using the snap packaged micro_ros_agent , you might need to grant hardware access
  1. No I was not running the micro_ros_agent with RTPS. For the RTPS communication I used the old micrortps_agent
  2. Yes, I already checked that there is no Mavlink instance running on the fmu and accidentally blocks the ttys1
  3. No I built the micro_ros_agent from source like explained in the tutorial and I mean it is working with the 1.13.2 thus probably not a permission problem

The -l flag is broken microdds_client: fix -l flag and add -c for custom participant configuration by bkueng Β· Pull Request #21150 Β· PX4/PX4-Autopilot Β· GitHub

Try without it :slight_smile:

2 Likes

Oh what a great hint! Many thanks that did the trick :+1:

… and timesync messages are working too and giving me reasonable values for RTT.

Hi all.

I have some question related to time syncing between PX4 and ROS 2.

I am setting up visual inertial SLAM system on a drone, and as you may know the camera images and the IMU time stamps have to be accurate for a usable and successful estimation.

I am using the v1.14beta vesion of PX4, and ROS 2 humble. I use MicroXRCEAgent to communicate with PX4. I get the IMU measurements from the fmu/out/sensor_combined topic, which look like this

timestamp: 1686500596970849
gyro_rad:
- -8.57829737419772e-15
- 1.4755774727093218e-12
- 6.035771080086626e-18
gyro_integral_dt: 4000
accelerometer_timestamp_relative: 0
accelerometer_m_s2:
- -6.62371348880697e-08
- 1.710423020995222e-07
- -9.800002098083496
accelerometer_integral_dt: 4000
accelerometer_clipping: 0
gyro_clipping: 0
accel_calibration_count: 0
gyro_calibration_count: 1

Now, the important part is the timestamp field of the message in the topic. Is this timestamp of the PX4 or the ROS side?

My camera images are published with ROS timestamps, and of course, the IMU readings need to be published with ROS timestamps as well in order for the SLAM software to work properly.

If the timestamp in the fmu/out/sensor_combined corresponds to PX4 clock, how can I synchronize it with ROS clock ?

@Jaeyoung-Lim @Julia_Nitsch any hint is highly appreciated.

Thanks!

Hi @Mzahana
Please see this:

Thanks a lot @Benja !

That makes it easier. So, now what I understand is that, in ROS on the companion computer, I can use the timestamp in any of the fmu/out/* topics without any modifications.

Hi Mzahana,

first of all sorry for my super late response. In theory that should work out of the box. However, I would still recommend you to double check the timestamps to be sure. I had some trouble due to delays (most likely due to overloaded system) For example, if you are syncing the camera for your SLAM algorithm, you could use some AR tags and compare the visual movement with the one detected from the IMU.

HTH,
Julia

Hi @Julia_Nitsch

Thank you very much for your reply.

I am going to use a stereo camera from Arducam and the IMU from the Orange Cube with the isaac_ros_visual_slam. I will first do the calibration process using Kalibr, then test the SLAM system. I will share my findings once done.

Mohamed