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,
])
命令行方式:
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
2. 查看tf变换树
ros2 run tf2_tools view_frames.py
运行该命令后生成tf变换树的PDF文件。
3.ros2与ros1通信
- 新开一终端,安装通信程序包
sudo apt install ros-dashing-ros1-bridge
- 进行ros1与ros2通信
source /opt/ros/noetic/setup.bash
source /opt/ros/foxy/setup.bash
ros2 run ros1_bridge dynamic_bridge --bridge-all-topics
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
本文介绍了如何使用ROS2中的tf2_ros进行静态变换发布,通过`static_transform_publisher`命令行工具设置地球到地图的固定坐标变换,并展示了如何查看TF变换树及ros1与ros2之间的通信。此外,还讲解了版本切换和基础的通信程序包安装方法。
5554

被折叠的 条评论
为什么被折叠?



