[Rock-dev] Generating one gnuplot data file from different logs
Leif Christensen
leif.christensen at dfki.de
Tue Jun 18 18:07:47 CEST 2013
Thx, that boils it down to:
#! /usr/bin/env ruby
2 require 'orocos/log'
3 include Orocos
4
5 replay = Log::Replay::open("xsens_imu.0.log", "sysmon.0.log")
6 replay.use_sample_time = true;
7
8 imu_r = replay.xsens_imu.calibrated_sensors.reader
9 joint_r = replay.sysmon.system_status.reader
10
11 replay.run do |port, data|
12 imu = imu_r.read
13 joint = joint_r.read
14 if !imu.nil? and !joint.nil?
15 printf "%16.5f %+6.5f %+6.5f\n", data.time.to_f,
16 joint.asguardJointEncoder,
17 imu.mag[0]
18 end
19 end
Am 18.06.2013 14:12, schrieb Alexander Duda:
> On 06/18/2013 01:19 PM, Leif Christensen wrote:
>> Hi,
>>
>> I'm generating my own (gnuplot) data file from different orocos log
>> files using this script:
>>
>> 1 #! /usr/bin/env ruby
>> 2 require 'orocos/log'
>> 3 include Orocos
>> 4
>> 5 replay = Log::Replay::open("xsens_imu.0.log", "sysmon.0.log")
>> 6
>> 7 replay.sysmon.system_status.tracked = true
>> 8 replay.xsens_imu.calibrated_sensors.tracked = true
>> 9
>> 10 #reader1 = replay.xsens_imu.calibrated_sensors.reader
>> 11 #reader2 = replay.sysmon.system_status.reader
>> 12
>> 13 replay.align
>> 14
>> 15 replay.run do |port,data|
>> 16 # puts reader1.read
>> 17 # puts reader2.read
>> 18 t = data.time if port.name == 'system_status' or
>> 'calibrated_sensors'
>> 19 enc = data.asguardJointEncoder if port.name == 'system_status'
>> 20 magx = data.mag[0] if port.name == 'calibrated_sensors'
>> 21 if magx.nil?
>> 22 puts "magx nil!"
>> 23 elsif t.nil?
>> 24 puts "t nil"
>> 25 elsif enc.nil?
>> 26 puts "enc nil"
>> 27 else
>> 28 printf "%016.4f %6.4f %6.4f\n", t.to_f, enc, magx
>> 29 end
>> 30 end
>>
>> Writing the script, several questions pop up:
>>
>> a) is the replay.align call necessary or already done inside open/load?
>
> if you are not calling it Replay will do it for you the first time you
> call step or run
>
>> b) is this call doing what I hope, sorting the samples of the different
>> streams for the replay
>
> yes, you will get the samples ordered after the time they were logged
>
>> c) if so, is it using logical/writing or sample time (if the sample
>> provides a time) to sort
>
> you can configure Replay to use the time field of the sample but this is
> not the default behaviour
>
>> d) When accessing 'data' in the replay.run loop, one of the values is
>> always nil:
>>
>> >...
>> >magx nil!
>> >enc nil
>> >magx nil!
>> >enc nil
>> >...
>>
>> I guess that is because of the two streams are interleaved now and there
>> is no reader defined providing always the last valid reading. But the
>> value should't be nil, since it is asigned only in case of the right
>> port being read ('... if port.name == ...')
>
> "if" returns always nil if the expression is false and no else is specified
>>
>> e) What would be your suggestion to come up with a simple data file
>> combining streams from different locations preserving the original
>> sampling time and order? Tried using the pocolog tool, but wasn't able
>> to give multiple stream arguments for the -s option
> I would use Replay and would read all ports every time a new sample was
> replayed.
>
> Greets
> Alex
>
>
>
--
Leif Christensen
DFKI Bremen
Robotics Innovation Center
Robert-Hooke-Straße 5
28359 Bremen, Germany
Phone: +49 (0)421 17845-4149
Fax: +49 (0)421 17845-4150
E-Mail: leif.christensen at dfki.de
Weitere Informationen: http://www.dfki.de/robotik
-----------------------------------------------------------------------
Deutsches Forschungszentrum fuer Kuenstliche Intelligenz GmbH
Firmensitz: Trippstadter Straße 122, D-67663 Kaiserslautern
Geschaeftsfuehrung: Prof. Dr. Dr. h.c. mult. Wolfgang Wahlster
(Vorsitzender) Dr. Walter Olthoff
Vorsitzender des Aufsichtsrats: Prof. Dr. h.c. Hans A. Aukes
Amtsgericht Kaiserslautern, HRB 2313
Sitz der Gesellschaft: Kaiserslautern (HRB 2313)
USt-Id.Nr.: DE 148646973
Steuernummer: 19/673/0060/3
-----------------------------------------------------------------------
More information about the Rock-dev
mailing list