0
点赞
收藏
分享

微信扫一扫

树莓派ROS+arduino(三):helloworld程序初探分析


对于helloworld程序来说,这个程序比较短而且简单,因此适合做一个详细的分析。

下面就是我们的helloworld初程序。

它主要负责发布一个名字叫chatter的话题,话题的消息是str_msg,二消息类型是String。

树莓派ROS+arduino(三):helloworld程序初探分析_python

这个我们通过订阅消息就能看出来:

(1):运行roscore

(2):运行rosrun rosserial_python serial_node.py /dev/ttyUSB1

(3):输出话题消息:rostopic echo chatter

树莓派ROS+arduino(三):helloworld程序初探分析_ros_02

可以看到,这里已经输出了hello world字符串。

然后我们开始进行修改尝试,从而思考这些语句的意义。

1.首先,我们把hello字符串的值改成nobble。

树莓派ROS+arduino(三):helloworld程序初探分析_python_03

看一下效果:从chatter这个话题里面输出来的消息就已经变成了”nobble“字符串。

树莓派ROS+arduino(三):helloworld程序初探分析_字符串_04

同时再看一下topic列表,可以看到下图,是有chatter这个话题的:

树莓派ROS+arduino(三):helloworld程序初探分析_ros_05

再看一下节点图:

树莓派ROS+arduino(三):helloworld程序初探分析_arduino_06

可以看到chatter这个话题是由serial_node这个节点发布的,那么如何才能更改话题名字呢?比如我想发布另一个话题?看接下来的尝试。

2.

 

举报

相关推荐

ros+arduino=robot

树莓派中的Ros系统01

0 条评论