ROS2学习

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通信

  1. 新开一终端,安装通信程序包
sudo apt install ros-dashing-ros1-bridge
  1. 进行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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值