raisim::NormalCamera
final class · #include <raisim/sensors/NormalSensor.hpp>
Inherits: raisim::Sensor
Surface-normal camera: the unit normal of the surface seen in each pixel (ground truth).
The image holds width * height * 3 floats, row-major (index = (row * width + col) * 3 + axis), row 0 at the top. Each normal is a unit vector facing the camera (flipped if the surface faces away), expressed in the world frame (Frame::WORLD, the default) or in the OpenCV optical frame of the camera (Frame::CAMERA: x right, y down, z forward; a surface facing the camera has a negative z). Pixels that see nothing within [clipNear, clipFar] hold (0, 0, 0).
Sensor frame convention: +x is the optical axis, +y points left and +z up, as for DepthCamera.
Measurement sources: with MANUAL (the default) a renderer writes the image (rayrai renders the interpolated vertex normals of the visual meshes). With RAISIM, update() ray-casts the collision geometry of the world (the owning body excluded) and stores the geometric normals of the collision shapes (face normals of meshes). The TCP viewer does not render this camera.
With a positive latency or latencyJitter, captures reach getNormalArray() after the delay (see the Sensor class comment): writers fill getCaptureNormalArray() and call commitCapture(). The jitter stream derives from the sensor identity, owner id and World environment seed.
Nested classes
structNormalCameraProperties — Configuration of a NormalCamera. Change it with setProperties().
Public types
Frame
enum class Frame : intFrame the normals are expressed in.
| Enumerator | Value | Description |
|---|---|---|
WORLD | 0 | World frame. |
CAMERA | 1 | OpenCV optical frame of the camera (x right, y down, z forward). |
Constructors & destructor
NormalCamera
NormalCamera(
const NormalCameraProperties &prop,
class ArticulatedSystem *as,
const Vec<3> &pos,
const Mat<3, 3> &rot)Create a normal camera with a zero image. The measurement source is MANUAL.
Parameters
| Parameter | Description |
|---|---|
prop (in) | Camera 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 NormalCameraProperties &getProperties() constReturns The camera properties.
setProperties
void setProperties(const NormalCameraProperties &prop)Replace the camera properties transactionally. Invalid properties leave the camera unchanged. The image is reallocated and zeroed.
Parameters
| Parameter | Description |
|---|---|
prop (in) | New properties. name and full_name must match the current ones (fatal error otherwise). |
getNormalArray
const std::vector<float> &getNormalArray() constNormal image, width * height * 3 floats (see the class comment).
Returns The image.
std::vector<float> &getNormalArray()Mutable access for MANUAL measurements (renderers); keep its size.
Returns The image.
setNormalArray
void setNormalArray(const std::vector<float> &normals)Replace the delivered image directly, without latency. Fatal error unless it has width * height * 3 values.
Parameters
| Parameter | Description |
|---|---|
normals (in) | New image. |
getCaptureNormalArray
std::vector<float> &getCaptureNormalArray()Image that receives the next capture (same size and layout as getNormalArray()). It is the delivered image itself without latency (zero copy) and a staging image otherwise; fill it and call commitCapture().
Returns Writable capture image.
commitCapture
void commitCapture(double acquisitionTime)Commit the capture written into getCaptureNormalArray() as acquired at the given world time: acknowledges the sample like setUpdateTimeStamp() and, with a latency, queues the capture for delivery (see the Sensor class comment). Without latency it is delivered at once.
Parameters
| Parameter | Description |
|---|---|
acquisitionTime (in) | World time of the capture (s); must be finite with a latency. |
getDeliveryTimeStamp
double getDeliveryTimeStamp() constReturns World time at which the delivered capture was delivered (its acquisition time without latency); negative before the first.
getDroppedCaptureCount
uint64_t getDroppedCaptureCount() constReturns Captures dropped because the latency queue was full, since the properties last changed.
getPendingCaptureCount
size_t getPendingCaptureCount() constReturns Captures waiting for delivery.
resetNoise
void resetNoise() noexceptRestart the latency-jitter stream from the sensor identity, owner id and World environment seed.
update
void update(class World &world) finalRay-cast the image: refreshes the sensor pose from its attachment frame, then casts one ray per pixel against the collision bodies of world, ignoring the owning body. Called by RaiSim when the measurement source is RAISIM. A rolling shutter is a fatal error.
Parameters
| Parameter | Description |
|---|---|
world (in) | the world that the sensor is in |
getRayDirections
const CameraRayDirections &getRayDirections() constReturns Ray directions in the sensor frame, one per pixel (see computeCameraRayDirections()). setProperties() and World::restoreCheckpoint() replace the table.
Static member functions
getType static
static Type getType()Returns Sensor::Type::NORMAL.
Inherited members
From raisim::Sensor: capturesDelayed, getAcquisitionTimeStamp, 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