前言:在前面的试验中,我们分别有wolrd,turtle1和turtle2三个坐标系,并且world是turtle1和turtle2的父坐标系。现在我们来新建一个自定义坐标系,让turtle2跟着新的坐标系”carrot“运动。

参考自:http://wiki.ros.org/tf/Tutorials/Adding%20a%20frame%20%28C%2B%2B%29

一、新建源文件

新建frame_tf_broadcaster.cpp文件,内容如下:

#include <ros/ros.h>
#include <tf/transform_broadcaster.h>

int main(int argc, char** argv){
  ros::init(argc, argv, "my_tf_broadcaster");
  ros::NodeHandle node;

  tf::TransformBroadcaster br;
  tf::Transform transform;

  ros::Rate rate(10.0);
  while (node.ok()){

    transform.setOrigin( tf::Vector3(0.0, 2.0, 0.0) );//设置新坐标系相对位置关系
    transform.setRotation( tf::Quaternion(, , , ) );//设置新坐标系相对旋转关系
    br.sendTransform(tf::StampedTransform(transform, ros::Time::now(), "turtle1", "carrot1"));//创建一个新坐标系carrot1,距离父坐标系turtle1距离2米
    rate.sleep();
  }
  ;
};

二、修改launch文件

在launch文件中添加代码:

  <launch>
    ...
    <node pkg="learning_tf" type="frame_tf_broadcaster"
          name="broadcaster_frame" />
  </launch>

三、修改广播信息

修改turtle_tf_listener.cpp文件

listener.lookupTransform(), transform);

四、运行

编译并运行launch文件

roslaunch learning_tf start_demo.launch

现在turtle2始终跟随在carrot坐标系运动。

-END-

ROS-TF-新建坐标系的更多相关文章

  1. ROS tf-增加坐标系

    博客参考:https://www.ncnynl.com/archives/201702/1312.html ROS与C++入门教程-tf-增加坐标系 说明: 介绍如何为TF增加额外固定的坐标系 为何增 ...

  2. ROS tf监听编写

    博客转载自:https://www.ncnynl.com/archives/201702/1311.html ROS与C++入门教程-tf-编写tf listener(监听) 说明: 介绍如何使用tf ...

  3. QT插件+ROS 2 新建项目

    一QT插件开发ROS,http://www.ncnynl.com/archives/201701/1277.html 二QT开发遇到问题http://blog.csdn.net/u013453604/ ...

  4. ROS tf广播编写

    博客参考:https://www.ncnynl.com/archives/201702/1310.html ROS与C++入门教程-tf-编写tf broadcaster(广播) 说明: 介绍如何广播 ...

  5. ROS tf 编程指南

    ROS (Robot Operating System, 机器人操作系统)是最知名的机器人操作系统,广泛应用于无人驾驶和机器人,tf(transforms,坐标系转换)是ROS下的一个常用的工具库.r ...

  6. ROS tf基础使用知识

    博客参考:https://www.ncnynl.com/archives/201702/1306.html ROS与C++入门教程-tf-坐标变换 说明: 介绍在c++实现TF的坐标变换 概念: Co ...

  7. ROS TF——learning tf

    在机器人的控制中,坐标系统是非常重要的,在ROS使用tf软件库进行坐标转换. 相关链接:http://www.ros.org/wiki/tf/Tutorials#Learning_tf 一.tf简介 ...

  8. ROS tf

    一.节点中使用(cpp,python) 1. ros wiki 提供的tutorials 2. https://blog.csdn.net/start_from_scratch/article/det ...

  9. ROS tf 两个常用的函数

    /** \brief Get the transform between two frames by frame ID.   * \param target_frame The frame to wh ...

  10. ROS Learning-014 learning_tf(编程) 坐标系变换(tf)广播员 (Python版)

    ROS Indigo learning_tf-01 坐标系变换(tf)广播员 (Python版) 我使用的虚拟机软件:VMware Workstation 11 使用的Ubuntu系统:Ubuntu ...

随机推荐

  1. c#中动态创建textbox并且从数据库中获取表中数据添加到textbox中

    private void FormLugOther_Load(object sender, EventArgs e) { foreach (string str in FormLug.FieldLis ...

  2. u-boot常用命令

    查看ip地址等信息 print tftp相关 设置ip地址 set ipaddr 192.168.1.5 设置tftp所在电脑ip set serverip 192.168.1.8 最后必须输入sav ...

  3. POJ——3169Layout(差分约束)

    POJ——3169Layout Layout Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 14702   Accepted ...

  4. 2018.03.04 晚上Atcoder比赛

    C - March Time limit : 2sec / Memory limit : 256MB Score : 300 points Problem Statement There are N  ...

  5. 【JAVA】简陋的学生信息管理系统

    因为之前写了一个学生信息管理系统,但还是处于命令行界面,不美观,于是打算做一个完整的界面出来. 在网上查阅资料后发现C++本身是不支持图形化界面的(可以使用第三方的Qt来做) 权衡之下还是选择了JAV ...

  6. Dijkstra算法模板

    自己对Dijstra算法的理解是: 首先输入保存点,边的权值(注意无向图和有向图在保存时的区别). 将表示从起点st到顶点 i 的距离的d[ i ]数组的每一个值初始化为INF,令d[st] = 0. ...

  7. Python - 三大器 迭代器,生层器,装饰器

    目录 Python - 三大器 迭代器,生层器,装饰器 一. 容器 二. 可迭代对象(iterable) 三. 迭代器 四. 生成器 五. 装饰器 1. 定义 六. 闭包 Python - 三大器 迭 ...

  8. Codeforces Hello 2018 C - Party Lemonade

    传送门:http://codeforces.com/contest/913/problem/C 有n类物品,第i(i=0,1,2,...,n-1)类物品的价值为2i,花费为ci.任意选择物品,使得总价 ...

  9. HDU 1836 畅通工程

    畅通工程 Time Limit: 1000ms Memory Limit: 32768KB This problem will be judged on HDU. Original ID: 18636 ...

  10. poj 1679 判断最小生成树是否唯一

    /* 只需判断等效边和必选边的个数和n-1的关系即可 */ #include<stdio.h> #include<stdlib.h> #define N 110 struct ...