using same callback function with more than one subs node
I want to use information received from the different nodes in one callback function. I am not sure. For example my callback function
void follow(const geometry_msgs::PoseStamped::ConstPtr& fmsg, const geometry_msgs::PoseStamped::ConstPtr& gmsg ){ #and do something with than info}
Subscribers
ros::Subscriber pos_sub_uav1 = nh_uav1.subscribe<geometry_mgs::PoseStamped>
("uav1/mavros/local_position/pose", 10, follow);
ros::Subscriber pos_sub_uav2 = nh_uav2.subscribe<geometry_mgs::PoseStamped>
("uav2/mavros/local_position/pose", 10, follow);
One way I think of is to make separate callback functions for each subscriber node and then receive messages from corresponding nodes, store info in some global variable and the use other function for manipulation of those variables or there is a better way to do this.