Help with PX4 topic subscriber using MATLAB

I am having an issue with subscribing to px4 topics using MATLAB’s ROS toolbox. I have generated the PX4 custom messages in MATLAB. It appears no message is actually passed through.

node1 = ros2node('matlab');
node2 = ros2subscriber(node1,'/fmu/out/sensor_combined')

Above results in "ros2subscriber with properties:

    TopicName: '/fmu/out/vehicle_odometry'
LatestMessage: []
  MessageType: 'px4_msgs/VehicleOdometry'
NewMessageFcn: []
      History: 'keeplast'
        Depth: 10
  Reliability: 'reliable'
   Durability: 'volatile'"

LatestMessage should probably have :[1x1 struct] or something along those lines. Does anyone have an idea of what the issue is? Is there a px4_msgs download specifically for custom messages in the ROS toolbox ?

Hi @I_R

Start by using the right QoS setting
in the subscriber, Manage Quality of Service Policies in ROS 2 - MATLAB & Simulink.
maybe it is just that.

Moreover, I would expect that you must wait a bit after creating the subscriber before actually having available messages.

1 Like

Yup, you are correct. Thank you!

1 Like