tf problems; error: tf/transform_listener.h: No such file or directory [closed]

asked 2012-08-21 17:21:17 -0500

this post is marked as community wiki

This post is a wiki. Anyone with karma >75 is welcome to improve it.

Hello

I made a node that use a TF but when tried to compiled I got the following error. error: tf/transform_listener.h: No such file or directory

I include the tf dependency in the manifest.xml file, i;e

<depend package="tf"/>

So I dont know what is the problem

Any help?

This is my node

#include <ros/ros.h>
#include <tf/transform_listener.h>
#include "std_msgs/String.h"
#include "sensor_msgs/LaserScan.h"
#include <vector>
#include <iostream>
#include <fstream>
#include <ros/package.h>
#include "geometry_msgs/PoseWithCovarianceStamped.h"
#include "geometry_msgs/Quaternion.h"
#include "/opt/ros/fuerte/stacks/bullet/include/LinearMath/btScalar.h"
#include "/opt/ros/fuerte/stacks/bullet/include/LinearMath/btQuaternion.h"
#include "/opt/ros/fuerte/stacks/bullet/include/LinearMath/btMatrix3x3.h"
#include "std_msgs/Float64.h"

std::ofstream myfile;


int main(int argc, char** argv){
    ros::init(argc, argv, "my_tf_listener");
    ros::NodeHandle node;
    myfile.open ("/home/bojan/Desktop/PowRos/utils/pow_analyzer/src/distance.txt");
        myfile << "distance in m" <<  " "  "\n";


    tf::TransformListener listener;
    ros::Rate rate(10.0);

    while (node.ok())
    {
        tf::StampedTransform transform;
        try
            {

                     listener.lookupTransform("/base_link", "/door1",  
                                 ros::Time(0), transform);
                }

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

            }


    double x = transform.getOrigin().x();
        double y = transform.getOrigin().y();
    double dist = sqrt(x*x + y*y);
    ROS_INFO("dist = %f" , dist);
    myfile << dist << " " "\n";


    rate.sleep();
  }
  return 0;
};
edit retag flag offensive reopen merge delete

Closed for the following reason question is not relevant or outdated by tfoote
close date 2012-11-05 10:34:27

Comments

Something about your code has been badly mis-formatted; can you correct that, so we can see what's going on?

Mac gravatar image Mac  ( 2012-08-21 17:51:25 -0500 )edit

ok done it

Astronaut gravatar image Astronaut  ( 2012-08-21 18:11:04 -0500 )edit
1

Do you have the geometry stack installed on your development system? Does roscd tf work?

joq gravatar image joq  ( 2012-08-22 04:58:14 -0500 )edit

+1 for suggestion made by @joq. I think I have also managed to produce this error in the past by accidentally calling add_executable instead of rosbuild_add_executable in my CMakeLists file

piyushk gravatar image piyushk  ( 2012-08-22 09:39:16 -0500 )edit

Yes . roscd works. I have everything

Astronaut gravatar image Astronaut  ( 2012-08-22 14:18:31 -0500 )edit

@Astronaut: Hmm, you might have to put a tar of the package somewhere, and link it in the question. Given that tf is installed, it's not quite possible to figure out what the error might be given the current information.

piyushk gravatar image piyushk  ( 2012-08-23 06:07:54 -0500 )edit