Open dp1140a opened 1 month ago
UPDATE: So it turns out you just need to pass in Subscription Option with a QOS Profile. I went back and looked at the PX4 Subscription example in C++ and saw they were using a QOS Profile. Thought I would try it and Voila!
So change
sub, err := msg.NewSensorGpsSubscription(pn.node, "/fmu/out/vehicle_gps_position",
nil,
func(msg *msg.SensorGps, info *rclgo.MessageInfo, err error) {
if err != nil {
pn.node.Logger().Errorf("failed to receive message: %v", err)
return
}
pn.node.Logger().Infof("Received: %#v", msg.Timestamp)
})
to
opts := &rclgo.SubscriptionOptions{
Qos: rclgo.QosProfile{
History: 1,
Depth: 5,
Reliability: 2,
Durability: 2,
Deadline: 0,
Lifespan: 0,
Liveliness: 0,
LivelinessLeaseDuration: 0,
AvoidRosNamespaceConventions: false,
},
}
sub, err := msg.NewSensorGpsSubscription(pn.node, "/fmu/out/vehicle_gps_position",
opts,
func(msg *msg.SensorGps, info *rclgo.MessageInfo, err error) {
if err != nil {
pn.node.Logger().Errorf("failed to receive message: %v", err)
return
}
pn.node.Logger().Infof("Received: %#v", msg.Timestamp)
})
AND IT WORKS!!! Sorry I'm pretty stoked.
I am trying to write a test to read a PX4 messages. Im running PX$ in SITL with Gazebo and the MicroXRCEAgent. I can see the topic "/fmu/out/vehicle_gps_position" and echo the data. When I run the PX$ subscriber example in C++ it reads the topic and I see:
In the console. This is what it should do.
But when I try to run the exact same subscriber in RCLGO nothing prints to the screen. No error nothing:
Heres the strange part. When I launch a separate Publisher on the same topic, the subscriber sees that message and prints it like it should.
So why is it not seeing the initial PX4 messages coming from PX4.
Steps to Recreate
Terminal1:
Terminal 2:
Terminal 3:
Modify the RCLGo Subscriber Example to use PX4 Messages and subscribe to the /fmu/out/vehicle_gps_position topic Terminal4:
Then if you like launch a publisher on the same topic and you will see that message get picked up.
For reference here is the code I am using for my subscriber, but I have also used the subscriber example in this repo.