Exemple #1
0
def test_scans_first_packet(packet: client.LidarPacket,
                            packets: client.PacketSource) -> None:
    """Check that data in the first packet survives batching to a scan."""
    scans = iter(client.Scans(packets))
    scan = next(scans)

    h = packet._pf.pixels_per_column
    w = packet._pf.columns_per_packet

    assert np.array_equal(packet.field(ChanField.RANGE),
                          scan.field(ChanField.RANGE)[:h, :w])

    assert np.array_equal(packet.field(ChanField.REFLECTIVITY),
                          scan.field(ChanField.REFLECTIVITY)[:h, :w])

    assert np.array_equal(packet.field(client.ChanField.SIGNAL),
                          scan.field(client.ChanField.SIGNAL)[:h, :w])

    assert np.array_equal(packet.field(client.ChanField.NEAR_IR),
                          scan.field(client.ChanField.NEAR_IR)[:h, :w])

    assert np.all(packet.header(ColHeader.FRAME_ID) == scan.frame_id)

    assert np.array_equal(packet.header(ColHeader.TIMESTAMP),
                          scan.header(ColHeader.TIMESTAMP)[:w])

    assert np.array_equal(packet.header(ColHeader.ENCODER_COUNT),
                          scan.header(ColHeader.ENCODER_COUNT)[:w])

    assert np.array_equal(packet.header(ColHeader.STATUS),
                          scan.header(ColHeader.STATUS)[:w])
Exemple #2
0
def test_read_real_packet(packet: client.LidarPacket) -> None:
    """Read some arbitrary values from a packet and check header invariants."""
    assert packet.field(client.ChanField.RANGE)[0, 0] == 1723
    assert packet.field(client.ChanField.REFLECTIVITY)[0, 0] == 196
    assert packet.field(client.ChanField.SIGNAL)[0, 0] == 66
    assert packet.field(client.ChanField.NEAR_IR)[0, 0] == 1768

    assert np.all(np.diff(packet.header(client.ColHeader.FRAME_ID)) == 0)
    assert np.all(np.diff(packet.header(client.ColHeader.MEASUREMENT_ID)) == 1)
    # in 512xN mode, the angle between measurements is exactly 176 encoder ticks
    assert np.all(
        np.diff(packet.header(client.ColHeader.ENCODER_COUNT)) == 176)
    assert np.all(packet.header(client.ColHeader.STATUS) == 0xffffffff)
def test_read_legacy_packet(packet: client.LidarPacket) -> None:
    """Read some arbitrary values from a packet and check header invariants."""
    assert packet.field(client.ChanField.RANGE)[-1, 0] == 12099
    assert packet.field(client.ChanField.REFLECTIVITY)[-1, 0] == 1017
    assert packet.field(client.ChanField.SIGNAL)[-1, 0] == 6
    assert packet.field(client.ChanField.NEAR_IR)[-1, 0] == 13

    assert np.all(np.diff(packet.header(client.ColHeader.FRAME_ID)) == 0)
    assert np.all(np.diff(packet.header(client.ColHeader.MEASUREMENT_ID)) == 1)
    assert np.all(np.diff(packet.timestamp) > 0)
    assert np.all(np.diff(packet.measurement_id) == 1)
    assert packet.packet_type == 0
    assert packet.frame_id == 5424
    assert packet.init_id == 0
    assert packet.prod_sn == 0
    # in 1024xN mode, the angle between measurements is exactly 88 encoder ticks
    assert np.all(np.diff(packet.header(client.ColHeader.ENCODER_COUNT)) == 88)
    assert np.all(packet.status == 0xffffffff)