Add output attribute to camera elements.

This attribute allows specifying the intended output types (e.g., RGB, depth, normal) for each camera in the XML. The output types are stored as bit flags in `mjModel`.

PiperOrigin-RevId: 853316261
Change-Id: I1ad2e94102593cf402756f8f4c80509371ca86d2
This commit is contained in:
Yuval Tassa
2026-01-07 10:19:35 -08:00
committed by Copybara-Service
parent 3c93d6b979
commit 608115ab95
18 changed files with 233 additions and 27 deletions
+16
View File
@@ -2988,6 +2988,20 @@ and the +Y axis points up. Thus the frame position and orientation are the key a
location to save the required resolution. Setting either value larger than 1
enables frustum visualization when the :ref:`mjVIS_CAMERA<mjtVisFlag>` visualization flag is active.
.. _body-camera-output:
:at:`output`: :at-val:`[rgb, depth, distance, normal, segmentation], "rgb"`
Types of output images supported by the camera.
- :at-val:`rgb`: RGB image.
- :at-val:`depth`: Depth image (distance from camera plane).
- :at-val:`distance`: Distance image (distance from camera origin).
- :at-val:`normal`: Surface normal image.
- :at-val:`segmentation`: Segmentation image.
This attribute is not used for rendering, but serves as a convenient location to save the output types supported by
the camera. The :at:`output` attribute can contain multiple types, e.g. :at-val:`"rgb normal"`.
.. _body-camera-sensorsize:
:at:`sensorsize`: :at-val:`real(2), "0 0"`
@@ -8715,6 +8729,8 @@ if omitted.
.. _default-camera-resolution:
.. _default-camera-output:
.. _default-camera-ipd:
.. _default-camera-pos:
+6
View File
@@ -1045,6 +1045,9 @@
.. grid-item::
:ref:`resolution<body-camera-resolution>`
.. grid-item::
:ref:`output<body-camera-output>`
.. grid-item::
:ref:`pos<body-camera-pos>`
@@ -4705,6 +4708,9 @@
.. grid-item::
:ref:`resolution<default-camera-resolution>`
.. grid-item::
:ref:`output<default-camera-output>`
.. grid-item::
:ref:`pos<default-camera-pos>`
+2
View File
@@ -30,6 +30,8 @@ General
attribute. In this case, the sensor will cast multiple ray, one for each pixel.
- Rangefinder sensors can now now report various kinds of information besides ray distances, including surface normals.
See :ref:`rangefinder<sensor-rangefinder>` for details.
- Cameras now have an :ref:`output<body-camera-output>` attribute, parsed into the ``mjModel.cam_output`` bitfield.
Unused by the renderer, it serves as a convenient location to store a camera's supported output types.
- Non-breaking ABI changes:
- The type of the ``sig`` (signature) argument of :ref:`mj_stateSize` and related functions has been changed from
+11
View File
@@ -786,6 +786,15 @@ typedef enum mjtRayDataField_ { // data fields returned by rangefinder sensors
mjNRAYDATA // number of rangefinder sensor data fields
} mjtRayDataField;
typedef enum mjtCamOutBit_ { // camera output type bitflags
mjCAMOUT_RGB = 1<<0, // RGB image
mjCAMOUT_DEPTH = 1<<1, // depth image (distance from camera plane)
mjCAMOUT_DIST = 1<<2, // distance image (distance from camera origin)
mjCAMOUT_NORMAL = 1<<3, // normal image
mjCAMOUT_SEG = 1<<4, // segmentation image
mjNCAMOUT = 5 // number of camera output types
} mjtCamOutBit;
typedef enum mjtSameFrame_ { // frame alignment of bodies with their children
mjSAMEFRAME_NONE = 0, // no alignment
mjSAMEFRAME_BODY, // frame is same as body frame
@@ -1240,6 +1249,7 @@ struct mjModel_ {
mjtNum* cam_fovy; // y field-of-view (ortho ? len : deg) (ncam x 1)
mjtNum* cam_ipd; // inter-pupilary distance (ncam x 1)
int* cam_resolution; // resolution: pixels [width, height] (ncam x 2)
int* cam_output; // output types (mjtCamOut bit flags) (ncam x 1)
float* cam_sensorsize; // sensor size: length [width, height] (ncam x 2)
float* cam_intrinsic; // [focal length; principal point] (ncam x 4)
mjtNum* cam_user; // user data (ncam x nuser_cam)
@@ -2117,6 +2127,7 @@ typedef struct mjsCamera_ { // camera specification
// intrinsics
mjtProjection proj; // camera projection type
int resolution[2]; // resolution (pixel)
int output; // bit flags for output type
double fovy; // y-field of view
double ipd; // inter-pupillary distance
float intrinsic[4]; // camera intrinsics (length)