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
+12
View File
@@ -416,6 +416,17 @@ typedef enum mjtRayDataField_ { // data fields returned by rangefinder sensors
} 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
@@ -903,6 +914,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)
+1
View File
@@ -375,6 +375,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)
+1
View File
@@ -306,6 +306,7 @@
X ( mjtNum, cam_fovy, ncam, 1 ) \
X ( mjtNum, cam_ipd, ncam, 1 ) \
X ( int, cam_resolution, ncam, 2 ) \
X ( int, cam_output, ncam, 1 ) \
X ( float, cam_sensorsize, ncam, 2 ) \
X ( float, cam_intrinsic, ncam, 4 ) \
X ( mjtNum, cam_user, ncam, MJ_M(nuser_cam) )