我们有的时候可能需要多个坐标系转换,那我们需要一个新的方法。
首先,我们先在静态转换的文件夹里创建launch文件,编写如下:
<launch>
<group>
<node pkg="tf2_ros" type="static_transform_publisher" name="son1" args="5 0 0 0 0 0 /world /son1" output="screen" />
</group>
<group>
<node pkg="tf2_ros" type="static_transform_publisher" name="son2" args="3 0 0 0 0 0 /world /son2" output="screen" />
</group>
</launch>
然后我们在编写多坐标系转换的文档:
#include "ros/ros.h"
#include "tf2_ros/transform_listener.h"
#include "tf2_ros/buffer.h"
#include "geometry_msgs/PointStamped.h"
#include "tf2_geometry_msgs/tf2_geometry_msgs.h"
int main(int argc,char* argv[]){
setlocale(LC_ALL,"");
ros::init(argc,argv,"multi01");
ros::NodeHandle n;
tf2_ros::Buffer buffer;
tf2_ros::TransformListener sub(buffer);
geometry_msgs::PointStamped psAtoSon1;
psAtoSon1.header.stamp=ros::Time

最低0.47元/天 解锁文章
990

被折叠的 条评论
为什么被折叠?



