当前位置:   article > 正文

ROS2学习_ros2 tf2 view

ros2 tf2 view

1. 静态tf变换发布

xxx.launch.py文件

from launch import LaunchDescription
from launch_ros.actions import Node

def generate_launch_description():
    tf2_earth2map = Node(
            package='tf2_ros',
            executable='static_transform_publisher',
            arguments = ['0', '0', '0', '0', '0', '0', 'earth', 'map']
    )
    return LaunchDescription([
        tf2_earth2map,
   ])
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12

命令行方式:

ros2 run tf2_ros static_transform_publisher x y z yaw pitch roll frame_id child_frame_id
ros2 run tf2_ros static_transform_publisher x y z qx qy qz qw frame_id child_frame_id
  • 1
  • 2

2. 查看tf变换树

ros2 run tf2_tools view_frames.py
  • 1

运行该命令后生成tf变换树的PDF文件。

3.ros2与ros1通信

  1. 新开一终端,安装通信程序包
sudo apt install ros-dashing-ros1-bridge
  • 1
  1. 进行ros1与ros2通信
source /opt/ros/noetic/setup.bash
source /opt/ros/foxy/setup.bash
ros2 run ros1_bridge dynamic_bridge --bridge-all-topics
  • 1
  • 2
  • 3

4. ros1与ros2版本切换

在~/.bashrc文件末尾输入

#source /opt/ros/noetic/setup.bash
echo "ros noetic(1) or ros2 foxy(2)?"
read edition
if [ "$edition" -eq "1" ]; then
  source /opt/ros/noetic/setup.bash
  echo "ros noetic(1) has been chosen!"
else
  source /opt/ros/foxy/setup.bash
  echo "ros2 foxy(2) has been chosen!"
fi
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/运维做开发/article/detail/885299
推荐阅读
相关标签
  

闽ICP备14008679号