我是靠谱客的博主 彩色黑米,最近开发中收集的这篇文章主要介绍"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 <ros/ros.h>
#include <tf2_ros/transform_listener.h>
#include <geometry_msgs/TransformStamped.h>
#include <geometry_msgs/Twist.h>
#include <turtlesim/Spawn.h>

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

  ros::NodeHandle node;
 
  ros::Publisher turtle_vel =
    node.advertise<geometry_msgs::Twist>("/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);
 

最后

以上就是彩色黑米为你收集整理的"qrcamera" passed to lookupTransform argument target_frame does not exist.的全部内容,希望文章能够帮你解决"qrcamera" passed to lookupTransform argument target_frame does not exist.所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(36)

评论列表共有 0 条评论

立即
投稿
返回
顶部