Question

I am trying to subscribe from a ROS topic via QT Creator and am using a class method for the call back. Below is the code I am executing,

n.subscribe("gps_info", 1, &QNode::gpsCallback,this)

I am trying to subscribe to the topic gps_info and I want the method gpsCallback within the class QNode to be called. I am calling the subscribe code from the constructor of QNode. The code compiles successfully but it is not subscribing to the topic. I could confirm this from rxgraph.

Any idea why the gpsCallback method is not being called?

Was it helpful?

Solution

You have to specify the templates you need:

n.subscribe<msgType,QNode>("gps_info", 1, &QNode::gpsCallback,this);

To get the deatils, right-click on subscribe and choose 'follow details under cursor`.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top