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

TimeSynchronizer [compilation error ]

asked 2014-09-02 16:56:01 -0500

bvbdort gravatar image

updated 2014-09-03 02:56:41 -0500

Hi all,

i am getting compilation error while using TimeSynchronizer.

i saw similar question , but it didnt solve.

thank you.


error: ‘TimeSynchronizer’ does not name a type
In constructor ‘Detectchange::Detectchange()’:
error: ‘timesync’ was not declared in this scope
error: expected type-specifier before ‘TimeSynchronizer’
error: expected ‘;’ before ‘TimeSynchronizer’

here is my code snippet.


class myclass
{
public:            
//some stuff            
private:
message_filters::Subscriber<sensor_msgs::LaserScan>* laser_scan_sub;
message_filters::Subscriber<geometry_msgs::PoseStamped>* pose_sub;
TimeSynchronizer<sensor_msgs::LaserScanConstPtr, geometry_msgs::PoseStampedConstPtr> *timesync;
 }

 myclass::myclass()
 {                
 laser_scan_sub  = new message_filters::Subscriber<sensor_msgs::LaserScan>(nh_, "/ms_front_laser", 1);
 pose_sub          = new message_filters::Subscriber<geometry_msgs::PoseStamped>(nh_, "/pose", 1);
 timesync = new TimeSynchronizer<sensor_msgs::LaserScanConstPtr, geometry_msgs::PoseStampedConstPtr>                         (laser_scan_sub, pose_sub, 50);
  timesync->registerCallback(boost::bind(&myclass::laserReceived, this, _1, _2));
 }

 void myclass::laserReceived(const sensor_msgs::LaserScanConstPtr& laser_scan, const geometry_msgs::PoseStampedConstPtr& estimate_pose)
            {
            // some stuff
            }

    int main(int argc, char** argv)
    {
      ros::init(argc, argv, "myclass");
      ros::NodeHandle nh;

      myclass mc;

      ros::spin();          
      return(0);
    }
edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
0

answered 2014-09-02 18:20:17 -0500

ahendrix gravatar image

updated 2014-09-03 07:04:52 -0500

bvbdort gravatar image

Are you sure you're including the proper header and using the namespace properly?

    #include <message_filters/time_synchronizer.h>

its problem with namespace and template arguments finally solved by

timesync= new message_filters::TimeSynchronizer<sensor_msgs::LaserScan, geometry_msgs::PoseStamped>(*laser_scan_sub, *pose_sub, 50);  // solved the problem :)
edit flag offensive delete link more

Comments

I have header file included and tried with using namespace message_filters; , it didn solve the problem.

bvbdort gravatar image bvbdort  ( 2014-09-03 02:56:14 -0500 )edit

Do you get a different error message when you add using namespace message_filters; ?

ahendrix gravatar image ahendrix  ( 2014-09-03 03:14:46 -0500 )edit

yes, it was from boost i think, you can view the error here

bvbdort gravatar image bvbdort  ( 2014-09-03 03:30:02 -0500 )edit

This looks like the critical error message: no known conversion for argument 2 from 'const boost::shared_ptr<const boost::shared_ptr<const sensor_msgs::LaserScan_<std::allocator<void> > > >' to 'const boost::shared_ptr<const sensor_msgs::LaserScan_<std::allocator<void> > >&'

ahendrix gravatar image ahendrix  ( 2014-09-03 04:26:17 -0500 )edit

That suggests that you have the template arguments to your synchronizer wrong. According to the tutorial, the template arguments to the synchronizer should be message types, not MessageConstPtrs.

ahendrix gravatar image ahendrix  ( 2014-09-03 04:28:08 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2014-09-02 16:56:01 -0500

Seen: 2,449 times

Last updated: Sep 03 '14