@foxglove/velodyne-cloud
Version:
TypeScript library for converting Velodyne LIDAR packet data to point clouds
40 lines • 2.16 kB
JavaScript
;
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/
Object.defineProperty(exports, "__esModule", { value: true });
const RawPacket_1 = require("./RawPacket");
const VelodyneTypes_1 = require("./VelodyneTypes");
const packets_1 = require("./fixtures/packets");
describe("RawPacket", () => {
it("can decode a packet from an HDL-32E", () => {
expect(() => new RawPacket_1.RawPacket(new Uint8Array())).toThrow();
expect(() => new RawPacket_1.RawPacket(new Uint8Array(1205))).toThrow();
expect(() => new RawPacket_1.RawPacket(new Uint8Array(1207))).toThrow();
expect(() => new RawPacket_1.RawPacket(new Uint8Array(1206))).not.toThrow();
const raw = new RawPacket_1.RawPacket(packets_1.HDL32E_PACKET1);
expect(raw.blocks).toHaveLength(12);
expect(raw.data).toHaveLength(1206);
expect(raw.factoryField1).toEqual(VelodyneTypes_1.ReturnMode.Strongest);
expect(raw.factoryField2).toEqual(VelodyneTypes_1.FactoryId.HDL32E);
expect(raw.gpsTimestamp).toEqual(757034951);
expect(raw.returnMode).toEqual(VelodyneTypes_1.ReturnMode.Strongest);
expect(raw.factoryId).toEqual(VelodyneTypes_1.FactoryId.HDL32E);
expect(raw.blocks).toHaveLength(12);
const block0 = raw.blocks[0];
expect(block0.data).toHaveLength(100);
expect(block0.blockId).toEqual(VelodyneTypes_1.BlockId.Block_0_To_31);
expect(block0.rotation).toEqual(22288);
expect(block0.isUpperBlock()).toEqual(false);
expect(block0.distance(0)).toEqual(1230);
expect(block0.intensity(0)).toEqual(9);
expect(block0.distance(1)).toEqual(2537);
expect(block0.intensity(1)).toEqual(4);
for (const block of raw.blocks) {
expect(block.data).toHaveLength(100);
expect(block.blockId).toEqual(VelodyneTypes_1.BlockId.Block_0_To_31);
expect(block.isUpperBlock()).toEqual(false);
}
});
});
//# sourceMappingURL=RawPacket.test.js.map