Add SDF functions to public API.

PiperOrigin-RevId: 757829339
Change-Id: I81ee7c3f33acf234835bf34cbb632e23cb9e284e
This commit is contained in:
Alessio Quaglino
2025-05-12 10:52:41 -07:00
committed by Copybara-Service
parent d77126dc58
commit 8a7c42c747
10 changed files with 232 additions and 16 deletions
+20
View File
@@ -357,6 +357,26 @@ last argument to :ref:`mj_local2global`.
.. mujoco-include:: mjtSameFrame
.. _mjtFlexSelf:
mjtFlexSelf
~~~~~~~~~~~~
Types of flex self-collisions midphase.
.. mujoco-include:: mjtFlexSelf
.. _mjtSDFType:
mjtSDFType
~~~~~~~~~~~
Formulas used to combine SDFs when calling mjc_distance and mjc_gradient.
.. mujoco-include:: mjtSDFType
.. _tyDataEnums:
Data
+19
View File
@@ -766,6 +766,12 @@ typedef enum mjtFlexSelf_ { // mode for flex selfcollide
mjFLEXSELF_SAP, // use SAP in midphase
mjFLEXSELF_AUTO // choose between BVH and SAP automatically
} mjtFlexSelf;
typedef enum mjtSDFType_ { // signed distance function (SDF) type
mjSDFTYPE_SINGLE = 0, // single SDF
mjSDFTYPE_INTERSECTION, // max(A, B)
mjSDFTYPE_MIDSURFACE, // A - B
mjSDFTYPE_COLLISION, // A + B + abs(max(A, B))
} mjtSDFType;
struct mjLROpt_ { // options for mj_setLengthRange()
// flags
int mode; // which actuators to process (mjtLRMode)
@@ -1586,6 +1592,15 @@ struct mjpPlugin_ {
void (*sdf_aabb)(mjtNum aabb[6], const mjtNum* attributes);
};
typedef struct mjpPlugin_ mjpPlugin;
struct mjSDF_ {
const mjpPlugin** plugin;
int* id;
mjtSDFType type;
mjtNum* relpos;
mjtNum* relmat;
mjtGeom* geomtype;
};
typedef struct mjSDF_ mjSDF;
typedef enum mjtGridPos_ { // grid position for overlay
mjGRID_TOPLEFT = 0, // top left
mjGRID_TOPRIGHT, // top right
@@ -3637,6 +3652,10 @@ void mju_insertionSortInt(int* list, int n);
mjtNum mju_Halton(int index, int base);
char* mju_strncpy(char *dst, const char *src, int n);
mjtNum mju_sigmoid(mjtNum x);
const mjpPlugin* mjc_getSDF(const mjModel* m, int id);
mjtNum mjc_distance(const mjModel* m, const mjData* d, const mjSDF* s, const mjtNum x[3]);
void mjc_gradient(const mjModel* m, const mjData* d, const mjSDF* s, mjtNum gradient[3],
const mjtNum x[3]);
void mjd_transitionFD(const mjModel* m, mjData* d, mjtNum eps, mjtByte flg_centered,
mjtNum* A, mjtNum* B, mjtNum* C, mjtNum* D);
void mjd_inverseFD(const mjModel* m, mjData* d, mjtNum eps, mjtByte flg_actuation,