ros2中常用命令,与ros1的区别

1. ros1 中的rosrun tf tf_echo 在ros2中使用办法

# ros2 run tf2_ros tf2_echo [reference_frame] [target_frame]
ros2 run tf2_ros tf2_echo turtle2 turtle1

会显示如下结果:

At time 1631336659.214493548
- Translation: [0.015, 0.000, 0.000]
- Rotation: in Quaternion [0.000, 0.000, -0.206, 0.978]
At time 1631336660.222032437
- Translation: [0.008, 0.000, 0.000]
- Rotation: in Quaternion [0.000, 0.000, -0.208, 0.978]

参考: https://www.cnblogs.com/vpegasus/p/ros2_tf2.html

2. rqt 中 tf 树的查看

请参考这个链接: https://blog.csdn.net/ABC_ORANGE/article/details/130420466?spm=1001.2014.3001.5501

3. roscd 在ros2中使用办法

ros2中使用colcon_cd,需要提前设置环境变量:
colcon_cd 环境变量:

source /usr/share/colcon_cd/function/colcon_cd.sh

为支持在bash和shell中对colcon命令进行补全:

source /usr/share/colcon_argcomplete/hook/colcon-argcomplete.bash

4. ros2获取时间的方法:

    auto t = rclcpp::Clock().now();
    auto t1 = std::chrono::system_clock::now(); 

    auto t2 = this->get_clock()->now();  #这个是在类中这样使用,可以直接实例化类后调用这个函数

    auto t3 = this->now();   #这个是在类中这样使用

参考:  https://blog.csdn.net/shoufei403/article/details/125955660

5. ros2 中 duration使用办法

ros1中是ros::Duration(),在ros2中是下面这个样子

rclcpp::Duration::from_seconds(0)
  • 3
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值