文章目录
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)