Skip to content

Failed to read vector of floats #2

Description

@PatWie

For the data chunk

data = [217, 135, 153, 12, 0, 0, 0, 0, 
        251, 133, 153, 12, 0, 0, 0, 0, 
        231, 207, 50, 49, 
        64, 131, 213, 36, 
        215, 182, 109, 50, 
        247, 152, 146, 50, 
        0, 0, 192, 127, 
        0, 0, 192, 127, 
        0, 0, 192, 127, 
        0, 0, 192, 127, 
        0, 0, 192, 127, 
        0, 0, 192, 127, 
        0, 0, 192, 127, 
        0, 0, 192, 127, 
        0, 0]

and field description

[('uint64_t', 1, 'timestamp'),
 ('uint64_t', 1, 'timestamp_sample'),
 ('float', 12, 'control'),
 ('uint16_t', 1, 'reversible_flags'),
 ('uint8_t', 6, '_padding0')]

This library only outputs the first two items from the field description in

println!("{} at {}: {:?}", item.name(), item.index(), item.data());

The extracted format from this library is

["uint64_t timestamp", "uint64_t timestamp_sample", "float[12] control", "uint16_t reversible_flags", "uint8_t[6] _padding0", ""]

Here is how I correctly parse them

import struct

timestamp = struct.unpack('<Q', bytes([217, 135, 153, 12, 0, 0, 0, 0]))[0]
timestamp_sample = struct.unpack('<Q', bytes([251, 133, 153, 12, 0, 0, 0, 0]))[0]
control_0 = struct.unpack('<f', bytes([231, 207, 50, 49]))
control_1 = struct.unpack('<f', bytes([64, 131, 213, 36]))
control_2 = struct.unpack('<f', bytes([215, 182, 109, 50]))
control_3 = struct.unpack('<f', bytes([247, 152, 146, 50]))
control_4 = np.nan 
# ...
control_11 = np.nan 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions