"qrcamera" passed to lookupTransform argument target_frame does not exist.

$rosrun tf tf_echo qrcamera marker

http://docs.ros.org/indigo/api/tf2_ros/html/c++/classtf2__ros_1_1Buffer.html#acabbd72cae8f49fb3b6ede3be7e34c55

#include 
#include 
#include 
#include 
#include 

int main(int argc, char** argv){
  ros::init(argc, argv, "my_tf2_listener");

  ros::NodeHandle node;
 
  ros::Publisher turtle_vel =
    node.advertise("/qrpose", 10);

  tf2_ros::Buffer tfBuffer;
  tf2_ros::TransformListener tfListener(tfBuffer);

  ros::Rate rate(10.0);
  while (node.ok()){
		ros::spinOnce();
    geometry_msgs::TransformStamped transformStamped;
    try{
 ros::Time now = ros::Time::now();
      transformStamped = tfBuffer.lookupTransform("qrcamera", "marker",
                               ros::Time(0), ros::Duration(1));
std::cout<<"transformstamped:\n";
		std::cout<<	transformStamped.transform.translation.x<<",";
		std::cout<<	transformStamped.transform.translation.y<<",";
		std::cout<<	transformStamped.transform.translation.z<<"\n****\n";
    }
    catch (tf2::TransformException &ex) {
      ROS_WARN("%s",ex.what());
      ros::Duration(1.0).sleep();
      continue;
    }

    geometry_msgs::Twist vel_msg;
     
    vel_msg.angular.z = 0;
    vel_msg.linear.x = 0.5 ;
    turtle_vel.publish(vel_msg);
    
    rate.sleep();
  }
  return 0;
};

 

  static tf2_ros::TransformBroadcaster br;

  
    transformStamped.header.stamp = ros::Time::now();
    transformStamped.header.frame_id = "qrcamera";
    transformStamped.child_frame_id = "marker";
    transformStamped.transform.translation.x = bc_cv.getX();
    transformStamped.transform.translation.y = bc_cv.getY();
    transformStamped.transform.translation.z = 0.0;
    tf2::Quaternion q;
        q.setRPY(0, 0, -yaw);
    transformStamped.transform.rotation.x = q.x();
    transformStamped.transform.rotation.y = q.y();
    transformStamped.transform.rotation.z = q.z();
    transformStamped.transform.rotation.w = q.w();

    br.sendTransform(transformStamped);
 

你可能感兴趣的:(无人驾驶,cpp)