Skip to content

raisim::RGBCamera ​

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

Inherits: raisim::Sensor

Color camera sensor. RaiSim stores the camera configuration and an image buffer but does not render images itself: the buffer must be written by user code or an in-process renderer (e.g. rayrai's Camera::getRawImage()), so the measurement source must stay MANUAL.

Nested classes ​

Constructors & destructor ​

RGBCamera ​

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

Create an RGB camera and allocate its width * height * 4 byte image buffer. 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 RGBCameraProperties &getProperties() const

Return immutable camera properties.

Returns camera properties

setProperties ​

cpp
void setProperties(const RGBCameraProperties &prop)

Replace camera properties transactionally and resize the dependent image buffer. Invalid properties leave the camera unchanged. The image contents are reset to zero.

Parameters

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

getImageBuffer ​

cpp
const std::vector<char> &getImageBuffer() const

Image buffer of width * height * 4 bytes (4 bytes per pixel, rows contiguous). RaiSim does not synthesize RGB images or interpret the channel order; user code or an in-process renderer must write this buffer manually. rayrai's Camera::getRawImage() writes BGRA.

Returns The image data in char vector

cpp
std::vector<char> &getImageBuffer()

Mutable access to the image buffer (same layout as the const overload); use it to write MANUAL measurements in place. Keep its size at width * height * 4 bytes.

Returns The image data in char vector

setImageBuffer ​

cpp
void setImageBuffer(const std::vector<char> &rgbaIn)

Replace the image buffer. Useful on the real robot or for renderer output.

Parameters

ParameterDescription
rgbaIn (in)4-byte-per-pixel image of exactly width * height * 4 bytes (fatal error otherwise), in the same layout as getImageBuffer()

applyNoise ​

cpp
void applyNoise()

Apply one simulated exposure's noise in place. Alpha is preserved. Manual setters do not add noise; Rayrai capture and the RaiSim server call this after writing a clean image.

cpp
void applyNoise(char *image, size_t size)

Apply noise to a custom four-channel image with exactly width * height * 4 bytes.

Parameters

ParameterDescription
image (in, out)RGBA or BGRA image in top-left row order.
size (in)Image size in bytes.
cpp
void applyNoise(char *image, size_t size, bool topLeftOrigin)

Apply the same exposure to top-left (true) or bottom-left (false) row storage. The seed always assigns noise to physical pixels in top-left image order.

resetNoise ​

cpp
void resetNoise() noexcept

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

update ​

cpp
void update(class World &world) final

Always a fatal error: RaiSim cannot produce RGB measurements (use MeasurementSource::MANUAL).

Parameters

ParameterDescription
world (in)unused

Static member functions ​

getType static ​

cpp
static Type getType()

Returns Sensor::Type::RGB.

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.