Skip to content

Commit b8a4ac5

Browse files
yuvaltassacopybara-github
authored andcommitted
Refactor camera orthographic attribute to projection enum.
PiperOrigin-RevId: 847069028 Change-Id: I7f686fe654e9b56519cab8bd2f37c9cc40091d3f
1 parent 44c8ef8 commit b8a4ac5

File tree

20 files changed

+102
-44
lines changed

20 files changed

+102
-44
lines changed

doc/APIreference/APItypes.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,16 @@ elements. These values are used in ``m->geom_type`` and ``m->site_type``.
166166
.. mujoco-include:: mjtGeom
167167

168168

169+
.. _mjtProjection:
170+
171+
mjtProjection
172+
~~~~~~~~~~~~~
173+
174+
Type of camera projection. Used in ``m->cam_projection``.
175+
176+
.. mujoco-include:: mjtProjection
177+
178+
169179
.. _mjtCamLight:
170180

171181
mjtCamLight

doc/XMLreference.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2961,11 +2961,11 @@ and the +Y axis points up. Thus the frame position and orientation are the key a
29612961
When the camera mode is "targetbody" or "targetbodycom", this attribute becomes required. It specifies which body
29622962
should be targeted by the camera. In all other modes this attribute is ignored.
29632963

2964-
.. _body-camera-orthographic:
2964+
.. _body-camera-projection:
29652965

2966-
:at:`orthographic`: :at-val:`[false, true], "false"`
2967-
Whether the camera uses a perspective projection (the default) or an orthographic projection. Setting this attribute
2968-
changes the semantic of the :ref:`fovy<body-camera-fovy>` attribute, see below.
2966+
:at:`projection`: :at-val:`[perspective, orthographic], "perspective"`
2967+
Whether the camera uses a perspective (the default) or orthographic projection. Setting this
2968+
attribute to "orthographic" changes the semantic of the :ref:`fovy<body-camera-fovy>` attribute, see below.
29692969

29702970
.. _body-camera-fovy:
29712971

@@ -8666,7 +8666,7 @@ if omitted.
86668666
| This element sets the attributes of the dummy :ref:`site <body-site>` element of the defaults class.
86678667
| All site attributes are available here except: name, class.
86688668
8669-
.. _default-camera-orthographic:
8669+
.. _default-camera-projection:
86708670

86718671
.. _default-camera-fovy:
86728672

doc/XMLschema.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@
302302
| :ref:`camera | \* | :class: mjcf-attributes |
303303
| <body-camera>` | | |
304304
| | | +-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+ |
305-
| | | | :ref:`name<body-camera-name>` | :ref:`class<body-camera-class>` | :ref:`orthographic<body-camera-orthographic>` | :ref:`fovy<body-camera-fovy>` | |
305+
| | | | :ref:`name<body-camera-name>` | :ref:`class<body-camera-class>` | :ref:`projection<body-camera-projection>` | :ref:`fovy<body-camera-fovy>` | |
306306
| | | +-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+ |
307307
| | | | :ref:`ipd<body-camera-ipd>` | :ref:`resolution<body-camera-resolution>` | :ref:`pos<body-camera-pos>` | :ref:`quat<body-camera-quat>` | |
308308
| | | +-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+ |
@@ -1490,7 +1490,7 @@
14901490
| :ref:`camera | ? | :class: mjcf-attributes |
14911491
| <default-camera>` | | |
14921492
| | | +-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+ |
1493-
| | | | :ref:`orthographic<default-camera-orthographic>` | :ref:`fovy<default-camera-fovy>` | :ref:`ipd<default-camera-ipd>` | :ref:`resolution<default-camera-resolution>` | |
1493+
| | | | :ref:`projection<default-camera-projection>` | :ref:`fovy<default-camera-fovy>` | :ref:`ipd<default-camera-ipd>` | :ref:`resolution<default-camera-resolution>` | |
14941494
| | | +-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+ |
14951495
| | | | :ref:`pos<default-camera-pos>` | :ref:`quat<default-camera-quat>` | :ref:`axisangle<default-camera-axisangle>` | :ref:`xyaxes<default-camera-xyaxes>` | |
14961496
| | | +-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+ |

doc/changelog.rst

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,17 @@ Changelog
55
Upcoming version (not yet released)
66
-----------------------------------
77

8+
.. admonition:: Breaking API changes
9+
:class: attention
10+
11+
- The ``mjModel.cam_orthographic`` field has been renamed to ``cam_projection``, with the semantic of a new enum type
12+
:ref:`mjtProjection`. This will allow for more projection types in the future like fisheye cameras.
13+
Relatedly, the ``camera/orthographic`` MJCF attribute for cameras has been renamed to
14+
:ref:`camera/projection<body-camera-projection>` and now accepts the values ``orthographic`` and ``perspective``.
15+
16+
**Migration:** Replace ``orthographic = "false/true"`` with ``projection="perspective/orthographic"``,
17+
respectively.
18+
819
General
920
^^^^^^^
1021
- Non-breaking ABI changes:
@@ -793,7 +804,7 @@ General
793804
:width: 240px
794805

795806
8. Added support for orthographic cameras. This is available for both fixed cameras and the free camera, using the
796-
:ref:`camera/orthographic<body-camera-orthographic>` and :ref:`global/orthographic<visual-global-orthographic>`
807+
``camera/orthographic`` and :ref:`global/orthographic<visual-global-orthographic>`
797808
attributes, respectively.
798809
9. Added :ref:`maxhullvert<asset-mesh-maxhullvert>`, the maximum number of vertices in a mesh's convex hull.
799810
10. Added :ref:`mj_setKeyframe` for saving the current state into a model keyframe.

doc/includes/references.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -538,6 +538,10 @@ typedef enum mjtGeom_ { // type of geometric shape
538538

539539
mjGEOM_NONE = 1001 // missing geom type
540540
} mjtGeom;
541+
typedef enum mjtProjection_ { // type of camera projection
542+
mjPROJ_PERSPECTIVE = 0, // perspective
543+
mjPROJ_ORTHOGRAPHIC // orthographic
544+
} mjtProjection;
541545
typedef enum mjtCamLight_ { // tracking mode for camera and light
542546
mjCAMLIGHT_FIXED = 0, // pos and rot fixed in body
543547
mjCAMLIGHT_TRACK, // pos tracks body, rot fixed in global
@@ -1223,7 +1227,7 @@ struct mjModel_ {
12231227
mjtNum* cam_poscom0; // global position rel. to sub-com in qpos0 (ncam x 3)
12241228
mjtNum* cam_pos0; // global position rel. to body in qpos0 (ncam x 3)
12251229
mjtNum* cam_mat0; // global orientation in qpos0 (ncam x 9)
1226-
int* cam_orthographic; // orthographic camera; 0: no, 1: yes (ncam x 1)
1230+
int* cam_projection; // projection type (mjtProjection) (ncam x 1)
12271231
mjtNum* cam_fovy; // y field-of-view (ortho ? len : deg) (ncam x 1)
12281232
mjtNum* cam_ipd; // inter-pupilary distance (ncam x 1)
12291233
int* cam_resolution; // resolution: pixels [width, height] (ncam x 2)
@@ -2102,7 +2106,7 @@ typedef struct mjsCamera_ { // camera specification
21022106
mjString* targetbody; // target body for tracking/targeting
21032107

21042108
// intrinsics
2105-
int orthographic; // is camera orthographic
2109+
mjtProjection proj; // camera projection type
21062110
double fovy; // y-field of view
21072111
double ipd; // inter-pupilary distance
21082112
float intrinsic[4]; // camera intrinsics (length)

include/mujoco/mjmodel.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,12 @@ typedef enum mjtGeom_ { // type of geometric shape
124124
} mjtGeom;
125125

126126

127+
typedef enum mjtProjection_ { // type of camera projection
128+
mjPROJ_PERSPECTIVE = 0, // perspective
129+
mjPROJ_ORTHOGRAPHIC // orthographic
130+
} mjtProjection;
131+
132+
127133
typedef enum mjtCamLight_ { // tracking mode for camera and light
128134
mjCAMLIGHT_FIXED = 0, // pos and rot fixed in body
129135
mjCAMLIGHT_TRACK, // pos tracks body, rot fixed in global
@@ -882,7 +888,7 @@ struct mjModel_ {
882888
mjtNum* cam_poscom0; // global position rel. to sub-com in qpos0 (ncam x 3)
883889
mjtNum* cam_pos0; // global position rel. to body in qpos0 (ncam x 3)
884890
mjtNum* cam_mat0; // global orientation in qpos0 (ncam x 9)
885-
int* cam_orthographic; // orthographic camera; 0: no, 1: yes (ncam x 1)
891+
int* cam_projection; // projection type (mjtProjection) (ncam x 1)
886892
mjtNum* cam_fovy; // y field-of-view (ortho ? len : deg) (ncam x 1)
887893
mjtNum* cam_ipd; // inter-pupilary distance (ncam x 1)
888894
int* cam_resolution; // resolution: pixels [width, height] (ncam x 2)

include/mujoco/mjspec.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ typedef struct mjsCamera_ { // camera specification
373373
mjString* targetbody; // target body for tracking/targeting
374374

375375
// intrinsics
376-
int orthographic; // is camera orthographic
376+
mjtProjection proj; // camera projection type
377377
double fovy; // y-field of view
378378
double ipd; // inter-pupilary distance
379379
float intrinsic[4]; // camera intrinsics (length)

include/mujoco/mjxmacro.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@
302302
X ( mjtNum, cam_poscom0, ncam, 3 ) \
303303
X ( mjtNum, cam_pos0, ncam, 3 ) \
304304
X ( mjtNum, cam_mat0, ncam, 9 ) \
305-
X ( int, cam_orthographic, ncam, 1 ) \
305+
X ( int, cam_projection, ncam, 1 ) \
306306
X ( mjtNum, cam_fovy, ncam, 1 ) \
307307
X ( mjtNum, cam_ipd, ncam, 1 ) \
308308
X ( int, cam_resolution, ncam, 2 ) \

python/mujoco/introspect/enums.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,15 @@
101101
('mjGEOM_NONE', 1001),
102102
]),
103103
)),
104+
('mjtProjection',
105+
EnumDecl(
106+
name='mjtProjection',
107+
declname='enum mjtProjection_',
108+
values=dict([
109+
('mjPROJ_PERSPECTIVE', 0),
110+
('mjPROJ_ORTHOGRAPHIC', 1),
111+
]),
112+
)),
104113
('mjtCamLight',
105114
EnumDecl(
106115
name='mjtCamLight',

python/mujoco/introspect/structs.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2244,11 +2244,11 @@
22442244
array_extent=('ncam', 9),
22452245
),
22462246
StructFieldDecl(
2247-
name='cam_orthographic',
2247+
name='cam_projection',
22482248
type=PointerType(
22492249
inner_type=ValueType(name='int'),
22502250
),
2251-
doc='orthographic camera; 0: no, 1: yes',
2251+
doc='projection type (mjtProjection)',
22522252
array_extent=('ncam',),
22532253
),
22542254
StructFieldDecl(
@@ -7566,9 +7566,9 @@
75667566
doc='target body for tracking/targeting',
75677567
),
75687568
StructFieldDecl(
7569-
name='orthographic',
7570-
type=ValueType(name='int'),
7571-
doc='is camera orthographic',
7569+
name='proj',
7570+
type=ValueType(name='mjtProjection'),
7571+
doc='camera projection type',
75727572
),
75737573
StructFieldDecl(
75747574
name='fovy',

0 commit comments

Comments
 (0)