Use global coordinates for computing the frame position of a primitive geom fitted to a mesh.
PiperOrigin-RevId: 500720200 Change-Id: I0a564aff1fe6943002db14f46f789cfdaef4d2de
This commit is contained in:
committed by
Copybara-Service
parent
f19d5d2f28
commit
19b6c70e13
@@ -4,9 +4,21 @@ Changelog
|
|||||||
|
|
||||||
Upcoming version (not yet released)
|
Upcoming version (not yet released)
|
||||||
-----------------------------------
|
-----------------------------------
|
||||||
|
|
||||||
|
General
|
||||||
|
^^^^^^^
|
||||||
|
|
||||||
- The function :ref:`mj_name2id` is now implemented using a hash function instead of a linear search for better
|
- The function :ref:`mj_name2id` is now implemented using a hash function instead of a linear search for better
|
||||||
performance.
|
performance.
|
||||||
|
|
||||||
|
Bug fixes
|
||||||
|
^^^^^^^^^
|
||||||
|
|
||||||
|
- Fixed misalignment bug in mesh-to-primitive fitting when using the bounding box fitting option :at:`fitaabb`.
|
||||||
|
|
||||||
|
.. image:: images/changelog/aabb.png
|
||||||
|
:width: 300px
|
||||||
|
|
||||||
Version 2.3.1 (December 6, 2022)
|
Version 2.3.1 (December 6, 2022)
|
||||||
-----------------------------------
|
-----------------------------------
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 116 KiB |
+10
-13
@@ -334,6 +334,9 @@ double* mjCMesh::GetQuatPtr(mjtMeshType type) {
|
|||||||
void mjCMesh::FitGeom(mjCGeom* geom, double* meshpos) {
|
void mjCMesh::FitGeom(mjCGeom* geom, double* meshpos) {
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
// copy mesh pos into meshpos
|
||||||
|
mjuu_copyvec(meshpos, GetPosPtr(geom->typeinertia), 3);
|
||||||
|
|
||||||
// use inertial box
|
// use inertial box
|
||||||
if (!model->fitaabb) {
|
if (!model->fitaabb) {
|
||||||
// get inertia box type (shell or volume)
|
// get inertia box type (shell or volume)
|
||||||
@@ -363,9 +366,6 @@ void mjCMesh::FitGeom(mjCGeom* geom, double* meshpos) {
|
|||||||
default:
|
default:
|
||||||
throw mjCError(this, "invalid geom type in fitting mesh %s", name.c_str());
|
throw mjCError(this, "invalid geom type in fitting mesh %s", name.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
// copy mesh pos into meshpos
|
|
||||||
mjuu_copyvec(meshpos, GetPosPtr(geom->typeinertia), 3);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// use AABB
|
// use AABB
|
||||||
@@ -385,13 +385,10 @@ void mjCMesh::FitGeom(mjCGeom* geom, double* meshpos) {
|
|||||||
// find AABB box center
|
// find AABB box center
|
||||||
double cen[3] = {(AABB[0]+AABB[3])/2, (AABB[1]+AABB[4])/2, (AABB[2]+AABB[5])/2};
|
double cen[3] = {(AABB[0]+AABB[3])/2, (AABB[1]+AABB[4])/2, (AABB[2]+AABB[5])/2};
|
||||||
|
|
||||||
// copy box center into meshpos
|
// add box center into meshpos
|
||||||
mjuu_copyvec(meshpos, cen, 3);
|
meshpos[0] += cen[0];
|
||||||
|
meshpos[1] += cen[1];
|
||||||
// get AABB box half-sizes
|
meshpos[2] += cen[2];
|
||||||
double sz0 = AABB[3] - cen[0];
|
|
||||||
double sz1 = AABB[4] - cen[1];
|
|
||||||
double sz2 = AABB[5] - cen[2];
|
|
||||||
|
|
||||||
// compute depending on type
|
// compute depending on type
|
||||||
switch (geom->type) {
|
switch (geom->type) {
|
||||||
@@ -440,9 +437,9 @@ void mjCMesh::FitGeom(mjCGeom* geom, double* meshpos) {
|
|||||||
|
|
||||||
case mjGEOM_ELLIPSOID:
|
case mjGEOM_ELLIPSOID:
|
||||||
case mjGEOM_BOX:
|
case mjGEOM_BOX:
|
||||||
geom->size[0] = sz0;
|
geom->size[0] = AABB[3] - cen[0];
|
||||||
geom->size[1] = sz1;
|
geom->size[1] = AABB[4] - cen[1];
|
||||||
geom->size[2] = sz2;
|
geom->size[2] = AABB[5] - cen[2];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|||||||
Vendored
+40
@@ -0,0 +1,40 @@
|
|||||||
|
<mujoco>
|
||||||
|
<compiler fitaabb="true"/>
|
||||||
|
<asset>
|
||||||
|
<mesh file="stanford_bunny.obj"/>
|
||||||
|
</asset>
|
||||||
|
<worldbody>
|
||||||
|
<body euler="90 0 0">
|
||||||
|
<geom type="mesh" mesh="stanford_bunny"/>
|
||||||
|
</body>
|
||||||
|
<body euler="90 0 0" pos=".25 0 0">
|
||||||
|
<geom type="mesh" mesh="stanford_bunny"/>
|
||||||
|
</body>
|
||||||
|
<body euler="90 0 0" pos=".5 0 0">
|
||||||
|
<geom type="mesh" mesh="stanford_bunny"/>
|
||||||
|
</body>
|
||||||
|
<body euler="90 0 0" pos=".75 0 0">
|
||||||
|
<geom type="mesh" mesh="stanford_bunny"/>
|
||||||
|
</body>
|
||||||
|
<body euler="90 0 0" pos="1 0 0">
|
||||||
|
<geom type="mesh" mesh="stanford_bunny"/>
|
||||||
|
</body>
|
||||||
|
<body euler="90 0 0">
|
||||||
|
<geom name="bunny_sphere" type="sphere" mesh="stanford_bunny"/>
|
||||||
|
</body>
|
||||||
|
<body euler="90 0 0" pos=".25 0 0">
|
||||||
|
<geom name="bunny_capsule" type="capsule" mesh="stanford_bunny"/>
|
||||||
|
</body>
|
||||||
|
<body euler="90 0 0" pos=".5 0 0">
|
||||||
|
<geom name="bunny_ellipsoid" type="ellipsoid" mesh="stanford_bunny"/>
|
||||||
|
</body>
|
||||||
|
<body euler="90 0 0" pos=".75 0 0">
|
||||||
|
<geom name="bunny_cylinder" type="cylinder" mesh="stanford_bunny"/>
|
||||||
|
</body>
|
||||||
|
<body euler="90 0 0" pos="1 0 0">
|
||||||
|
<geom name="bunny_box" type="box" mesh="stanford_bunny"/>
|
||||||
|
</body>
|
||||||
|
<light name="left" pos="0 0 1"/>
|
||||||
|
<light name="right" pos="1 0 1"/>
|
||||||
|
</worldbody>
|
||||||
|
</mujoco>
|
||||||
+40
@@ -0,0 +1,40 @@
|
|||||||
|
<mujoco>
|
||||||
|
<compiler fitaabb="false"/>
|
||||||
|
<asset>
|
||||||
|
<mesh file="stanford_bunny.obj"/>
|
||||||
|
</asset>
|
||||||
|
<worldbody>
|
||||||
|
<body euler="90 0 0">
|
||||||
|
<geom type="mesh" mesh="stanford_bunny"/>
|
||||||
|
</body>
|
||||||
|
<body euler="90 0 0" pos=".25 0 0">
|
||||||
|
<geom type="mesh" mesh="stanford_bunny"/>
|
||||||
|
</body>
|
||||||
|
<body euler="90 0 0" pos=".5 0 0">
|
||||||
|
<geom type="mesh" mesh="stanford_bunny"/>
|
||||||
|
</body>
|
||||||
|
<body euler="90 0 0" pos=".75 0 0">
|
||||||
|
<geom type="mesh" mesh="stanford_bunny"/>
|
||||||
|
</body>
|
||||||
|
<body euler="90 0 0" pos="1 0 0">
|
||||||
|
<geom type="mesh" mesh="stanford_bunny"/>
|
||||||
|
</body>
|
||||||
|
<body euler="90 0 0">
|
||||||
|
<geom name="bunny_sphere" type="sphere" mesh="stanford_bunny"/>
|
||||||
|
</body>
|
||||||
|
<body euler="90 0 0" pos=".25 0 0">
|
||||||
|
<geom name="bunny_capsule" type="capsule" mesh="stanford_bunny"/>
|
||||||
|
</body>
|
||||||
|
<body euler="90 0 0" pos=".5 0 0">
|
||||||
|
<geom name="bunny_ellipsoid" type="ellipsoid" mesh="stanford_bunny"/>
|
||||||
|
</body>
|
||||||
|
<body euler="90 0 0" pos=".75 0 0">
|
||||||
|
<geom name="bunny_cylinder" type="cylinder" mesh="stanford_bunny"/>
|
||||||
|
</body>
|
||||||
|
<body euler="90 0 0" pos="1 0 0">
|
||||||
|
<geom name="bunny_box" type="box" mesh="stanford_bunny"/>
|
||||||
|
</body>
|
||||||
|
<light name="left" pos="0 0 1"/>
|
||||||
|
<light name="right" pos="1 0 1"/>
|
||||||
|
</worldbody>
|
||||||
|
</mujoco>
|
||||||
+7474
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user