Naming a node while playing from rosbag [closed]
Greetings
As a part of my application logic I have a single callback to obtain data from multiple topics from multiple nodes that are subscribed. Each topic has the same message type.
void callBackName(
const ros::MessageEvent<geometry_msgs::PoseWithCovarianceStamped>& any_node)
I am disambiguating the node name inside the callback function using.
const std::string& node_name = any_node.getPublisherName();
Sometimes we do unit test the application logic using recorded rosbags just by executing the subscriber node. However when we start playing rosbag, under the topic graph a random node name is created viz. play_<timestamp of recording>
and hence the callBackName logic fails as the node name does not match the publisher node name as it would appear for a fully integrated system where the publisher nodes are also executing.
Is there a way to impart a suitable node name while playing the rosbag so that the node name disambiguation logic works as it should in a fully integrated system.
This is going to be super pedantic, for which I apologise, but for anyone reading this in the future: this is exactly one of those examples which shows why anonymous publish-subscribe should not be broken or circumvented by (trying to) write special logic for nodes with particular names.
This is not a critique directed at the OP, nor at the system he's working with. There are probably valid reasons why it was constructed the way it is constructed. Just make absolutely sure, when intending to create a similar setup, you need to know the name of the publisher -- instead of something like the location where sensor data was captured (for example). Those are different things, and there are other ways to get that sort of information (TF for instance).