Ask Your Question
0

tf_listener error transform.tf::Transform::getOrigin 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; // ##
 //add_turtle.call(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;
try{
  listener.lookupTransform("/obstacle/right_up_corner", "/base_link",ros::Time(0), transform);

  cloud.header.stamp = ros::Time::now();
  cloud.header.frame_id = "sensor_frame";
  cloud.points.resize(num_points);
  //we'll also add an intensity channel to the cloud
  cloud.channels.resize(1);
  cloud.channels[0].name = "intensities";
  cloud.channels[0].values.resize(num_points);
  //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;//#
   }

  cloud_pub.publish(cloud);

   ++count;


}
catch (tf::TransformException ex){
  ROS_ERROR("%s",ex.what());
}

rate.sleep();
 }
  return 0;
};

I got the following error

transform.tf::Transform::getOrigin’ 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
2

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

Comments

Thank you it worked

RSA gravatar image RSA  ( 2014-04-14 01:49:13 -0500 )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

1 follower

Stats

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

Seen: 579 times

Last updated: Apr 13 '14