Skip to content

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 ​

Public types ​

Frame ​

cpp
enum class Frame : int

Frame the normals are expressed in.

EnumeratorValueDescription
WORLD0World frame.
CAMERA1OpenCV optical frame of the camera (x right, y down, z forward).

Constructors & destructor ​

NormalCamera ​

cpp
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

ParameterDescription
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 ​

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 NormalCameraProperties &getProperties() const

Returns The camera properties.

setProperties ​

cpp
void setProperties(const NormalCameraProperties &prop)

Replace the camera properties transactionally. Invalid properties leave the camera unchanged. The image is reallocated and zeroed.

Parameters

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

getNormalArray ​

cpp
const std::vector<float> &getNormalArray() const

Normal image, width * height * 3 floats (see the class comment).

Returns The image.

cpp
std::vector<float> &getNormalArray()

Mutable access for MANUAL measurements (renderers); keep its size.

Returns The image.

setNormalArray ​

cpp
void setNormalArray(const std::vector<float> &normals)

Replace the delivered image directly, without latency. Fatal error unless it has width * height * 3 values.

Parameters

ParameterDescription
normals (in)New image.

getCaptureNormalArray ​

cpp
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 ​

cpp
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

ParameterDescription
acquisitionTime (in)World time of the capture (s); must be finite with a latency.

getDeliveryTimeStamp ​

cpp
double getDeliveryTimeStamp() const

Returns World time at which the delivered capture was delivered (its acquisition time without latency); negative before the first.

getDroppedCaptureCount ​

cpp
uint64_t getDroppedCaptureCount() const

Returns Captures dropped because the latency queue was full, since the properties last changed.

getPendingCaptureCount ​

cpp
size_t getPendingCaptureCount() const

Returns Captures waiting for delivery.

resetNoise ​

cpp
void resetNoise() noexcept

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

update ​

cpp
void update(class World &world) final

Ray-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

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

getRayDirections ​

cpp
const CameraRayDirections &getRayDirections() const

Returns Ray directions in the sensor frame, one per pixel (see computeCameraRayDirections()). setProperties() and World::restoreCheckpoint() replace the table.

Static member functions ​

getType static ​

cpp
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

RaiSim — physics for robotics and AI.