ros2之turtlesim命令

网友投稿 635 2022-05-29

如何在ros2熟悉和使用各种指令呢,ros1的经典小乌龟是最快捷的途径之一。

ros2_tutorials(turtlesim): https://github.com/zhangrelay/ros2_tutorials

通过turtlesim,对比一下ros1和ros2吧:

文件组织:

ros1:

.

├── CHANGELOG.rst

├── CMakeLists.txt

├── images

│   ├── box-turtle.png

│   ├── diamondback.png

│   ├── electric.png

│   ├── fuerte.png

│   ├── groovy.png

│   ├── hydro.png

│   ├── hydro.svg

│   ├── indigo.png

│   ├── indigo.svg

│   ├── jade.png

│   ├── kinetic.png

│   ├── kinetic.svg

│   ├── lunar.png

│   ├── lunar.svg

│   ├── melodic.png

│   ├── palette.png

│   ├── robot-face.png

│   ├── robot-turtle.png

│   ├── sea-turtle.png

│   ├── turtle.png

│   └── turtle.xar

├── include

│   └── turtlesim

│       ├── turtle_frame.h

│       └── turtle.h

├── launch

│   └── multisim.launch

├── msg

│   ├── Color.msg

│   └── Pose.msg

├── package.xml

├── src

│   ├── turtle.cpp

│   ├── turtle_frame.cpp

│   ├── turtlesim

│   │   └── __init__.py

│   └── turtlesim.cpp

├── srv

│   ├── Kill.srv

│   ├── SetPen.srv

│   ├── Spawn.srv

│   ├── TeleportAbsolute.srv

│   └── TeleportRelative.srv

└── tutorials

├── draw_square.cpp

├── mimic.cpp

└── teleop_turtle_key.cpp

9 directories, 41 files

ros2:

.

├── CHANGELOG.rst

├── CMakeLists.txt

├── images

│   ├── box-turtle.png

│   ├── diamondback.png

│   ├── electric.png

│   ├── fuerte.png

│   ├── groovy.png

│   ├── hydro.png

│   ├── hydro.svg

│   ├── indigo.png

│   ├── indigo.svg

│   ├── jade.png

│   ├── kinetic.png

│   ├── kinetic.svg

│   ├── lunar.png

│   ├── lunar.svg

│   ├── melodic.png

│   ├── palette.png

│   ├── robot-turtle.png

│   ├── sea-turtle.png

│   ├── turtle.png

│   └── turtle.xar

├── include

│   └── turtlesim

│       ├── turtle_frame.h

│       └── turtle.h

├── launch

│   ├── draw_square.launch.py

│   ├── multisim.launch.py

│   └── __pycache__

│       └── draw_square.launch.cpython-36.pyc

├── msg

│   ├── Color.msg

│   └── Pose.msg

├── package.xml

├── src

│   ├── turtle.cpp

│   ├── turtle_frame.cpp

│   ├── turtlesim

│   │   └── __init__.py

│   └── turtlesim.cpp

├── srv

│   ├── Kill.srv

│   ├── SetPen.srv

│   ├── Spawn.srv

│   ├── TeleportAbsolute.srv

│   └── TeleportRelative.srv

└── tutorials

├── draw_square.cpp

├── mimic.cpp

└── teleop_turtle_key.cpp

10 directories, 42 files

这里并未在ros2中添加对应2代版本小乌龟的图片。

编译环节:

ros1:catkin build

ros2:colcon build

命令使用:

ros1:

rosrun, rostopic ……

ros2:

ros2 run, ros2 topic ……

具体介绍如下:

ros2 is an extensible command-line tool for ROS 2.

optional arguments:

-h, --help            show this help message and exit

Commands:

action     Various action related sub-commands

component  Various component related sub-commands

daemon     Various daemon related sub-commands

launch     Run a launch file

lifecycle  Various lifecycle related sub-commands

msg        Various msg related sub-commands

multicast  Various multicast related sub-commands

ros2之turtlesim命令

node       Various node related sub-commands

param      Various param related sub-commands

pkg        Various package related sub-commands

run        Run a package specific executable

security   Various security related sub-commands

service    Various service related sub-commands

srv        Various srv related sub-commands

topic      Various topic related sub-commands

Call `ros2 -h` for more detailed usage.

对于ros1而言,启动小乌龟并键盘遥控,需要如下步骤:

roscore

rosrun turtlesim turtlesim_node

rosrun turtlesim turtle_teleop_key

类比与ros2,我们可以使用如下命令:

roscore

注意ros2无需core

ros2 run turtlesim turtlesim_node

ros2 run turtlesim turtle_teleop_key

非常容易理解。

比如畫一個大圓:

ros2 topic pub /turtle1/cmd_vel ometry_msgs/msg/Twist "{linear: {x: 0.8, y: 0.0, z: 0.0}, angular: {x: 0.0, y: 0.0, z: 0.2}}"

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:麻省理工开设RPA课程,自动化时代离我们还有多远?
下一篇:【题集】一维前缀和-二维前缀和-数星星问题-反复运行时如何降低时间复杂度
相关文章