ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

You could do something like this:

ros::Subscriber pos_sub_uav1 = nh.subscribe<geometry_mgs::PoseStamped>("uav1/mavros/local_position/pose", 10, boost::bind(&follow, _1, "uav1"));
ros::Subscriber pos_sub_uav1 = nh.subscribe<geometry_mgs::PoseStamped>("uav1/mavros/local_position/pose", 10, boost::bind(&follow, _1, "uav2"));
...
void follow(const geometry_msgs::PoseStamped::ConstPtr& msg, const std::string &uav) { }

You might also want to just use a time sychronizer.

You could do something like this:

ros::Subscriber pos_sub_uav1 = nh.subscribe<geometry_mgs::PoseStamped>("uav1/mavros/local_position/pose", 10, boost::bind(&follow, _1, "uav1"));
ros::Subscriber pos_sub_uav1 pos_sub_uav2 = nh.subscribe<geometry_mgs::PoseStamped>("uav1/mavros/local_position/pose", nh.subscribe<geometry_mgs::PoseStamped>("uav2/mavros/local_position/pose", 10, boost::bind(&follow, _1, "uav2"));
...
void follow(const geometry_msgs::PoseStamped::ConstPtr& msg, const std::string &uav) { }

You might also want to just use a time sychronizer.