From a2be1fdf5e8d6f7f2f31efbee4173677108968ac Mon Sep 17 00:00:00 2001 From: dehann Date: Thu, 28 Jul 2022 22:35:57 -0700 Subject: [PATCH 1/2] rm bag compress kwargs --- src/ros/Utils/RosbagSubscriber.jl | 10 ++++++---- src/ros/Utils/rosbagReader.py | 4 ++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/ros/Utils/RosbagSubscriber.jl b/src/ros/Utils/RosbagSubscriber.jl index 17329219a..c3f54e125 100644 --- a/src/ros/Utils/RosbagSubscriber.jl +++ b/src/ros/Utils/RosbagSubscriber.jl @@ -48,13 +48,15 @@ mutable struct RosbagSubscriber syncBuffer::Dict{Symbol,Tuple{DateTime, Int}} # t,ns,msgdata nextMsgChl::Symbol nextMsgTimestamp::Tuple{DateTime, Int} + compression::Any # constructors end RosbagSubscriber(bagfile::AbstractString; + compression=nothing, channels::Vector{Symbol}=Symbol[], callbacks::Dict{Symbol,Function}=Dict{Symbol,Function}(), readers::Dict{Symbol,PyObject}=Dict{Symbol,PyObject}(), - syncBuffer::Dict{Symbol,Tuple{DateTime, Int}}=Dict{Symbol,Tuple{DateTime, Int}}() ) = RosbagSubscriber(bagfile,channels,callbacks,readers,syncBuffer, :null, (unix2datetime(0),0)) + syncBuffer::Dict{Symbol,Tuple{DateTime, Int}}=Dict{Symbol,Tuple{DateTime, Int}}() ) = RosbagSubscriber(bagfile,channels,callbacks,readers,syncBuffer, :null, (unix2datetime(0),0),compression) # # loss of accuracy (Julia only Millisecond) @@ -97,8 +99,8 @@ function loop!(rbs::RosbagSubscriber, args...) rbs.callbacks[rbs.nextMsgChl](msg, args...) true else - println("false, dont know how to handle message time as typeof(msgT)=$(typeof(msgT))") - @show msg + @warn "false, dont know how to handle message" rbs.nextMsgChl msgT maxlog=10 + # @show msg false end end @@ -114,5 +116,5 @@ function (rbs::RosbagSubscriber)( chl::AbstractString, # include the type converter, see ref: https://github.com/jdlangs/RobotOS.jl/blob/21a7088461a21bc9b24cd2763254d5043d5b1800/src/callbacks.jl#L23 rbs.callbacks[cn] = (m)->callback(convert(MT,m[2]),args...) rbs.syncBuffer[cn] = (unix2datetime(0), 0) - rbs.readers[cn] = RosbagParser(rbs.bagfile, chl) + rbs.readers[cn] = RosbagParser(rbs.bagfile, chl) #; rbs.compression) end diff --git a/src/ros/Utils/rosbagReader.py b/src/ros/Utils/rosbagReader.py index 05f3ceab5..a08fd462d 100644 --- a/src/ros/Utils/rosbagReader.py +++ b/src/ros/Utils/rosbagReader.py @@ -6,11 +6,11 @@ import sys class RosbagParser: - def __init__(self, bag_file_name, topic_name): + def __init__(self, bag_file_name, topic_name): #, compression=None): #bag_file_name = sys.argv[1] #topic_name = sys.argv[2] - self.bag = rosbag.Bag(bag_file_name) + self.bag = rosbag.Bag(bag_file_name, 'r') #, compression=compression) self.bag_contents = self.bag.read_messages(topics=[topic_name]) self.idx = 0 From 4995420080c134726f6acda29f6a5f2bb1999e8c Mon Sep 17 00:00:00 2001 From: dehann Date: Fri, 29 Jul 2022 00:00:18 -0700 Subject: [PATCH 2/2] better warn message --- src/ros/Utils/RosbagSubscriber.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ros/Utils/RosbagSubscriber.jl b/src/ros/Utils/RosbagSubscriber.jl index c3f54e125..4b20fcb71 100644 --- a/src/ros/Utils/RosbagSubscriber.jl +++ b/src/ros/Utils/RosbagSubscriber.jl @@ -99,7 +99,7 @@ function loop!(rbs::RosbagSubscriber, args...) rbs.callbacks[rbs.nextMsgChl](msg, args...) true else - @warn "false, dont know how to handle message" rbs.nextMsgChl msgT maxlog=10 + @warn "Unsure about decoding this topic:msg type pair, make sure the subscribed topic names are spelled exactly right." rbs.nextMsgChl msgT maxlog=10 # @show msg false end