ROS datatype/md5sum错误

本文解决了一个关于ROS环境中话题类型不匹配的错误,详细描述了从std_msgs::Float64到std_msgs::Float64MultiArray的类型冲突,并通过类型转换成功解决了问题。

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

I got this error today.

Problem

[ERROR] [1576785283.032878520]: Client [/rostopic_21515_1576784759002] wants topic /timestamp to have datatype/md5sum std_msgs/Float64MultiArray/4b7d974086d4060e7db4613a7e6c3ba4], but our version has [std_msgs/Float64/fdb28210bfa9d7c91146260178d9a584]. Dropping connection.

What I did is that I wanted to publish a topic with std_msgs::Float64.

define:

std_msgs::Float64 time_msg;
std::chrono::duration<double> t;

assignment:

time_msg.data = t.count();
time_pub_.publish(time_msg);

Solution

Becuase the error showed that the type of message is error (std_msgs::Float64-> std_msgs::Float64MultiArray), so I think the mistake is on t.count(). It looks like std_msgs::Float64MultiArray.
I add a type conversion for it.

time_msg.data = (double)t.count();

It does work!!!
Super:)

评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值