ROStf变换之得到两个坐标之间的转换关系1、two_tf_transform.cpp
#include <ros/ros.h>
#include <tf/transform_listener.h>
#include <geometry_msgs/Twist.h>
#include <turtlesim/Spawn.h>
#include <iostream>
#include <cmath>
using namespace std;
double x,y,z,ww,zz,hh,ii,Aww,Azz,Ahh,Aii;
double theta;
int main(int argc, char** argv){
ros::init(argc, argv, "two_tf_transform");
ros::NodeHandle node;
tf::TransformListener listener;
ros::Rate rate(10.0);
while (node.ok()){
tf::StampedTransform transform;
try{
//得到坐标odom和坐标ba_link之间的关系
listener.waitForTransform("odom", "ba_link", ros::Time(0), ros::Duration(3.0)); listener.lookupTransform("odom", "ba_link",
ros::Time(0), transform);
}
catch (tf::TransformException &ex) {
ROS_ERROR("%s",ex.what());
ros::Duration(1.0).sleep();
}
maximum是什么意思Origin().x();
Origin().y();
Origin().z();
cout<<"x: "<<x<<endl;
cout<<"y: "<<y<<endl;
cout<<"z: "<<z<<endl;
xna//两种不同的表⽰⽅法,来表⽰getRotation
Rotation()[0];
Rotation()[1];
Rotation()[2];
Rotation()[3];
cout<<"ww: "<<ww<<endl;
cout<<"zz: "<<zz<<endl;
cout<<"hh: "<<hh<<endl;
风信子英文
cout<<"ii: "<<ii<<endl;
Rotation().getX();
Rotation().getY();
Rotation().getZ();
cancam
Rotation().getW();beautifulgirl
theta=2*Rotation().getW())/3.1415926*180;
cout<<"Aww: "<<Aww<<endl;
depositedcout<<"Azz: "<<Azz<<endl;
cout<<"Ahh: "<<Ahh<<endl;
cout<<"Aii: "<<Aii<<endl;
cout<<"Theta: "<<theta<<endl;
cout<<endl;
rate.sleep();
}
掘井return 0;
};
2、
cmake_minimum_required(VERSION 2.8.3)
project(learn_tf)
find_package(catkin REQUIRED COMPONENTS
geometry_msgs
roscpp
tf
)
catkin_package(
)
## Specify additional locations of header files
高光笔## Your package locations should be listed before other locations include_directories(
# include
${catkin_INCLUDE_DIRS}
)
add_executable(two_tf_transform src/two_tf_transform.cpp)
target_link_libraries(two_tf_transform ${catkin_LIBRARIES})
3、l
<?xml version="1.0"?>
<package format="2">
<name>learn_tf</name>
<version>0.0.0</version>
<description>The learn_tf package</description>
<maintainer email="do">patience</maintainer>
<licen>TODO</licen>
<buildtool_depend>catkin</buildtool_depend>
<build_depend>geometry_msgs</build_depend>
<build_depend>roscpp</build_depend>
<build_depend>tf</build_depend>
<build_export_depend>geometry_msgs</build_export_depend>
<build_export_depend>roscpp</build_export_depend>
<build_export_depend>tf</build_export_depend>
<exec_depend>geometry_msgs</exec_depend>
<exec_depend>roscpp</exec_depend>
<exec_depend>tf</exec_depend>
<!-- The export tag contains other, unspecified, tags -->
<export>
im<!-- Other tools can request additional information be placed here -->
</export>
</package>
>启程歌词