ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
If you're using roscpp, you can use a callback with the MessageEvent
type and ignore messages received too far in the past:
void callback(const ros::MessageEvent<geometry_msgs::Twist>& event)
{
const std::string& publisher_name = event.getPublisherName();
ros::Time receipt_time = event.getReceiptTime();
ROS_INFO("Got a msg at time %f from publisher: %s",
receipt_time.toSec(), publisher_name.c_str());
// Compare receipt_time with ros::Time::now() to ignore too old messages
const geometry_msgs::Twist::ConstPtr msg = event.getConstMessage();
}