Chinaunix首页 | 论坛 | 博客
  • 博客访问: 9138878
  • 博文数量: 1725
  • 博客积分: 12961
  • 博客等级: 上将
  • 技术积分: 19840
  • 用 户 组: 普通用户
  • 注册时间: 2009-01-09 11:25
个人简介

偷得浮生半桶水(半日闲), 好记性不如抄下来(烂笔头). 信息爆炸的时代, 学习是一项持续的工作.

文章分类

全部博文(1725)

文章存档

2024年(1)

2023年(26)

2022年(112)

2021年(217)

2020年(157)

2019年(192)

2018年(81)

2017年(78)

2016年(70)

2015年(52)

2014年(40)

2013年(51)

2012年(85)

2011年(45)

2010年(231)

2009年(287)

分类: 其他平台

2020-06-17 10:38:44

1. 环境 
 点击(此处)折叠或打开

  1. source /opt/ros/<distro>/setup.bash ## 最好加入到 .bashrc
  2. printenv | grep -i ROS
  3. 应该出现
  4. ROS_VERSION=2
  5. ROS_PYTHON_VERSION=3
  6. ROS_DISTRO=foxy
当环境中有多个ROS2在跑时, 需要区别 通过 ROS_DOMAIN_ID [0-232].

点击(此处)折叠或打开

  1. echo "export ROS_DOMAIN_ID=" >> ~/.bashrc
 
----------------------------------------------------------------------------- 
学习 turtlesim 和 rqt 工具.
sudo apt install ~nros--rqt*
然后可执行 rqt
-----------------------------------------------------------------------------
ROS2 graph 是 ROS 2 的网络体系.
remapping 机制允许你重新指派节点的默认属性, 包括node_name, topic_name, 
service_name 等等
 
例如 ros2 run turtlesim turtlesim_node --ros-args --remap __node:=my_turtle 
即把名称有默认的 turtle1/2/3 改成 my_turtle

ros2 topic hz / list -t / echo / info 
 
ros2 interface show geometry_msgs/msg/Twist #查看消息类型的定义
ros2 topic pub   ''
 
单次 ros2 topic pub --once /turtle1/cmd_vel geometry_msgs/msg/Twist "{linear: {x: 2.0, y: 0.0, z: 0.0}, angular: {x: 0.0, y: 0.0, z: 1.8}}"
1Hz ros2 topic pub --rate 1 /turtle1/cmd_vel geometry_msgs/msg/Twist "{linear: {x: 2.0, y: 0.0, z: 0.0}, angular: {x: 0.0, y: 0.0, z: 1.8}}"

-----------------------------------------------------------------------------
ros2 service list / type  / list -t / find 
 
ros2 interface show std_srvs/srv/Empty.srv # 查看 srv 的内容.
ros2 service call   
例如 ros2 service call /spawn turtlesim/srv/Spawn "{x: 2, y: 2, theta: 0.2, name: ''}"

-----------------------------------------------------------------------------
ros2 param list | get   
  | set    
            | dump  被存储在 node_name.yaml 文件. 
运行时加载参数文件
 
ros2 run   --ros-args --params-file 
竟然没了 load 指令, 惊讶.
-----------------------------------------------------------------------------
 
ros2 node info /teleop_turtle  会列出发布的话题,订阅的话题, services, action servers 和 action clients.
ros2 action list -t
ros2 action info action_name # 列出action的服务端 和 客户端.
 
ros2 interface show turtlesim/action/RotateAbsolute.action
ros2 action send_goal     values应该是yaml的格式.
例如
ros2 action send_goal /turtle1/rotate_absolute turtlesim/action/RotateAbsolute "{theta: 1.57}"-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
 
 
rqt_console 是个GUI工具. 在此你可看到日志信息,可过滤检索手机等等
ros2 run rqt_console rqt_console
日志级别: Fatal / Error / Warn / Info 默认 / Debug
设置默认日志级别.
 
ros2 run turtlesim turtlesim_node --ros-args --log-level WARN
-----------------------------------------------------------------------------
建立launch 文件.
1. touch launch目录/turtlesim_mimic_launch.py
内容

点击(此处)折叠或打开

  1. from launch import LaunchDescription
  2. from launch_ros.actions import Node
  3. def generate_launch_description():
  4.     return LaunchDescription([
  5.         Node(
  6.             package='turtlesim',
  7.             namespace='turtlesim1',
  8.             executable='turtlesim_node',
  9.             name='sim'
  10.         ),
  11.         Node(
  12.             package='turtlesim',
  13.             namespace='turtlesim2',
  14.             executable='turtlesim_node',
  15.             name='sim'
  16.         ),
  17.         Node(
  18.             package='turtlesim',
  19.             executable='mimic',
  20.             name='mimic',
  21.             remappings=[ //相当于让 turtlesim2 模拟 turtlesim 1 的动作.
  22.                 ('/input/pose', '/turtlesim1/turtle1/pose'), 相当于订阅/turtlesim1/turtle1/pose
  23.                 ('/output/cmd_vel', '/turtlesim2/turtle1/cmd_vel'), 发布到/turtlesim2/turtle1/cmd_vel
  24.             ]
  25.         )
  26.     ])
 
ros2 launch  
ros2 launch turtlesim_mimic_launch.py 如果launch文件在当前目录下的情况
-----------------------------------------------------------------------------
sudo apt-get install ros--ros2bag ros--rosbag2*
ros2 bag record  产生一个 rosbag2-时间点 的文件.
ros2 bag record -o 录音名称 /topic1 /topic2
ros2 bag info 
ros2 bag play 
-----------------------------------------------------------------------------


-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

阅读(918) | 评论(0) | 转发(0) |
0

上一篇:ROS2 ubuntu20.04安装

下一篇:ROS2 just do it

给主人留下些什么吧!~~