tf2_ros::Buffer causes linking error
Hi, I wanted to use tfListener in my .cpp file but when i declare an object of tf2_ros::Buffer class ide gives a linking error; however, if I comment that line out error dissappears. I'm sending code and error. My rosdistro: melodic, OS: Ubuntu 18.04.4 LTS gcc: gcc (Ubuntu 7.4.0-1ubuntu1~18.04.1) 7.4.0 Linux distro: Linux version 4.15.0-88-generic (buildd@lgw01-amd64-036) (gcc version 7.4.0 (Ubuntu 7.4.0-1ubuntu1~18.04.1)) #88-Ubuntu SMP Tue Feb 11 20:11:34 UTC 2020 Kernel: 4.15.0-88-generic Ide:Clion
assignment2.cpp:
include "ros/ros.h"
include "std_msgs/Float32.h"
include "geometry_msgs/PoseStamped.h"
include "geometry_msgs/PoseArray.h"
include "sensor_msgs/PointCloud2.h"
include "std_msgs/String.h"
include "std_msgs/Float32.h"
include "kdl/chain.hpp"
include "kdl/chainfksolver.hpp"
include "kdl/chainfksolverpos_recursive.hpp"
include "kdl/chainiksolverpos_lma.hpp"
include "kdl/chainiksolvervel_pinv_givens.hpp"
include "kdl/chainiksolverpos_nr_jl.hpp"
include "kdl/frames_io.hpp"
include "tf2_ros/transform_listener.h"
include "tf2_sensor_msgs/tf2_sensor_msgs.h"
include "tf2_geometry_msgs/tf2_geometry_msgs.h"
include "tf2_ros/message_filter.h"
include "message_filters/subscriber.h"
include "tf2_ros/buffer.h"
include "tf2_ros/buffer_client.h"
include "tf2_ros/buffer_interface.h"
include "tf2_ros/buffer_server.h"
include "tf2_ros/message_filter.h"
include "tf2_ros/static_transform_broadcaster.h"
include "tf2_ros/transform_broadcaster.h"
include <geometry_msgs transformstamped.h="">
include <vector>
define UR10_DOF 6
geometry_msgs::Pose calculatedPosition;
void func1(const sensor_msgs::PointCloud2& pointCloud) { ros::NodeHandle nodeHandle; tf2_ros::Buffer tfBuffer; //tf2_ros::TransformListener tfListener(tfBuffer);
/*ros::Rate rate(10.0);
while (nodeHandle.ok()) {
sensor_msgs::PointCloud2 transformStamped;
try {
tfBuffer.lookupTransform("UR10_base",
"kinect_depth", ros::Time(0));
} catch (tf2::TransformException &exception) {
ROS_WARN("%s", exception.what());
ros::Duration(1.0).sleep();
continue;
}
rate.sleep();
}*/
}
void func2(const std_msgs::String& string) {
}
void func3(const std_msgs::Float32& float1) {
}
void func4(const std_msgs::Float32& float2) {
}
void endEffectorPositionCallback(const geometry_msgs::PoseStampedConstPtr& endEffectorPositionMessage) { std::cout << "End Effector Position :" << "[ "<< endEffectorPositionMessage->pose.position.x << " , " << endEffectorPositionMessage->pose.position.y << " , " << endEffectorPositionMessage->pose.position.z << " ]" << std::endl; }
KDL::Chain initChainUR10() { KDL::Chain chain;
chain.addSegment(KDL::Segment(KDL::Joint(KDL::Joint::RotZ),KDL::Frame(KDL::Rotation::RPY(0,-KDL::PI/2,0), KDL::Vector( -0.09265011549, 0, 0.0833499655128 ))));
chain.addSegment(KDL::Segment(KDL::Joint(KDL::Joint::RotZ),KDL::Frame(KDL::Rotation::RPY(0,0,0), KDL::Vector( 0.612088978291, 0, 0.0196119993925 ))));
chain.addSegment(KDL::Segment(KDL::Joint(KDL::Joint::RotZ),KDL::Frame(KDL::Rotation::RPY(0,0,0), KDL::Vector( 0.572199583054, 0, -0.00660470128059 ))));
chain.addSegment(KDL::Segment(KDL::Joint(KDL::Joint::RotZ),KDL::Frame(KDL::Rotation::RPY(0,KDL::PI/2,0), KDL::Vector( 0.0572912693024, 0,0.0584142804146 ))));
chain.addSegment(KDL::Segment(KDL::Joint(KDL::Joint::RotZ),KDL::Frame(KDL::Rotation::RPY(0,-KDL::PI/2,0), KDL::Vector( -0.0573025941849, 0,0.0583996772766))));
chain.addSegment(KDL::Segment(KDL::Joint(KDL::Joint::RotZ),KDL::Frame(KDL::Rotation::RPY(0,0,0), KDL::Vector( 0, 0, 0.110513627529 ))));
return chain;
}
int main(int argc, char **argv) { //ROS_INFO_STREAM("321"); ros::init(argc,argv,"UR10_Main");
ros::NodeHandle node;
ros::Subscriber subscriber1 =node.subscribe("/kinect/depth",10,func1);
ros ...