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

tf_listener error does not have class type

asked 2014-04-13 20:52:51 -0500

RSA gravatar image

Hello, I used the "Writing a tf listener (C++)" tutorial and Publishing Sensor Streams Over ROS tutorial and I created a sensor_msgs/pointcloud msg after listening to tfs... and the my code is shown bellow:

#include <ros/ros.h>
#include <tf/transform_listener.h>
//#include <turtlesim/Velocity.h>
 #include <geometry_msgs/Twist.h> 
 #include <turtlesim/Spawn.h>
 #include "sensor_msgs/PointCloud.h"
 #include "tf/message_filter.h"
#include "laser_geometry/laser_geometry.h"

int main(int argc, char** argv){
 ros::init(argc, argv, "my_tf_listener");
 ros::NodeHandle node;
 //ros::service::waitForService("spawn");// ##
 //ros::ServiceClient add_turtle = node.serviceClient<turtlesim::Spawn>("spawn"); //##
 //turtlesim::Spawn srv; // ##
 //; // ##
 ros::Publisher cloud_pub = node.advertise<sensor_msgs::PointCloud>("cloud", 50);
 unsigned int num_points = 100;
 tf::TransformListener listener;
  int count = 0;
  ros::Rate rate(10.0);
  sensor_msgs::PointCloud cloud;
  while (node.ok()){
   tf::StampedTransform transform;
  listener.lookupTransform("/obstacle/right_up_corner", "/base_link",ros::Time(0), transform);

  cloud.header.stamp = ros::Time::now();
  cloud.header.frame_id = "sensor_frame";
  //we'll also add an intensity channel to the cloud
  cloud.channels[0].name = "intensities";
  //cloud.points.x = transform.getOrigin.x();
  //cloud.points.y = transform.getOrigin.y();
  //cloud.points.z = transform.getOrigin.z();
  // generate some fake data for our point cloud
  for(unsigned int i = 0; i < num_points; ++i){
   cloud.points[i].x =transform.getOrigin.x();// 1 + count;
   cloud.points[i].y =transform.getOrigin.y();// 2 + count;
   cloud.points[i].z =transform.getOrigin.z();// 3 + count;
   cloud.channels[0].values[i] = 100 + count;//#



catch (tf::TransformException ex){

  return 0;

I got the following error’ does not have class type

What is the error in this code ?

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted

answered 2014-04-13 22:48:00 -0500

updated 2014-04-13 22:52:22 -0500

getOrigin() is a function of the tf::Transform class and as such has to be called with trailing (), indicating it is a function with 0 arguments.

You should really try searching for this kind of compile errors, as those are typical novice C++ mistakes that happened to many people before. Googling "does not have class type" gives you the correct answer pretty quickly.

edit flag offensive delete link more


Thank you it worked

RSA gravatar image RSA  ( 2014-04-14 01:49:13 -0500 )edit

Question Tools

1 follower


Asked: 2014-04-13 20:52:51 -0500

Seen: 687 times

Last updated: Apr 13 '14