Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft: [fix_extract] Not working first attempts to fix the extract feature #38

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Debug pocolog command",
"type": "Ruby",
"request": "launch",
"program": "${rock:srcDir}/bin/pocolog",
"args": [
"${rock:srcDir}/test/data/laser_scanner_Logger.0.log",
"--extract",
"${rock:srcDir}/test/data/sample_velodyne_only.log",
"--stream",
"velodyne.laser_scans:0:5"
]
}
]
}
62 changes: 39 additions & 23 deletions bin/pocolog
Original file line number Diff line number Diff line change
Expand Up @@ -166,39 +166,54 @@ module Pocolog
from.each do |file_io|
from = Logfiles.new(file_io)
index_mapping = Array.new
from.each_block do |info|
if info.type == STREAM_BLOCK
stream = from.read_stream_declaration
if streams.empty? || streams.has_key?(stream.name)
if !enabled[[stream.name, stream.typename]]
enabled[[stream.name, stream.typename]] = next_index
next_index += 1
end
index_mapping[info.index] = [enabled[[stream.name, stream.typename]]].pack("v")
start_sample[info.index], sample_count[info.index] = *streams[stream.name]
puts "from #{from.path}"
from.each_stream do |stream|
#from.each_block do |info| #
#binding.pry
#if info.type == STREAM_BLOCK
# stream = from.read_stream_declaration
if streams.empty? || streams.has_key?(stream.name)
if !enabled[[stream.name, stream.typename]]
enabled[[stream.name, stream.typename]] = next_index
next_index += 1
end
index_mapping[stream.index] = [enabled[[stream.name, stream.typename]]].pack("v")
start_sample[stream.index], sample_count[stream.index] = *streams[stream.name]
end
#end

#stream_index = index_mapping[info.index]

stream_index = index_mapping[stream.index]

stream_index = index_mapping[info.index]
if stream_index
if (skip = start_sample[info.index]) && info.type == DATA_BLOCK
start_sample[info.index] =
if skip > 1 then skip - 1
else nil
end
next
if stream.name == "velodyne.laser_scans"
puts "stream_index = #{stream_index}"
puts "index_mapping = #{index_mapping}"
end

Logfiles.copy_block(info, from.rio, to, buffer) do |buffer|
#if (skip = start_sample[info.index]) && info.type == DATA_BLOCK
# start_sample[info.index] =
# if skip > 1 then skip - 1
# else nil
# end
# next
#end

#Logfiles.copy_block(stream.info, from.io, to, buffer) do |buffer|
#Logfiles.copy_block(from.block_stream, from.io, to, buffer) do |buffer|
Logfiles.copy_block(stream.info, from.io, to, buffer) do |buffer|
buffer[2, 2] = stream_index
buffer
end
remaining = sample_count[info.index]
if remaining && info.type == DATA_BLOCK
remaining = sample_count[stream.index]
puts "remaining = #{remaining}"
if remaining #&& stream.type == DATA_BLOCK
puts "remaining = #{remaining}"
if remaining > 1
sample_count[info.index] = remaining - 1
sample_count[stream.index] = remaining - 1
else # reached the max count, disable copying that stream
index_mapping[info.index] = nil
index_mapping[stream.index] = nil
stream_index = nil
end
end
end
Expand Down Expand Up @@ -676,6 +691,7 @@ parser = OptionParser.new do |opts|
name, start, finish = n.split(':')
start = Integer(start) if start
finish = Integer(finish) if finish
puts "start {#{start}} finish {#{finish}} for #{name}"
config.streams[name] = [start, finish - (start || 0)]
end
end
Expand Down
4 changes: 2 additions & 2 deletions lib/pocolog/convert.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ def self.write_prologue(to_io, big_endian = nil)

def self.copy_block(block_info, from_io, to_io, buffer)
# copy the block as-is
from_io.seek(block_info.pos)
buffer = from_io.read(BLOCK_HEADER_SIZE + block_info.payload_size, buffer)
from_io.seek(block_info.interval_io[0])
buffer = from_io.read(BLOCK_HEADER_SIZE + block_info.size, buffer)
if block_given?
buffer = yield(buffer)
end
Expand Down