undefined reference to `tf::TransformBroadcaster::TransformBroadcaster()'
Hi all
when I learn the tf with ros wiki, some questions happened.
it said:undefined reference to tf::TransformBroadcaster::TransformBroadcaster()
But at the CMakeLists.txt I add tf in the find package and the catkin_package.
at package.xml I add <build_depend>tf</build_depend> <build_export_depend>tf</build_export_depend>
and <exec_depend>tf</exec_depend>
I dont kown why undefined
Thanks all
this is my code.
#include<iostream>
#include<string>
#include<cstring>
#include"ros/ros.h"
#include <tf/transform_broadcaster.h>
#include <turtlesim/Pose.h>
using namespace std;
string turtle_name;
void poseCallback(const turtlesim::PoseConstPtr &msg)
{
static tf::TransformBroadcaster br;
tf::Transform transform;
transform.setOrigin(tf::Vector3(msg->x, msg->y, 0.0));
tf::Quaternion q;
q.setRPY(0, 0, msg->theta);
transform.setRotation(q);
br.sendTransform(tf::StampedTransform(transform, ros::Time::now(), "world", turtle_name));
}
int main(int argc, char **argv)
{
ros::init(argc, argv, "my_tf_broadcaster");
if(argc != 2)
{
ROS_ERROR("need turtle name as argument");
return -1;
}
turtle_name = argv[1];
ros::NodeHandle node;
ros::Subscriber sub = node.subscribe(turtle_name + "/pose", 10, &poseCallback);
ros::spin();
return 0;
}
This is almost certainly an issue with your CMakeLists.txt file. Would be helpful to include your CMakeLists.txt and package.xml (minus any boilerplate comments)
Can you show us your source code too. Do you have the
#include <tf/transform_broadcaster.h>
statement at the top of your source code?Yes I have the #include <tf transform_broadcaster.h="">.this is my source code.JUst like the turtorials of tf #include"ros/ros.h" #include <tf transform_broadcaster.h=""> #include <turtlesim pose.h=""> string turtle_name; void poseCallback(const turtlesim::PoseCo{ static tf::TransformBroadcaster br;
@jarvisschultz what's the mean of minus any boilerplate comments? I dont understans, please.
When you create a CMakeLists.txt and package.xml using
catkin_create_pkg
there are a bunch of comments in both files that we don't need to see. These are often referred to as "boilerplate". Getting rid of these is good practice to try and keep questions as short as possible.