Ask Your Question
1

Why cant initialize tf2_ros::TransformListenter in hydro?

asked 2013-09-17 07:36:20 -0600

destogl gravatar image

updated 2014-01-28 17:17:58 -0600

ngrennan gravatar image

When I try to compile node with folowing lines (this is only a part of code):

// ROS includes
#include <ros/ros.h>
#include <message_filters/subscriber.h>
#include <message_filters/time_synchronizer.h>
#include <tf/transform_listener.h>
#include <tf2_ros/buffer.h>
#include <tf2_ros/transform_listener.h>
#include <sensor_msgs/PointCloud.h>
#include <laser_geometry/laser_geometry.h>

// ROS message includes
#include <sensor_msgs/LaserScan.h>


//####################
//#### node class ####
class NodeClass
{
    //
    public:

    ros::NodeHandle nodeHandle;
        // topics to publish
        message_filters::Subscriber<sensor_msgs::LaserScan> * topicSub_LaserFront;
    message_filters::Subscriber<sensor_msgs::LaserScan> * topicSub_LaserBack;
        message_filters::TimeSynchronizer<sensor_msgs::LaserScan, sensor_msgs::LaserScan> *sync;
    tf::TransformListener listener_;
    tf2_ros::Buffer buffer;
    tf2_ros::TransformListener tf_listener(buffer);
    laser_geometry::LaserProjection projector_;
    ros::Publisher topicPub_LaserUnified;

i get ERROR: "buffer" is not a type:

catkin_make --pkg cob_sick_s300 
Base path: /home/user/Workspace/care-o-bot
Source space: /home/user/Workspace/care-o-bot/src
Build space: /home/user/Workspace/care-o-bot/build
Devel space: /home/user/Workspace/care-o-bot/devel
Install space: /home/user/Workspace/care-o-bot/install
####
#### Running command: "make cmake_check_build_system" in "/home/user/Workspace/care-o-bot/build"
####
####
#### Running command: "make -j4 -l4" in "/home/user/Workspace/care-o-bot/build/cob_driver/cob_sick_s300"
####
[  0%] [ 66%] Built target cob_sick_s300
[100%] Built target cob_scan_filter
Building CXX object cob_driver/cob_sick_s300/CMakeFiles/cob_unified_scan_publisher.dir/ros/src/cob_unified_scan_publisher.cpp.o
/home/stogl/Workspace/care-o-bot/src/cob_driver/cob_sick_s300/ros/src/cob_unified_scan_publisher.cpp:88:41: Fehler: »buffer« ist kein Typ
make[2]: *** [cob_driver/cob_sick_s300/CMakeFiles/cob_unified_scan_publisher.dir/ros/src/cob_unified_scan_publisher.cpp.o] Error 1
make[1]: *** [cob_driver/cob_sick_s300/CMakeFiles/cob_unified_scan_publisher.dir/all] Error 2
make: *** [all] Error 2
Invoking "make" failed
edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted
2

answered 2014-07-23 18:53:11 -0600

destogl gravatar image

Ok now I know...

I tried to initialise it in declaration part of the NodeClass not inside any method. And this just doesn't work in C++. If you put it in constructor it will work like in the following example:

// ROS includes
#include <ros/ros.h>
#include <message_filters/subscriber.h>
#include <message_filters/time_synchronizer.h>
#include <tf/transform_listener.h>
#include <tf2_ros/buffer.h>
#include <tf2_ros/transform_listener.h>
#include <sensor_msgs/PointCloud.h>
#include <laser_geometry/laser_geometry.h>

// ROS message includes
#include <sensor_msgs/LaserScan.h>


//####################
//#### node class ####
class NodeClass
{
    //
    public:

    NodeClass();

    ros::NodeHandle nodeHandle;
    // topics to publish
    message_filters::Subscriber<sensor_msgs::LaserScan> * topicSub_LaserFront;
    message_filters::Subscriber<sensor_msgs::LaserScan> * topicSub_LaserBack;
    message_filters::TimeSynchronizer<sensor_msgs::LaserScan, sensor_msgs::LaserScan> *sync;
    tf::TransformListener listener_;
    tf2_ros::Buffer buffer;
    tf2_ros::TransformListener* tf_listener;
    laser_geometry::LaserProjection projector_;
    ros::Publisher topicPub_LaserUnified;

}

NodeClass::NodeClass() {

    tf_listener = new TransformListener(buffer);
}
edit flag offensive delete link more
1

answered 2013-09-17 08:23:06 -0600

tfoote gravatar image

You probably have some sort of symbol collision? Please if you are having a compile issue copy and paste the error.

This example program compiles fine. (It won't run as wanted but that's not your error.)

#include <tf2_ros/buffer.h>
#include <tf2_ros/transform_listener.h>


int main(void)
{

tf2_ros::Buffer buffer;
tf2_ros::TransformListener tf_listener(buffer);

 return 0;
}
edit flag offensive delete link more

Comments

I completely forgot on this issue because I worked on something else. It will be checked as soon as possible, and I will give a feedback about solution! Thanks for your answer :)

destogl gravatar imagedestogl ( 2014-03-19 23:40:32 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2013-09-17 07:36:20 -0600

Seen: 846 times

Last updated: Jul 23 '14