必威体育Betway必威体育官网
当前位置:首页 > IT技术

ROS之tf2坐标转换包

时间:2019-11-03 22:14:27来源:IT技术作者:seo实验室小编阅读:87次「手机版」
 

tf2

参考资源

tf2资源:

官网:http://wiki.ros.org/tf2

http://wiki.ros.org/tf2/Tutorials

API: http://docs.ros.org/jade/api/tf2/html/index.html

在tf2系统中,将包分为tf2和tf2_ros,前者用来进行坐标变换等具体操作,tf2_ros则负责与ROS消息打交道,负责发布tf或订阅tf,即发布者和订阅者是在tf2_ros命名空间下的。

ROS中广播和监听的tf2消息类型是tf2_msgs::TFmessage,其本质是

geometry_msgs/TransformStamped类型的向量形式
geometry_msgs/TransformStamped[] transforms
  std_msgs/Header header
    uint32 seq
    time stamp
    string frame_id
  string child_frame_id
  geometry_msgs/Transform transform
    geometry_msgs/vector3 translation
      float64 x
      float64 y
      float64 z
    geometry_msgs/Quaternion rotation
      float64 x
      float64 y
      float64 z
      float64 w

tf2_ros wiki:http://wiki.ros.org/tf2_ros?distro=melodic

tf2_ros API: http://docs.ros.org/kinetic/api/tf2_ros/html/c++/

广播tf2:

#include <tf2_ros/transform_listener.h>
#include <tf2_geometry_msgs/tf2_geometry_msgs.h>
#include <geometry_msgs/TransformStamped.h>
#include <geometry_msgs/PointStamped.h>

static tf2_ros::Transformbroadcaster br;
  geometry_msgs::TransformStamped transformStamped;

  transformStamped.header.stamp = ros::Time::now();
  transformStamped.header.frame_id = "world";
  transformStamped.child_frame_id = turtle_name;
  transformStamped.transform.translation.x = msg->x;
  transformStamped.transform.translation.y = msg->y;
  transformStamped.transform.translation.z = 0.0;
  tf2::Quaternion q;
  q.setRPY(0, 0, msg->theta);
  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);

监听tf2:

使用tf2消息的大部分工作通过tf2_ros::Buffer类完成,其通过tf2_ros::TransformListener完成对tf2_ros::Buffer类的初始化和构造,并订阅相应tf消息,后续操作都是用的tf2_ros::Buffer类的成员函数完成:

#include <tf2_ros/transform_listener.h>
#include <tf2_geometry_msgs/tf2_geometry_msgs.h>
#include <geometry_msgs/TransformStamped.h>
#include <geometry_msgs/PointStamped.h>
....
tf2_ros::Buffer tfBuffer;
  tf2_ros::TransformListener tfListener(tfBuffer);

  ros::Rate rate(10.0);
  while (node.ok()){
    geometry_msgs::TransformStamped transformStamped;
    try{
      transformStamped = tfBuffer.lookupTransform("turtle2", "turtle1",
          ros::Time(0), ros::Duration(3.0));
      geometry_msgs::PointStamped world, velo_link;
      tfBuffer.transform<geometry_msgs::PointStamped>(world, velo_link, "velo_link", ros::Duration(1.0));
    }
    catch (tf2::TransformException &ex) {
      ROS_WARN("%s",ex.what());
      ros::Duration(1.0).sleep();
      continue;
    }
 }

数据类型变换:


https://answers.ros.org/question/261419/tf2-transformpose-in-c/

https://answers.ros.org/question/95791/tf-transformpoint-equivalent-on-tf2/

点云转换:


https://github.com/lucasw/transform_point_cloud

文章最后发布于: 2019-01-04 22:06:29

相关阅读

优办人力:助力人力资源服务商高效管理的HROSaaS系统

随着中国经济的高速增长,市场竞争日益激烈,人的因素越来越成为企业实现自己战略目标的关键要点,因此,能够为劳动者就业与职业发展

解决Qt中文乱码以及汉字编码的问题(UTF-8/GBK)

一、Qt环境设置文件从window上传到Ubuntu后会显示乱码,原因是因为ubuntu环境设置默认是utf-8,Windows默认都是GBK.Windows环境下,

Microsoft Office 2013 (64位) 免费完整版

原文地址:http://www.xitongzhijia.net/soft/89428.htmlMicrosoft Office 2013(又称为Office2013)是运用于Microsoft Windows视窗系

ETF50 & ETF500 Pair trading 策略

Pair trading 策略 ETF50 & ETF500 小demo import pandas as pd import numpy as np import tushare as ts import seaborn from

platform_driver_register()与platform_device_regist

设备与驱动的两种绑定方式:在设备注册时进行绑定及在驱动注册时进行绑定。 以一个USB设备为例,有两种情形:(1)先插上USB设备并挂到总

分享到:

栏目导航

推荐阅读

热门阅读