compile error with tf transformation [closed]
Hi everybody,
I have written some codes as below:
#include <ros/ros.h>
#include <tf/transform_broadcaster.h>
#include <nav_msgs/Odometry.h>
int main(int argc,char ** argv){
ros::init(argc,argv,"odometry_publisher");
ros::NodeHandle n;
ros::Publisher pubOdom= n.advertise<nav_msgs::Odometry>("odom",50);
tf::TransformBroadcaster odomBroadcaster;
//some other codes
ros::Rate r(10);
while(n.ok()){
//some other codes
r.sleep();
}
//
return 0;
}
and put
rosbuild_add_executable(OdomOFPS1_X64 src/OdomOFPS1.cpp)
in the end of the "CMakeLists.txt" file.
There is an error when compile:
OdomOFPS1.cpp.o: In function `main':
src/OdomOFPS1.cpp:22: undefined reference to `tf::TransformBroadcaster::TransformBroadcaster()'
src/OdomOFPS1.cpp:127: undefined reference to `tf::TransformBroadcaster::sendTransform(geometry_msgs::TransformStamped_<std::allocator<void> > const&)'
collect2: error: ld returned 1 exit status
It seems like a link error,the compiler could not find the "tf::TransformBroadcaster" class.Should I put the source code of the tf package in my project and compile them together or solve this problem by some other way?