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
+8
View File
@@ -407,6 +407,14 @@ typedef enum mjtFlexSelf_ { // mode for flex selfcollide
} 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;
//---------------------------------- mjLROpt -------------------------------------------------------
struct mjLROpt_ { // options for mj_setLengthRange()
+10
View File
@@ -135,6 +135,16 @@ struct mjpPlugin_ {
};
typedef struct mjpPlugin_ mjpPlugin;
struct mjSDF_ {
const mjpPlugin** plugin;
int* id;
mjtSDFType type;
mjtNum* relpos;
mjtNum* relmat;
mjtGeom* geomtype;
};
typedef struct mjSDF_ mjSDF;
#if defined(__has_attribute)
#if __has_attribute(constructor)
+13
View File
@@ -1308,6 +1308,19 @@ MJAPI char* mju_strncpy(char *dst, const char *src, int n);
MJAPI mjtNum mju_sigmoid(mjtNum x);
//---------------------------------- Signed Distance Function --------------------------------------
// get sdf from geom id
MJAPI const mjpPlugin* mjc_getSDF(const mjModel* m, int id);
// signed distance function
MJAPI mjtNum mjc_distance(const mjModel* m, const mjData* d, const mjSDF* s, const mjtNum x[3]);
// gradient of sdf
MJAPI void mjc_gradient(const mjModel* m, const mjData* d, const mjSDF* s, mjtNum gradient[3],
const mjtNum x[3]);
//---------------------------------- Derivatives ---------------------------------------------------
// Finite differenced transition matrices (control theory notation)