概述
$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.所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复