Get one frame (spin) of lidar data

I try to get full 360 deg lidar data from lidar sample record data in /usr/local/driveworks-2.2/data/samples/sensors/lidar/lidar:top:hdl64e.bin using ‘lidar_replay’ sample code.

In this sample code, I think that I can use computeSpin() function to get a one frame data of lidar from nextPacket->pointsXYZI (I want to save x,y,z,intensity to text file)
But I don’t know how to get full frame data. Because from nextPacket->pointsXYZI, it is possible to get a one layer of data (not full 360 deg frame data).
I check the result text file and visualize it, however, I can only get a single plane of data (i think it is bottom lidar data)

how can I get a full 360 deg one frame lidar data?

++ and I think when running while loop in computeSpin(), each iteration ‘nextPacket->pointsXYZI’ should give me a partial data of full frame data but i get a only partial data looks like above. each iteration, ‘nextPacket->pointsXYZI’ return partial data (also I save partial data at txt file) and at the end of spin I should have all one frame data. But things don’t go as I expected.

Hello @pjhkb083gak9,
you are on the right track.
notice that because the recording always starts asynchronously to the LiDAR run, the first spin that was recorded reaches the “scanComplete” flag to be true while not the whole spin was recorded ( in this specific recording only half of the spin was recorded) - so if you wish to extract a full 360 deg spin, you should ignore the first spin (the first time the updateFrame is being called in the sample code).

So, I suggest you put your code right aside to the calling of updateFrame function (where the status == DW_SUCCESS condition is satisfied from dwSensorLidar_readPacket) and use a similar class variable to m_pointCloud for accumulating the data you wish to have for the relevant point cloud spin.

also, please consider the following code to replace with updateFrame function in order to draw a specific LiDAR spin number (spinNumToDraw ):

void updateFrame(uint32_t accumulatedPoints, uint32_t packetCount,
                     dwTime_t hostTimestamp, dwTime_t sensorTimestamp)
    	static int spinNum = 0;
    	static const int spinNumToDraw = 5; // ignoring spin 0 so this value should be higher than 0
    	if( spinNum < spinNumToDraw) // waiting for the spin number we want to draw
    	else if(spinNum == spinNumToDraw)
			m_pointCloudBufferSize = accumulatedPoints;
			// Grab properties, in case they were changed while running
			dwSensorLidar_getProperties(&m_lidarProperties, m_lidarSensor);

			m_message1 = "Host timestamp    (us) " + std::to_string(hostTimestamp);
			m_message2 = "Sensor timestamp (us) " + std::to_string(sensorTimestamp);
			m_message3 = "Packets per scan         " + std::to_string(packetCount);
			m_message4 = "Points per scan           " + std::to_string(accumulatedPoints);
			m_message5 = "Frequency (Hz)           " + std::to_string(m_lidarProperties.spinFrequency);
			m_message6 = "Lidar Device               " + std::string{m_lidarProperties.deviceString};
			m_message7 = "Press ESC to exit";

1 Like