Skip to content

raisim::SpinningLidar ​

class · #include <raisim/sensors/SpinningLidar.hpp>

Inherits: raisim::Sensor

Spinning (rotating-head) lidar simulated by CPU ray casting.

The head spins about the sensor's +z axis. A ray with yaw y and pitch p has the sensor-frame direction (cos p cos y, cos p sin y, sin p): yaw 0 is +x, positive pitch tilts toward +z. Each update casts only the yaw columns that the head swept since the previous update (spinningRate * elapsed time), so one scan generally covers a partial revolution.

Nested classes ​

Constructors & destructor ​

SpinningLidar ​

cpp
SpinningLidar(
    const SpinningLidarProperties &prop,
    class ArticulatedSystem *as,
    const Vec<3> &pos,
    const Mat<3, 3> &rot)

Create a lidar. The measurement source is RAISIM.

Parameters

ParameterDescription
prop (in)Lidar properties (validated; invalid values cause a fatal error).
as (in)Owning articulated system.
pos (in)Sensor position relative to the body (link) it is defined on.
rot (in)Sensor orientation relative to the body (link) it is defined on.

Public member functions ​

serializeProp ​

cpp
server::BoundedWriter serializeProp(server::BoundedWriter data) const final

Used by the server. Do not use it if you don't know what it does. It serializes the sensor properties

Parameters

ParameterDescription
data (in)where the property is written; throws server::SerializationError if it does not fit

Returns where the next data should be written

getProperties ​

cpp
const SpinningLidarProperties &getProperties() const

Returns The lidar configuration properties.

setProperties ​

cpp
void setProperties(const SpinningLidarProperties &prop)

Replace the lidar configuration, clear the scan and reset the scan timestamp to 0.

Parameters

ParameterDescription
prop (in)New properties. name and full_name must match the current ones (fatal error otherwise).

getScan ​

cpp
const std::vector<raisim::Vec<3>, AlignedAllocator<raisim::Vec<3>, 32>> &getScan() const

Returns Hit points of the latest scan in the sensor frame (relative to the sensor origin). Rays without a hit within the range are omitted, so the size varies. Points are ordered by yaw column (in sweep order), then by pitch from pitchMinAngle to pitchMaxAngle.

setScan ​

cpp
void setScan(const std::vector<raisim::Vec<3>> &scan)

Replace the scan points (useful for real hardware or offline playback).

Parameters

ParameterDescription
scan (in)Scan points in the sensor frame (same convention as getScan()).
cpp
void setScan(const std::vector<raisim::Vec<3>, AlignedAllocator<raisim::Vec<3>, 32>> &scan)

Replace the scan points (useful for real hardware or offline playback).

Parameters

ParameterDescription
scan (in)Scan points in the sensor frame (same convention as getScan()).

applyNoise ​

cpp
void applyNoise()

Apply one scan's range/angle noise, quantization and dropout in place. Called by CPU and Rayrai GPU captures. setScan() itself preserves manual/hardware data without adding noise. Draws follow hit order; different CPU/GPU hit sets can reassign later samples.

resetNoise ​

cpp
void resetNoise() noexcept

Restart the stream from the sensor seed, identity, owner id and World environment seed.

getTimeStamp ​

cpp
double getTimeStamp() const

Returns Timestamp of the latest scan in seconds (world time of the last update).

setTimeStamp ​

cpp
void setTimeStamp(double timeStamp)

Set the timestamp for the latest scan.

Parameters

ParameterDescription
timeStamp (in)Timestamp in seconds.

getCurrentYaw ​

cpp
double getCurrentYaw() const

Returns Current yaw angle of the spinning head in radians, in [0, 2*pi).

advanceSweep ​

cpp
Sweep advanceSweep(double worldTime)

Advance the spinning head to worldTime, as update() does before casting. Sets the current yaw, the scan timestamp and the update timestamp. Use it to cast the swept rays with another ray tracer (for example rayrai's GPU LiDAR) and store the hits with setScan(). The first update after the sensor is created or loaded, or after the world time went back before the last update, sweeps the time since world time 0, at most one update interval.

Parameters

ParameterDescription
worldTime (in)world time of this update (s)

Returns the yaw columns swept since the last update (count 0 if no column was crossed)

update ​

cpp
void update(class World &world) final

update lidar measurement: refreshes the pose, advances the head yaw by the time elapsed since the last update (advanceSweep()) and casts the swept rays. The body the sensor is attached to is excluded from the ray test.

Parameters

ParameterDescription
world (in)the world that the sensor is in

Static member functions ​

getType static ​

cpp
static Type getType()

Returns Sensor::Type::SPINNING_LIDAR.

Inherited members ​

From raisim::Sensor: getArticulatedSystem, getFrameId, getFrameOrientation, getFramePosition, getFullName, getMeasurementSource, getName, getOrientation, getOriInSensorFrame, getPosInSensorFrame, getPosition, getSensorSetModel, getSerialNumber, getUpdateRate, getUpdateTimeStamp, isUpdateDue, lock, lockMutex, MeasurementSource, serializeMeasurements, setAttachmentFrame, setMeasurementSource, setSerialNumber, setUpdateRate, setUpdateTimeStamp, try_lock, Type, unlock, unlockMutex, updatePose

RaiSim — physics for robotics and AI.