-
Kafka创建Topic,还有生产者消费者按照FileBeat格式通信
2019-05-24 10:16:133、Id的规则尚不明确,目前用yyyy-MM-dd日期格式代替id,作为命名后缀。 4、前缀目前在代码中直接定义,后期可以根据需要改为从配置文件或者数据库表中获取。 5、完整代码见附件,包含消费者和生产者的java直接调用... -
python将ros下bag文件的所有topic解析为csv格式
2020-06-21 11:18:51背景:最近在制作kimera的数据集,尤其是运行semantic模块所需要的bag文件中有很多topic,但是很多不知道topic中装的是什么数据,及其格式,所以我就想着怎么可以将bag中的topic都解析数来,这样就能知道bag中都有啥...背景:最近在制作kimera的数据集,尤其是运行semantic模块所需要的bag文件中有很多topic,但是很多不知道topic中装的是什么数据,及其格式,所以我就想着怎么可以将bag中的topic都解析数来,这样就能知道bag中都有啥了.有网友提供了下面的代码,我稍作了些修改,可以在python3下可以顺利运行.如果你的文件夹下有多个bag文件,这个代码可以挨个处理这些bag文件,先为每个bag文件创建一个相应的文件夹,然后把bag文件拷贝进去,然后将bag中的topic都解析为csv格式
#!/usr/bin/python ''' This script saves each topic in a bagfile as a csv. Accepts a filename as an optional argument. Operates on all bagfiles in current directory if no argument provided Written by Nick Speal in May 2013 at McGill University's Aerospace Mechatronics Laboratory www.speal.ca Supervised by Professor Inna Sharf, Professor Meyer Nahon ''' import rosbag, sys, csv import time import string import os #for file management make directory import shutil #for file management, copy file #verify correct input arguments: 1 or 2 if (len(sys.argv) > 2): print("invalid number of arguments: " + str(len(sys.argv))) print("should be 2: 'bag2csv.py' and 'bagName'") print("or just 1 : 'bag2csv.py'") sys.exit(1) elif (len(sys.argv) == 2): listOfBagFiles = [sys.argv[1]] numberOfFiles = "1" print("reading only 1 bagfile: " + str(listOfBagFiles[0])) elif (len(sys.argv) == 1): listOfBagFiles = [f for f in os.listdir(".") if f[-4:] == ".bag"] #get list of only bag files in current dir. numberOfFiles = str(len(listOfBagFiles)) print("reading all " + numberOfFiles + " bagfiles in current directory: \n") for f in listOfBagFiles: print(f) print("\n press ctrl+c in the next 10 seconds to cancel \n") time.sleep(10) else: print("bad argument(s): " + str(sys.argv)) #shouldnt really come up sys.exit(1) count = 0 for bagFile in listOfBagFiles: count += 1 print("reading file " + str(count) + " of " + numberOfFiles + ": " + bagFile) #access bag bag = rosbag.Bag(bagFile) bagContents = bag.read_messages() bagName = bag.filename#/home/yunlei/COOL/kalibr-cde/test/2020-06-13-11-57-29.bag #create a new directory string.rstrip(bagName, ".bag") folder = bagName.split(".bag")[0] try: #else already exists os.makedirs(folder) except: pass shutil.copyfile(bagName, folder + '/' + bagName.split('/')[-1]) #get list of topics from the bag listOfTopics = [] for topic, msg, t in bagContents: if topic not in listOfTopics: listOfTopics.append(topic) for topicName in listOfTopics: #Create a new CSV file for each topic folder + '/' + string.replace(topicName, '/', '_slash_') + '.csv' filename = folder + '/' + topicName.split('/')[-1] + '.csv' with open(filename, 'w+') as csvfile: filewriter = csv.writer(csvfile, delimiter = ',') firstIteration = True #allows header row for subtopic, msg, t in bag.read_messages(topicName): # for each instant in time that has data for topicName #parse data from this instant, which is of the form of multiple lines of "Name: value\n" # - put it in the form of a list of 2-element lists msgString = str(msg) msgList = msgString.split('\n') instantaneousListOfData = [] for nameValuePair in msgList: splitPair = nameValuePair.split(':') for i in range(len(splitPair)): #should be 0 to 1 splitPair[i] = splitPair[i].strip() instantaneousListOfData.append(splitPair) #write the first row from the first element of each pair if firstIteration: # header headers = ["rosbagTimestamp"] #first column header for pair in instantaneousListOfData: headers.append(pair[0]) filewriter.writerow(headers) firstIteration = False # write the value from each pair to the file values = [str(t)] #first column will have rosbag timestamp for pair in instantaneousListOfData: if len(pair) > 1: values.append(pair[1]) filewriter.writerow(values) bag.close() print("Done reading all " + numberOfFiles + " bag files.")
-
ROS小海龟的topic 消息发布格式
2018-10-08 09:30:47rostopic pub -1 /turtle1/cmd_vel geometry_msgs/Twist -- '[2,0,0]' '[0,0,1.8]' https://www.cnblogs.com/BlueMountain-HaggenDazs/p/6277100.htmlrostopic pub -1 /turtle1/cmd_vel geometry_msgs/Twist -- '[2,0,0]' '[0,0,1.8]'
https://www.cnblogs.com/BlueMountain-HaggenDazs/p/6277100.html
-
ROS中map与costmap的topic数据格式定义
2017-10-18 00:08:58map与costmap都是以nav_msgs::OccupancyGrid类型发布其topic。其中整张地图的障碍物信息存放在data数据成员中,data是一个int8类型的vector向量,即一维数组。假设一张pgm的map地图,宽:width,高:height,单位为...map与costmap都是以nav_msgs::OccupancyGrid类型发布其topic。其中整张地图的障碍物信息存放在data数据成员中,data是一个int8类型的vector向量,即一维数组。假设一张pgm的map地图,宽:width,高:height,单位为像素,分辨路为resolution,左下角像素点在世界坐标系下的位置为:(ox,oy),单位米,那么世界坐标系下一点(x,y)单位米,假设其在地图中,那么该点对应的data中的索引index为:
index = (x-ox)/resolution+(y-oy)/resolution*width
(注:index为int8类型,所以要将结果进行下类型转换),
那么该点在地图中的信息即为data[index]
即:data是按照那张地图图片的自底向上,自左至右逐个像素点存储的
map中data存储的格式如下:
0:空白区域
100:障碍物
-1:未知
1-99:根据像素的灰度值转换后的值,代表有障碍物的概率(不确定,猜测是这个含义,实际用的时候把这个值都当作无障碍物)
costmap中data存储格式如下:
0:空白区域
100:障碍物层
99:膨胀层
1-98:距离障碍物层的远近获得的代价值
-1:未知区域
-
ros关于topic的理解
2020-04-26 08:38:38node发布的topic格式 /+名称(可以是二级名称的形式) 发布的topic放在master中,所有的node都可以订阅,但是名称要一样 当一个node订阅一个topic,但是这个topic的node还没有启动,这时rosnode info 这个node,就...node发布的topic格式 /+名称(可以是二级名称的形式)
发布的topic放在master中,所有的node都可以订阅,但是名称要一样
当一个node订阅一个topic,但是这个topic的node还没有启动,这时rosnode info 这个node,就可以看到他所订阅的这个topic还是未定义类型。
-
MAVROS感觉只是起到一个数据格式转换的作用,把ROS TOPIC里面的指令转化为MAVLINK格式发给PX4
2020-08-05 07:41:50MAVROS感觉只是起到一个数据格式转换的作用,把ROS TOPIC里面的指令转化为MAVLINK格式发给PX4,所以指令已经由GAAS或者一个功能包发出来了,MAVROS只是起到一个格式转换转发的作用。 ... ... -
rosbag记录topic数据并把bag包的数据转换成excel格式
2021-04-12 09:02:41把bag包的数据转换成excel rostopic echo -b <BAGFILE> -p <TOPIC>...BAGFILE是bag文件,TOPIC为数据所在的topic 例如 rostopic echo -b file.bag -p /differ/demo > cross_track_error.csv -
在《Pro Git》引用格式推送这节中出现 fatal: invalid refspec ' topic:refs/remotes/origin/topic' ...
2020-05-31 12:16:14在《Pro Git》 — 引用格式推送 这一小节中,有下面的命令和输出结果 git fetch origin master:refs/remotes/origin/mymaster \ topic:refs/remotes/origin/topic From git@github.com:schacon/simplegit ! ... -
ROS错误:摄像头数据格式错误 wants topic /image/compressed to have datatype/md5sum
2019-05-06 18:17:26ROS错误 摄像头数据格式错误wants topic /image/compressed to have datatype/md5sum 错误提示: [ERROR] 1260927377.348922000: Received error message in header for connection to [TCPROS connection to ... -
Kafka:ZK+Kafka+Spark Streaming集群环境搭建(二十九):推送avro格式数据到topic,并使用spark ...
2018-10-23 10:03:00推送avro格式数据到topic 源代码:https://github.com/Neuw84/structured-streaming-avro-demo/blob/master/src/main/java/es/aconde/structured/GeneratorDemo.java package es.aconde.structured; import ... -
带有 数组格式的自定义ros message
2018-10-15 14:31:20最近由于需求,需要自定义一些topic格式进行数据的处理。基于常见的数据类型:int32 flosat32 bool 等可以定义出需要的消息格式。 如:example.msg int32 a float32 b bool c 则在终端查看消息类型为example.msg... -
关于python crash course中添加topic页面时出现时间戳格式错误的问题的解决方法
2020-04-18 22:20:46问题:Could not parse the remainder: ‘: ‘M d, Y H:i’’ from ‘entry.date_added|date: ‘M d, Y H:i’’ 解决方法:去掉date:后面,‘M前面的空格即可。 -
mqtt服务器_tlink物联网服务器后台MQTT协议命令下发,分析数据格式和内容
2020-12-05 02:36:28开关设备首先我们进入控制台内的设备管理页面,我们用开关设备测试命令下发功能,使用MQTT协议,接收命令推送之前,我们必须订阅相关的Topic后才能收到推送,我们需要订阅的Topic格式如下:*/+ 其中*... -
Kafka:ZK+Kafka+Spark Streaming集群环境搭建(十一)定制一个arvo格式文件发送到kafka的topic,通过...
2018-07-03 23:32:00将arvo格式数据发送到kafka的topic 第一步:定制avro schema: { "type": "record", "name": "userlog", "fields": [ {"name": "ip","type": "string"}, {"name": "identi... -
Kafka学习笔记:位移主题Offsets Topic
2019-12-26 10:15:56__consumer_offsets 在 Kafka 源码中有个更为正式的名字,叫位移主题,即 Offsets Topic。 位移主题就是普通的 Kafka 主题。它的消息格式却是 Kafka 自己定义的,不能修改,不能随意向里面写数据. 如果位移主题是 ... -
Kafka topic常用命令 查看 创建 修改 彻底删除topic(删除数据目录和在zk上的信息)
2020-09-17 19:31:00命令格式:注意空格 ./kafka-topics.sh --create --topic topic名称--partitions分区数--replication-factor备份数--zookeeperZooKeeper的任意一个节点或者全部的IP:Port/kafka 示例: ./kafka-topics.sh --... -
mqtt 获取所有topic_MQTT topic 设计|匹配规则|设计实践总结
2020-12-19 08:04:15MQTT topic匹配规则基础1.主题层级分隔符—“/”:用于分割主题层级,/分割后的主题,这是消息主题层级设计中很重要的符号e.g:aaaa/bbbb和 aaaa/bbbb/cccc 和aaaa/bbbb/cccc/dddd ,这样的消息主题格式,是一个层层... -
MQTT topic匹配规则
2019-03-01 11:40:26转载自:MQTT topic匹配规则基础 主题层级分隔符 / : 用于分割主题层级,/分割后的主题,这是消息主题层级设计中很重要的符号。 比方说: aaa/bbb和 aaa/bbb/ccc 和aaa/bbb/ccc/ddd ,这样的消息主题格式,是一个...
收藏数
1,084
精华内容
433