主要参考链接:
http://wiki.ros.org/msg
最近由于需求,需要自定义一些topic格式进行数据的处理。基于常见的数据类型:int32 flosat32 bool 等可以定义出需要的消息格式。
如:example.msg
int32 a
float32 b
bool c
123
则在终端查看消息类型为example.msg定义的example_topic时
rostopic echo /example_topic
1
有类似如下显示:
a: 1
b: 1.0
c: true
---
a: 1
b: 1.0
c: true
---
a: 1
b: 1.0
c: true
---
a: 1
b: 1.0
c: true
---
12345678910111213141516
当显示的频率较大时,由于数据刷新很快,对于数据的可读性、分析和把握提出很高的要求。为了改善上述问题,可以在消息前添加Header格式数据。
std_msgs/Header message :
# Standard metadata for higher-level stamped data types.
# This is generally used to communicate timestamped data
# in a particular coordinate frame.
#
# sequence ID: consecutively increasing ID
uint32 seq
#Two-integer timestamp that is expressed as:
# * stamp.sec: seconds (stamp_secs) since epoch (in Python the variable is called 'secs')
# * stamp.nsec: nanoseconds since stamp_secs (in Python the variable is called 'nsecs')
# time-handling sugar is provided by the client library
time stamp
#Frame this data is associated with
# 0: no frame
# 1: global frame
string frame_id
123456789101112131415
原example.msg可以修改为:
Header header
int32 a
float32 b
bool c
1234
此时再次输出example_topic时,得到类似下述显示:
header:
seq: 1
stamp:
secs: 1538813853
nsecs: 968391761
frame_id: frame_test
a: 1
b: 1.0
c: true
---
header:
seq: 2
stamp:
secs: 1538813854
nsecs: 67791173
frame_id: frame_test
a: 1
b: 1.0
c: true
---
header:
seq: 3
stamp:
secs: 1538813854
nsecs: 168768708
frame_id: frame_test
a: 1
b: 1.0
c: true
---
123456789101112131415161718192021222324252627282930
此时可以根据seq、secs和nsecs值可以更好的观测和分析终端显示的数据。
seq:topic当前发布的次数
secs:topic发布的系统时间 unit:秒
nsecs:topic发布的系统时间 unit:纳秒
---------------------
【转载】:https://blog.csdn.net/bbtang5568 ... 939?utm_source=copy |
|