发布不同类型的话题问题

在ROS开发中尝试将不同类型的消息发布到同一话题/helloworld,但测试结果显示,订阅者只能接收到最后发布者的数据,并且先前的发布者收到警告,表明主题类型不匹配。这表明一个ROS话题不能同时承载不同消息类型。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

在实际的开发中,想把不同的消息发布到一个模块中,就考虑把不同类型的消息发布到一个话题上,这样似乎可以省事甚多

然后通过命令测试了一下:
rostopic pub /helloworld std_msgs/String “this is a test string” -r 1
rostopic pub /helloworld std_msgs/Bool 1 -r 1
rostopic echo “/helloworld”


测试现象

订阅者只能收到后发布的数据,先发布者报警告如下:
[WARN] [1581548856.701520]: Could not process inbound connection: topic types do not match: [std_msgs/Bool] vs. [std_msgs/String]{‘message_definition’: ‘bool data’, ‘callerid’: ‘/rostopic_16202_1581548852459’, ‘tcp_nodelay’: ‘0’, ‘md5sum’: ‘8b94c1b53db61fb6aed406028ad6332a’, ‘topic’: ‘/helloworld’, ‘type’: ‘std_msgs/Bool’}[WARN] [1581548856.701520]: Could not process inbound connection: topic types do not match: [st

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

贾大君

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值