博客参考:https://www.ncnynl.com/archives/201702/1305.html

ROS与C++入门教程-tf-数据类型

说明:

  • 介绍roscpp的Data Types(数据类型)及使用

数据类型

  • 数据类型定义在tf/transform_datatypes.h

基本数据类型

  • 基本数据类型有:(Quaternion, Vector, Point, Pose, Transform)
  • ROS Fuerte后,TF已经定义了自己的数据类型。关于如何迁移pre-Fuerte代码到更新的ROS版本,查阅geometry/bullet_migration
  • 基本类型:

Type

tf

Quaternion

tf::Quaternion

Vector

tf::Vector3

Point

tf::Point

Pose

tf::Pose

Transform

tf::Transform

tf::Stamped 模板

  • tf::Stamped 对上述数据类型做模板化(除了tf::Transform),并附带元素frame_id_和stamp_ 。
  • 定义代码:
template <typename T>
class Stamped : public T{
public:
ros::Time stamp_;
std::string frame_id_; Stamped() :frame_id_ ("NO_ID_STAMPED_DEFAULT_CONSTRUCTION"){}; //Default constructor used only for preallocation Stamped(const T& input, const ros::Time& timestamp, const std::string & frame_id); void setData(const T& input);
};

tf::StampedTransform

  • tf::StampedTransform 是tf::Transforms的特例,它要求frame_id 、stamp 、child_frame_id.
  • 定义代码:
/** \brief The Stamped Transform datatype used by tf */
class StampedTransform : public tf::Transform
{
public:
ros::Time stamp_; ///< The timestamp associated with this transform
std::string frame_id_; ///< The frame_id of the coordinate frame in which this transform is defined
std::string child_frame_id_; ///< The frame_id of the coordinate frame this transform defines
StampedTransform(const tf::Transform& input, const ros::Time& timestamp, const std::string & frame_id, const std::string & child_frame_id):
tf::Transform (input), stamp_ ( timestamp ), frame_id_ (frame_id), child_frame_id_(child_frame_id){ }; /** \brief Default constructor only to be used for preallocation */
StampedTransform() { }; /** \brief Set the inherited Traonsform data */
void setData(const tf::Transform& input){*static_cast<tf::Transform*>(this) = input;}; };

辅助函数

  • 函数:tf::Quaternion createIdentityQuaternion()
  • 作用:返回四元数句柄
  • 函数:tf::Quaternion createQuaternionFromRPY(double roll,double pitch,double yaw)
  • 作用:返回从固定轴的Roll, Pitch and Yaw(滚动,俯仰和偏转)构造的tf::Quaternion四元数
  • 函数:geometry_msgs::Quaternion createQuaternionMsgFromRollPitchYaw(double roll,double pitch,double yaw)
  • 作用:返回从固定轴的Roll, Pitch and Yaw(滚动,俯仰和偏转)构造的geometry_msgs::Quaternion四元数

数据类型转换

最新文章

  1. 启动Tomcat一闪而过——分析及解决过程
  2. 《java编程思想》读书笔记 暂停一段时间,改为上面的练习题
  3. C语言 文件操作6--文件打开方式详解
  4. javascript继承(一)—类的属性研究
  5. [firefox+plug-n-hack]轻松地配置burpsuite代理https流量
  6. mycat1.5~1.6的一个bug
  7. CSS使块半透明方法,兼容IE6
  8. jquery 随机数
  9. Office 2010
  10. Android系统休眠对程序的影响以及处理
  11. Redis client Python usage
  12. Python实现浏览器自动化操作
  13. MySQL select语句直接导出数据
  14. python mysql 单表查询 多表查询
  15. cefSharp 开发随笔
  16. Linux系统Vi/Vim编辑器的简单介绍、安装/卸载、常用命令
  17. 关于__declspec(dllexport)
  18. [诈骗]“中国移动”发送诈骗短信,china mobile 是骗子吗?
  19. Atitit. 解决unterminated string literal 缺失引号
  20. Base64转Blob

热门文章

  1. .net框架 - Enum枚举
  2. 第122题:买卖股票的最佳时机II
  3. Enterprise Architect 14破解版 安装包 安装教程
  4. 详解C++中基类与派生类的转换以及虚基类
  5. Backpack II
  6. Ubuntu16.04 install hadoop-2.8.1.tar.gz Cluster Setup
  7. MySQL 实现 Oracle row_number over 数据排序功能
  8. bilibili 高并发实时弹幕系统的实现
  9. BZOJ 4571: [Scoi2016]美味
  10. orm-配置不启动项目自动查询orm