zoukankan      html  css  js  c++  java
  • ROS Melodic 小海龟操控笔记

    执行新的命令操作时,均需要启动一个新的终端然后输入命令。

    基础操作:

    1. 启动 ROS Master:roscore
    2. 启动小海龟仿真器:rosrun turtlesim turtlesim_node
    3. 启动小海龟键盘控制节点:rosrun turtlesim turtle_teleop_key
    4. 此时按键盘上的方向键即可操控小海龟运行

    其他操作:

    提前说明:有小伙伴曾反馈指令有问题,输入后会报错。经查实,是因为不同行的问题,如果指令都在同一行,则会出现问题。所以不要把不同行的代码在同一行输入!

    新生一只小海龟:

    rosservice call /spawn "x: 5.0
    y: 5.0
    theta: 0.0
    name: 'turtle2'"
    

    让第一只小海龟绕圈跑:

    代码中的 x,y,z 为坐标及角度信息,按照意愿自行修改即可。

    -r 10 表示让命令以 10Hz 的频率控制小海龟运行,可以自行修改或者删除该指令。

    rostopic pub -r 10 /turtle1/cmd_vel geometry_msgs/Twist "linear:
      x: 1.0
      y: 0.0
      z: 0.0
    angular:
      x: 0.0
      y: 0.0
      z: 1.0"
    

    不喜欢换行输入的小伙伴,可以输入如下简化指令:rostopic pub -r 10 /turtle1/cmd_vel geometry_msgs/Twist -- '[1.0, 0.0, 0.0]' '[0.0, 0.0, 1.0]'

    同理,让第二只小海龟绕圈跑:

    rostopic pub -r 10 /turtle2/cmd_vel geometry_msgs/Twist "linear:
      x: 1.0
      y: 0.0
      z: 0.0
    angular:
      x: 0.0
      y: 0.0
      z: 1.0"
    

    一只小海龟追赶另外一只小海龟实例:

    1. 安装小海龟坐标变换功能包:sudo apt install ros-melodic-turtle-tf
    2. 运行功能包:roslaunch turtle_tf turtle_tf_demo.launch
    3. 启动小海龟键盘控制节点:rosrun turtlesim turtle_teleop_key
    4. 此时按键盘上的方向键即可操控第一只小海龟运行,第二只小海龟会自动跟踪第一只小海龟
  • 相关阅读:
    不可重叠最长重复子串
    离散化
    hash是一门优雅的暴力
    Detect the Virus (字符串转化+AC自动机)
    病毒侵袭(AC自动机变形)
    hdu2069(Coin Change)
    Hie with the Pie(poj3311)
    poj3254(状压dp入门第一道题,很详细)
    map系统学习
    ACM-ICPC 2018 南京赛区网络预赛 B. The writing on the wall
  • 原文地址:https://www.cnblogs.com/zhangxiaochn/p/12255260.html
Copyright © 2011-2022 走看看