Customized Communication ROS2 on Raspberry Pi 4 and PX4(v1.14) on Pixhawk 6x

Dear all,
I’m currently working on a project where I need to let the ROS2 Node on Raspi and PX4 on Pixhawk 6x communicate with a customized message type PixhawkToRaspberryPi.msg, which is defined as below:

uint64 timestamp # time since system start (microseconds)

uint8 INDEX_WILDCARD_1 = 0
uint8 INDEX_WILDCARD_2 = 1
uint8 INDEX_WILDCARD_3 = 2
uint8 INDEX_WILDCARD_4 = 3
uint8 INDEX_WILDCARD_5 = 4
uint8 INDEX_WILDCARD_6 = 5
uint8 INDEX_WILDCARD_7 = 6
uint8 INDEX_WILDCARD_8 = 7

float32[16] msg_payload

Firstly on the PX4 side I stored this message file in my PX4 source tree: ~/mypx4/PX4-Autopilot/msg, and then I modified the dds_topics.yaml adding the following descriptions under the publication segment:

publications:

  • topic: /fmu/out/pixhawk_to_raspberry_pi
    type: px4_msgs::msg::PixhawkToRaspberryPi

Then I make the default firmware and upload it onto Pixhawk 6x using the command:

make px4_fmu-v6x_default upload

On the ROS2 side (on Raspi) I followed this tutorial ROS 2 User Guide | PX4 Guide (main) , where I created the example ros2 workspace.

I also cloned the msg file PixhawkToRaspberryPi.msg into the folder ~/ws_sensor_combined/src/px4_msgs/msg and built the whole workspace successfully.

For the test of the communication I started an agent on Rasberry Pi with the command:

MicroXRCEAgent udp4 -p 8888

and started a client on Pixhawk with the command in Mavlink Console:

uxrce_dds_client start -t udp -p 8888 -h 172.16.20.223

At last I run the following command to check the running ros2 topic on Raspi and it showed:

ubuntu@ubuntu:~/ws_sensor_combined$ ros2 topic list
/fmu/in/obstacle_distance
/fmu/in/offboard_control_mode
/fmu/in/onboard_computer_status
/fmu/in/sensor_optical_flow
/fmu/in/telemetry_status
/fmu/in/trajectory_setpoint
/fmu/in/vehicle_attitude_setpoint
/fmu/in/vehicle_command
/fmu/in/vehicle_mocap_odometry
/fmu/in/vehicle_rates_setpoint
/fmu/in/vehicle_trajectory_bezier
/fmu/in/vehicle_trajectory_waypoint
/fmu/in/vehicle_visual_odometry
/fmu/out/failsafe_flags
/fmu/out/position_setpoint_triplet
/fmu/out/sensor_combined
/fmu/out/timesync_status
/fmu/out/vehicle_attitude
/fmu/out/vehicle_control_mode
/fmu/out/vehicle_local_position
/fmu/out/vehicle_odometry
/fmu/out/vehicle_status
/parameter_events
/rosout

wherein the msg I created was NOT listed, I also found that the following topics defined indds_topics.yaml were either not running in ros2 workspace:

/fmu/out/collision_constraints
/fmu/out/vehicle_global_position
/fmu/out/vehicle_gps_position
/fmu/out/vehicle_trajectory_waypoint_desired

Have I done something wrong or missed some steps?
Or maye the ros2 topic was not listed simply because no data was in it? if so how could I run a test to chek the communication?
I would appreciate it if someone could give me any suggestions and idea.
Thank you in advance!
Y.Z.