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
structSpinningLidarProperties — Configuration of a SpinningLidar.structSweep — Yaw columns swept by one update.
Constructors & destructor
SpinningLidar
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
| Parameter | Description |
|---|---|
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
server::BoundedWriter serializeProp(server::BoundedWriter data) const finalUsed by the server. Do not use it if you don't know what it does. It serializes the sensor properties
Parameters
| Parameter | Description |
|---|---|
data (in) | where the property is written; throws server::SerializationError if it does not fit |
Returns where the next data should be written
getProperties
const SpinningLidarProperties &getProperties() constReturns The lidar configuration properties.
setProperties
void setProperties(const SpinningLidarProperties &prop)Replace the lidar configuration, clear the scan and reset the scan timestamp to 0.
Parameters
| Parameter | Description |
|---|---|
prop (in) | New properties. name and full_name must match the current ones (fatal error otherwise). |
getScan
const std::vector<raisim::Vec<3>, AlignedAllocator<raisim::Vec<3>, 32>> &getScan() constReturns 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
void setScan(const std::vector<raisim::Vec<3>> &scan)Replace the scan points (useful for real hardware or offline playback).
Parameters
| Parameter | Description |
|---|---|
scan (in) | Scan points in the sensor frame (same convention as getScan()). |
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
| Parameter | Description |
|---|---|
scan (in) | Scan points in the sensor frame (same convention as getScan()). |
applyNoise
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
void resetNoise() noexceptRestart the stream from the sensor seed, identity, owner id and World environment seed.
getTimeStamp
double getTimeStamp() constReturns Timestamp of the latest scan in seconds (world time of the last update).
setTimeStamp
void setTimeStamp(double timeStamp)Set the timestamp for the latest scan.
Parameters
| Parameter | Description |
|---|---|
timeStamp (in) | Timestamp in seconds. |
getCurrentYaw
double getCurrentYaw() constReturns Current yaw angle of the spinning head in radians, in [0, 2*pi).
advanceSweep
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
| Parameter | Description |
|---|---|
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
void update(class World &world) finalupdate 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
| Parameter | Description |
|---|---|
world (in) | the world that the sensor is in |
Static member functions
getType static
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