您当前的位置: 首页 > 

鱼香ROS

暂无认证

  • 0浏览

    0关注

    498博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

《动手学ROS2》4.1ROS2话题介绍

鱼香ROS 发布时间:2021-11-10 09:51:45 ,浏览量:0

本系列教程作者:小鱼 公众号:鱼香ROS QQ交流群:139707339 教学视频地址:小鱼的B站 完整文档地址:鱼香ROS官网 版权声明:如非允许禁止转载与商业用途。 公众号

4.1 ROS2话题介绍

大家好,我是小鱼。上一章节中,我们采用了面向对象的方法创建了作家李四和单身狗王二,本节课我们就通过ROS2的话题机制,让作家李四发布小说,让单身狗王二订阅小说并付费。

1.背景故事

李四是一名擅长写小说的作家,既然是作家,肯定要写文章才行,所以李四就写了一本带颜色的小说《艳娘传奇》。

王二是一名单身多年的单身狗,单身狗没啥爱好,但是《艳娘传奇》肯定是必看的(单身多年的你肯定懂)。

所以我们就要想办法让王二可以看到李四写的小说,有什么好的办法吗?

办法就是ROS2的话题机制。

我们让王二(Node)通过订阅(Subscribe)李四(Node)发布(Publish)的《艳娘传奇》(Topic)来欣赏小说的。

2.话题介绍

故事其实就是讲了一下ROS2中Topic通信方式,Topic通信模型是一种发布订阅模型。

2.1 话题的发布订阅模型

这里的王二和李四两个节点,通过话题来互相通信(传递数据)。

李四节点会创建一个发布者(Publisher)来发布一个话题(艳娘传奇,小鱼取个英文名叫sexy_girl)。单身汉王二节点,他创建了一个订阅者(Subscriber)来订阅李四发布的话题sexy_girl。

那艳娘传奇的内容是什么呢?我们暂且规定为由文字组成的字符串(连插图都没的那种)。

#mermaid-svg-7PQZwpLn0BPKMjGn .label{font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family);fill:#333;color:#333}#mermaid-svg-7PQZwpLn0BPKMjGn .label text{fill:#333}#mermaid-svg-7PQZwpLn0BPKMjGn .node rect,#mermaid-svg-7PQZwpLn0BPKMjGn .node circle,#mermaid-svg-7PQZwpLn0BPKMjGn .node ellipse,#mermaid-svg-7PQZwpLn0BPKMjGn .node polygon,#mermaid-svg-7PQZwpLn0BPKMjGn .node path{fill:#ECECFF;stroke:#9370db;stroke-width:1px}#mermaid-svg-7PQZwpLn0BPKMjGn .node .label{text-align:center;fill:#333}#mermaid-svg-7PQZwpLn0BPKMjGn .node.clickable{cursor:pointer}#mermaid-svg-7PQZwpLn0BPKMjGn .arrowheadPath{fill:#333}#mermaid-svg-7PQZwpLn0BPKMjGn .edgePath .path{stroke:#333;stroke-width:1.5px}#mermaid-svg-7PQZwpLn0BPKMjGn .flowchart-link{stroke:#333;fill:none}#mermaid-svg-7PQZwpLn0BPKMjGn .edgeLabel{background-color:#e8e8e8;text-align:center}#mermaid-svg-7PQZwpLn0BPKMjGn .edgeLabel rect{opacity:0.9}#mermaid-svg-7PQZwpLn0BPKMjGn .edgeLabel span{color:#333}#mermaid-svg-7PQZwpLn0BPKMjGn .cluster rect{fill:#ffffde;stroke:#aa3;stroke-width:1px}#mermaid-svg-7PQZwpLn0BPKMjGn .cluster text{fill:#333}#mermaid-svg-7PQZwpLn0BPKMjGn div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family);font-size:12px;background:#ffffde;border:1px solid #aa3;border-radius:2px;pointer-events:none;z-index:100}#mermaid-svg-7PQZwpLn0BPKMjGn .actor{stroke:#ccf;fill:#ECECFF}#mermaid-svg-7PQZwpLn0BPKMjGn text.actor>tspan{fill:#000;stroke:none}#mermaid-svg-7PQZwpLn0BPKMjGn .actor-line{stroke:grey}#mermaid-svg-7PQZwpLn0BPKMjGn .messageLine0{stroke-width:1.5;stroke-dasharray:none;stroke:#333}#mermaid-svg-7PQZwpLn0BPKMjGn .messageLine1{stroke-width:1.5;stroke-dasharray:2, 2;stroke:#333}#mermaid-svg-7PQZwpLn0BPKMjGn #arrowhead path{fill:#333;stroke:#333}#mermaid-svg-7PQZwpLn0BPKMjGn .sequenceNumber{fill:#fff}#mermaid-svg-7PQZwpLn0BPKMjGn #sequencenumber{fill:#333}#mermaid-svg-7PQZwpLn0BPKMjGn #crosshead path{fill:#333;stroke:#333}#mermaid-svg-7PQZwpLn0BPKMjGn .messageText{fill:#333;stroke:#333}#mermaid-svg-7PQZwpLn0BPKMjGn .labelBox{stroke:#ccf;fill:#ECECFF}#mermaid-svg-7PQZwpLn0BPKMjGn .labelText,#mermaid-svg-7PQZwpLn0BPKMjGn .labelText>tspan{fill:#000;stroke:none}#mermaid-svg-7PQZwpLn0BPKMjGn .loopText,#mermaid-svg-7PQZwpLn0BPKMjGn .loopText>tspan{fill:#000;stroke:none}#mermaid-svg-7PQZwpLn0BPKMjGn .loopLine{stroke-width:2px;stroke-dasharray:2, 2;stroke:#ccf;fill:#ccf}#mermaid-svg-7PQZwpLn0BPKMjGn .note{stroke:#aa3;fill:#fff5ad}#mermaid-svg-7PQZwpLn0BPKMjGn .noteText,#mermaid-svg-7PQZwpLn0BPKMjGn .noteText>tspan{fill:#000;stroke:none}#mermaid-svg-7PQZwpLn0BPKMjGn .activation0{fill:#f4f4f4;stroke:#666}#mermaid-svg-7PQZwpLn0BPKMjGn .activation1{fill:#f4f4f4;stroke:#666}#mermaid-svg-7PQZwpLn0BPKMjGn .activation2{fill:#f4f4f4;stroke:#666}#mermaid-svg-7PQZwpLn0BPKMjGn .mermaid-main-font{font-family:"trebuchet ms", verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-7PQZwpLn0BPKMjGn .section{stroke:none;opacity:0.2}#mermaid-svg-7PQZwpLn0BPKMjGn .section0{fill:rgba(102,102,255,0.49)}#mermaid-svg-7PQZwpLn0BPKMjGn .section2{fill:#fff400}#mermaid-svg-7PQZwpLn0BPKMjGn .section1,#mermaid-svg-7PQZwpLn0BPKMjGn .section3{fill:#fff;opacity:0.2}#mermaid-svg-7PQZwpLn0BPKMjGn .sectionTitle0{fill:#333}#mermaid-svg-7PQZwpLn0BPKMjGn .sectionTitle1{fill:#333}#mermaid-svg-7PQZwpLn0BPKMjGn .sectionTitle2{fill:#333}#mermaid-svg-7PQZwpLn0BPKMjGn .sectionTitle3{fill:#333}#mermaid-svg-7PQZwpLn0BPKMjGn .sectionTitle{text-anchor:start;font-size:11px;text-height:14px;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-7PQZwpLn0BPKMjGn .grid .tick{stroke:#d3d3d3;opacity:0.8;shape-rendering:crispEdges}#mermaid-svg-7PQZwpLn0BPKMjGn .grid .tick text{font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-7PQZwpLn0BPKMjGn .grid path{stroke-width:0}#mermaid-svg-7PQZwpLn0BPKMjGn .today{fill:none;stroke:red;stroke-width:2px}#mermaid-svg-7PQZwpLn0BPKMjGn .task{stroke-width:2}#mermaid-svg-7PQZwpLn0BPKMjGn .taskText{text-anchor:middle;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-7PQZwpLn0BPKMjGn .taskText:not([font-size]){font-size:11px}#mermaid-svg-7PQZwpLn0BPKMjGn .taskTextOutsideRight{fill:#000;text-anchor:start;font-size:11px;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-7PQZwpLn0BPKMjGn .taskTextOutsideLeft{fill:#000;text-anchor:end;font-size:11px}#mermaid-svg-7PQZwpLn0BPKMjGn .task.clickable{cursor:pointer}#mermaid-svg-7PQZwpLn0BPKMjGn .taskText.clickable{cursor:pointer;fill:#003163 !important;font-weight:bold}#mermaid-svg-7PQZwpLn0BPKMjGn .taskTextOutsideLeft.clickable{cursor:pointer;fill:#003163 !important;font-weight:bold}#mermaid-svg-7PQZwpLn0BPKMjGn .taskTextOutsideRight.clickable{cursor:pointer;fill:#003163 !important;font-weight:bold}#mermaid-svg-7PQZwpLn0BPKMjGn .taskText0,#mermaid-svg-7PQZwpLn0BPKMjGn .taskText1,#mermaid-svg-7PQZwpLn0BPKMjGn .taskText2,#mermaid-svg-7PQZwpLn0BPKMjGn .taskText3{fill:#fff}#mermaid-svg-7PQZwpLn0BPKMjGn .task0,#mermaid-svg-7PQZwpLn0BPKMjGn .task1,#mermaid-svg-7PQZwpLn0BPKMjGn .task2,#mermaid-svg-7PQZwpLn0BPKMjGn .task3{fill:#8a90dd;stroke:#534fbc}#mermaid-svg-7PQZwpLn0BPKMjGn .taskTextOutside0,#mermaid-svg-7PQZwpLn0BPKMjGn .taskTextOutside2{fill:#000}#mermaid-svg-7PQZwpLn0BPKMjGn .taskTextOutside1,#mermaid-svg-7PQZwpLn0BPKMjGn .taskTextOutside3{fill:#000}#mermaid-svg-7PQZwpLn0BPKMjGn .active0,#mermaid-svg-7PQZwpLn0BPKMjGn .active1,#mermaid-svg-7PQZwpLn0BPKMjGn .active2,#mermaid-svg-7PQZwpLn0BPKMjGn .active3{fill:#bfc7ff;stroke:#534fbc}#mermaid-svg-7PQZwpLn0BPKMjGn .activeText0,#mermaid-svg-7PQZwpLn0BPKMjGn .activeText1,#mermaid-svg-7PQZwpLn0BPKMjGn .activeText2,#mermaid-svg-7PQZwpLn0BPKMjGn .activeText3{fill:#000 !important}#mermaid-svg-7PQZwpLn0BPKMjGn .done0,#mermaid-svg-7PQZwpLn0BPKMjGn .done1,#mermaid-svg-7PQZwpLn0BPKMjGn .done2,#mermaid-svg-7PQZwpLn0BPKMjGn .done3{stroke:grey;fill:#d3d3d3;stroke-width:2}#mermaid-svg-7PQZwpLn0BPKMjGn .doneText0,#mermaid-svg-7PQZwpLn0BPKMjGn .doneText1,#mermaid-svg-7PQZwpLn0BPKMjGn .doneText2,#mermaid-svg-7PQZwpLn0BPKMjGn .doneText3{fill:#000 !important}#mermaid-svg-7PQZwpLn0BPKMjGn .crit0,#mermaid-svg-7PQZwpLn0BPKMjGn .crit1,#mermaid-svg-7PQZwpLn0BPKMjGn .crit2,#mermaid-svg-7PQZwpLn0BPKMjGn .crit3{stroke:#f88;fill:red;stroke-width:2}#mermaid-svg-7PQZwpLn0BPKMjGn .activeCrit0,#mermaid-svg-7PQZwpLn0BPKMjGn .activeCrit1,#mermaid-svg-7PQZwpLn0BPKMjGn .activeCrit2,#mermaid-svg-7PQZwpLn0BPKMjGn .activeCrit3{stroke:#f88;fill:#bfc7ff;stroke-width:2}#mermaid-svg-7PQZwpLn0BPKMjGn .doneCrit0,#mermaid-svg-7PQZwpLn0BPKMjGn .doneCrit1,#mermaid-svg-7PQZwpLn0BPKMjGn .doneCrit2,#mermaid-svg-7PQZwpLn0BPKMjGn .doneCrit3{stroke:#f88;fill:#d3d3d3;stroke-width:2;cursor:pointer;shape-rendering:crispEdges}#mermaid-svg-7PQZwpLn0BPKMjGn .milestone{transform:rotate(45deg) scale(0.8, 0.8)}#mermaid-svg-7PQZwpLn0BPKMjGn .milestoneText{font-style:italic}#mermaid-svg-7PQZwpLn0BPKMjGn .doneCritText0,#mermaid-svg-7PQZwpLn0BPKMjGn .doneCritText1,#mermaid-svg-7PQZwpLn0BPKMjGn .doneCritText2,#mermaid-svg-7PQZwpLn0BPKMjGn .doneCritText3{fill:#000 !important}#mermaid-svg-7PQZwpLn0BPKMjGn .activeCritText0,#mermaid-svg-7PQZwpLn0BPKMjGn .activeCritText1,#mermaid-svg-7PQZwpLn0BPKMjGn .activeCritText2,#mermaid-svg-7PQZwpLn0BPKMjGn .activeCritText3{fill:#000 !important}#mermaid-svg-7PQZwpLn0BPKMjGn .titleText{text-anchor:middle;font-size:18px;fill:#000;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-7PQZwpLn0BPKMjGn g.classGroup text{fill:#9370db;stroke:none;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family);font-size:10px}#mermaid-svg-7PQZwpLn0BPKMjGn g.classGroup text .title{font-weight:bolder}#mermaid-svg-7PQZwpLn0BPKMjGn g.clickable{cursor:pointer}#mermaid-svg-7PQZwpLn0BPKMjGn g.classGroup rect{fill:#ECECFF;stroke:#9370db}#mermaid-svg-7PQZwpLn0BPKMjGn g.classGroup line{stroke:#9370db;stroke-width:1}#mermaid-svg-7PQZwpLn0BPKMjGn .classLabel .box{stroke:none;stroke-width:0;fill:#ECECFF;opacity:0.5}#mermaid-svg-7PQZwpLn0BPKMjGn .classLabel .label{fill:#9370db;font-size:10px}#mermaid-svg-7PQZwpLn0BPKMjGn .relation{stroke:#9370db;stroke-width:1;fill:none}#mermaid-svg-7PQZwpLn0BPKMjGn .dashed-line{stroke-dasharray:3}#mermaid-svg-7PQZwpLn0BPKMjGn #compositionStart{fill:#9370db;stroke:#9370db;stroke-width:1}#mermaid-svg-7PQZwpLn0BPKMjGn #compositionEnd{fill:#9370db;stroke:#9370db;stroke-width:1}#mermaid-svg-7PQZwpLn0BPKMjGn #aggregationStart{fill:#ECECFF;stroke:#9370db;stroke-width:1}#mermaid-svg-7PQZwpLn0BPKMjGn #aggregationEnd{fill:#ECECFF;stroke:#9370db;stroke-width:1}#mermaid-svg-7PQZwpLn0BPKMjGn #dependencyStart{fill:#9370db;stroke:#9370db;stroke-width:1}#mermaid-svg-7PQZwpLn0BPKMjGn #dependencyEnd{fill:#9370db;stroke:#9370db;stroke-width:1}#mermaid-svg-7PQZwpLn0BPKMjGn #extensionStart{fill:#9370db;stroke:#9370db;stroke-width:1}#mermaid-svg-7PQZwpLn0BPKMjGn #extensionEnd{fill:#9370db;stroke:#9370db;stroke-width:1}#mermaid-svg-7PQZwpLn0BPKMjGn .commit-id,#mermaid-svg-7PQZwpLn0BPKMjGn .commit-msg,#mermaid-svg-7PQZwpLn0BPKMjGn .branch-label{fill:lightgrey;color:lightgrey;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-7PQZwpLn0BPKMjGn .pieTitleText{text-anchor:middle;font-size:25px;fill:#000;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-7PQZwpLn0BPKMjGn .slice{font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-7PQZwpLn0BPKMjGn g.stateGroup text{fill:#9370db;stroke:none;font-size:10px;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-7PQZwpLn0BPKMjGn g.stateGroup text{fill:#9370db;fill:#333;stroke:none;font-size:10px}#mermaid-svg-7PQZwpLn0BPKMjGn g.statediagram-cluster .cluster-label text{fill:#333}#mermaid-svg-7PQZwpLn0BPKMjGn g.stateGroup .state-title{font-weight:bolder;fill:#000}#mermaid-svg-7PQZwpLn0BPKMjGn g.stateGroup rect{fill:#ECECFF;stroke:#9370db}#mermaid-svg-7PQZwpLn0BPKMjGn g.stateGroup line{stroke:#9370db;stroke-width:1}#mermaid-svg-7PQZwpLn0BPKMjGn .transition{stroke:#9370db;stroke-width:1;fill:none}#mermaid-svg-7PQZwpLn0BPKMjGn .stateGroup .composit{fill:white;border-bottom:1px}#mermaid-svg-7PQZwpLn0BPKMjGn .stateGroup .alt-composit{fill:#e0e0e0;border-bottom:1px}#mermaid-svg-7PQZwpLn0BPKMjGn .state-note{stroke:#aa3;fill:#fff5ad}#mermaid-svg-7PQZwpLn0BPKMjGn .state-note text{fill:black;stroke:none;font-size:10px}#mermaid-svg-7PQZwpLn0BPKMjGn .stateLabel .box{stroke:none;stroke-width:0;fill:#ECECFF;opacity:0.7}#mermaid-svg-7PQZwpLn0BPKMjGn .edgeLabel text{fill:#333}#mermaid-svg-7PQZwpLn0BPKMjGn .stateLabel text{fill:#000;font-size:10px;font-weight:bold;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-7PQZwpLn0BPKMjGn .node circle.state-start{fill:black;stroke:black}#mermaid-svg-7PQZwpLn0BPKMjGn .node circle.state-end{fill:black;stroke:white;stroke-width:1.5}#mermaid-svg-7PQZwpLn0BPKMjGn #statediagram-barbEnd{fill:#9370db}#mermaid-svg-7PQZwpLn0BPKMjGn .statediagram-cluster rect{fill:#ECECFF;stroke:#9370db;stroke-width:1px}#mermaid-svg-7PQZwpLn0BPKMjGn .statediagram-cluster rect.outer{rx:5px;ry:5px}#mermaid-svg-7PQZwpLn0BPKMjGn .statediagram-state .divider{stroke:#9370db}#mermaid-svg-7PQZwpLn0BPKMjGn .statediagram-state .title-state{rx:5px;ry:5px}#mermaid-svg-7PQZwpLn0BPKMjGn .statediagram-cluster.statediagram-cluster .inner{fill:white}#mermaid-svg-7PQZwpLn0BPKMjGn .statediagram-cluster.statediagram-cluster-alt .inner{fill:#e0e0e0}#mermaid-svg-7PQZwpLn0BPKMjGn .statediagram-cluster .inner{rx:0;ry:0}#mermaid-svg-7PQZwpLn0BPKMjGn .statediagram-state rect.basic{rx:5px;ry:5px}#mermaid-svg-7PQZwpLn0BPKMjGn .statediagram-state rect.divider{stroke-dasharray:10,10;fill:#efefef}#mermaid-svg-7PQZwpLn0BPKMjGn .note-edge{stroke-dasharray:5}#mermaid-svg-7PQZwpLn0BPKMjGn .statediagram-note rect{fill:#fff5ad;stroke:#aa3;stroke-width:1px;rx:0;ry:0}:root{--mermaid-font-family: '"trebuchet ms", verdana, arial';--mermaid-font-family: "Comic Sans MS", "Comic Sans", cursive}#mermaid-svg-7PQZwpLn0BPKMjGn .error-icon{fill:#522}#mermaid-svg-7PQZwpLn0BPKMjGn .error-text{fill:#522;stroke:#522}#mermaid-svg-7PQZwpLn0BPKMjGn .edge-thickness-normal{stroke-width:2px}#mermaid-svg-7PQZwpLn0BPKMjGn .edge-thickness-thick{stroke-width:3.5px}#mermaid-svg-7PQZwpLn0BPKMjGn .edge-pattern-solid{stroke-dasharray:0}#mermaid-svg-7PQZwpLn0BPKMjGn .edge-pattern-dashed{stroke-dasharray:3}#mermaid-svg-7PQZwpLn0BPKMjGn .edge-pattern-dotted{stroke-dasharray:2}#mermaid-svg-7PQZwpLn0BPKMjGn .marker{fill:#333}#mermaid-svg-7PQZwpLn0BPKMjGn .marker.cross{stroke:#333} :root { --mermaid-font-family: "trebuchet ms", verdana, arial;} #mermaid-svg-7PQZwpLn0BPKMjGn { color: rgba(0, 0, 0, 0.75); font: ; }
发布
订阅
Node李四
艳娘传奇
Node王二

李四王二通信模型是一个一对一(一个发布者,一个订阅者)的模型,除此之外ROS2中话题通信其实还可以是1对n,n对1,n对n的。

2.2 话题通信有哪些需要注意的规则呢?

需要满足以下规则:

  • 话题名字是关键,发布订阅接口类型要相同,发布的是字符串,接受也要用字符串来接收;
  • 同一个人(节点)可以订阅多个话题,同时也可以发布多个话题,就像一本书的作者也可以是另外一本书的读者;
  • 同一个小说不能有多个作者(版权问题),但跟小说不一样,同一个话题可以有多个发布者。
3.相关的工具 3.1 RQT工具之rqt_graph

ROS2作为一个强大的工具,在运行过程中,我们是可以通过命令来看到节点和节点之间的数据关系的。

运行我们第二章中的你说我听小demo。依次打开三个终端,分别输入下面三个命令。

ros2 run demo_nodes_py listener
ros2 run demo_nodes_cpp talker
rqt_graph

你将看到下面这张图

你可以尝试改变菜单栏的选项,看一看下面图的变化,感受一下rqt_graph工具的强大。

这是一个很重要的工具,小鱼在学习和使用ROS2的过程中经常会用到它,来看一看数据到底是怎么走的,它可以帮我们搞清楚一个节点的输入和输出是什么。

3.2 ROS2话题相关命令行界面(CLI)工具

还记得上一节的ros2 node指令吗?ros2也支持很多强大的topic指令。可以使用下面的指令查看。

ros2 topic -h

image-20210803114102048

本着学以致用的目的,小鱼先对比较常用的几个命令进行介绍,其他的我们用到的时候小鱼再介绍(现在介绍反而不好理解)。

3.2.1 ros2 topic list 返回系统中当前活动的所有主题的列表

命令

ros2 topic list

结果

image-20210803114705943

3.2.2 ros2 topic list -t 增加消息类型

命令

ros2 topic list -t

结果

image-20210803114756448

3.2.3 ros2 topic echo 打印实时话题内容

命令

ros2 topic echo /chatter

结果

image-20210803115124591

3.2,4 ros2 topic info 查看主题信息

命令

ros2 topic info  /chatter

结果

image-20210803115320265

3.2.5 ros2 interface show 查看消息类型

上面一个指令告诉大家这个消息是std_msgs/msg/String,那String里面有什么呢?不妨来试一试。

命令

ros2 interface show std_msgs/msg/String

结果

image-20210803115726942

3.2.6 ros2 topic pub arg 手动发布命令

关闭发布者,我们受到来发布

命令

ros2 topic pub /chatter std_msgs/msg/String 'data: "123"'

结果

image-20210803115906116

4.最后

了解完话题,下一节小鱼就会带大家来手动写Python版本的话题通信。

参考链接:Understanding ROS 2 topics — ROS 2 Documentation: Foxy documentation

作者介绍:

我是小鱼,机器人领域资深玩家,现深圳某独脚兽机器人算法工程师一枚 初中学习编程,高中开始接触机器人,大学期间打机器人相关比赛实现月入2W+(比赛奖金) 目前在输出机器人学习指南、论文注解、工作经验,欢迎大家关注小智,一起交流技术,学习机器人

关注
打赏
1666092100
查看更多评论
立即登录/注册

微信扫码登录

0.0638s