@@ -45,6 +45,7 @@ EOD_ROS::EOD_ROS(ros::NodeHandle nh, ros::NodeHandle nh_p){
4545 nh_p_.param (" use_actual_time" , use_actual_time, false );
4646 nh_p_.param (" publish_markers" , publish_markers, false );
4747 nh_p_.param (" broadcast_tf" , broadcast_tf, false );
48+ nh_p_.param (" allowed_lag_sec" , allowed_lag_sec, 0.1 );
4849
4950 std::string object_base_path;
5051 nh_p_.getParam (" object_base" ,object_base_path);
@@ -136,6 +137,14 @@ bool EOD_ROS::check_time(ros::Time stamp){
136137}
137138
138139
140+ bool EOD_ROS::check_lag (ros::Time stamp, double & lag){
141+ if ( allowed_lag_sec == 0 )
142+ return true ;
143+ lag = (ros::Time::now () - stamp).toSec ();
144+ return lag <= allowed_lag_sec;
145+ }
146+
147+
139148cv::Mat EOD_ROS::getK (const sensor_msgs::CameraInfoConstPtr& info_msg){
140149 cv::Mat K = cv::Mat::zeros (3 , 3 , CV_64F);
141150 for (size_t i=0 ; i<3 ; i++) {
@@ -162,8 +171,12 @@ void EOD_ROS::rgb_info_cb(const sensor_msgs::ImageConstPtr& rgb_image, const sen
162171 if ( !check_time (ros::Time::now ()) ) {
163172 ROS_WARN (" Skipped frame" );
164173 return ;
165- }
166- // TODO add possibility to exclude old stamp images (if detection goes to slow)
174+ }
175+ double lag;
176+ if ( !check_lag (rgb_image->header .stamp , lag) ) {
177+ ROS_WARN (" Dropped frame, lag = %f" , lag);
178+ return ;
179+ }
167180 cv::Mat rgb;
168181 try {
169182 rgb = cv_bridge::toCvCopy (rgb_image, " bgr8" )->image ;
@@ -184,6 +197,11 @@ void EOD_ROS::rgbd_info_cb(const sensor_msgs::ImageConstPtr& rgb_image, const se
184197 ROS_WARN (" Skipped frame" );
185198 return ;
186199 }
200+ double lag;
201+ if ( !check_lag (rgb_image->header .stamp , lag) ) {
202+ ROS_WARN (" Dropped frame, lag = %f" , lag);
203+ return ;
204+ }
187205 // TODO add possibility to exclude old stamp images (if detection goes to slow)
188206 cv::Mat rgb;
189207 try {
0 commit comments