Add mjmModel opaque pointer to C API.

PiperOrigin-RevId: 607619891
Change-Id: Ic1eaaa842438d9c2e19f742deff41967287853f5
This commit is contained in:
Alessio Quaglino
2024-02-16 02:20:29 -08:00
committed by Copybara-Service
parent f9f7827a64
commit 5e353efaaf
9 changed files with 124 additions and 113 deletions
+44 -44
View File
@@ -24,16 +24,16 @@
// create model
void* mjm_createModel() {
mjmModel* mjm_createModel() {
mjCModel* modelC = new mjCModel();
return modelC;
return &modelC->spec;
}
// delete model
void mjm_deleteModel(void* modelspec) {
mjCModel* model = static_cast<mjCModel*>(modelspec);
void mjm_deleteModel(mjmModel* modelspec) {
mjCModel* model = reinterpret_cast<mjCModel*>(modelspec->element);
delete model;
}
@@ -116,8 +116,8 @@ mjmLight* mjm_addLight(mjmBody* bodyspec, mjmDefault* defspec) {
// add flex to model
mjmFlex* mjm_addFlex(void* model) {
mjCModel* modelC = static_cast<mjCModel*>(model);
mjmFlex* mjm_addFlex(mjmModel* model) {
mjCModel* modelC = reinterpret_cast<mjCModel*>(model->element);
mjCFlex* flex = modelC->AddFlex();
return &flex->spec;
}
@@ -138,9 +138,9 @@ mjmFrame* mjm_addFrame(mjmBody* bodyspec, mjmFrame* parentframe) {
// add mesh to model
mjmMesh* mjm_addMesh(void* model, mjmDefault* defspec) {
mjmMesh* mjm_addMesh(mjmModel* model, mjmDefault* defspec) {
mjCDef* def = defspec ? reinterpret_cast<mjCDef*>(defspec->element) : 0;
mjCModel* modelC = static_cast<mjCModel*>(model);
mjCModel* modelC = reinterpret_cast<mjCModel*>(model->element);
mjCMesh* mesh = modelC->AddMesh(def);
return &mesh->spec;
}
@@ -148,8 +148,8 @@ mjmMesh* mjm_addMesh(void* model, mjmDefault* defspec) {
// add height field to model
mjmHField* mjm_addHField(void* model) {
mjCModel* modelC = static_cast<mjCModel*>(model);
mjmHField* mjm_addHField(mjmModel* model) {
mjCModel* modelC = reinterpret_cast<mjCModel*>(model->element);
mjCHField* heightField = modelC->AddHField();
return &heightField->spec;
}
@@ -157,8 +157,8 @@ mjmHField* mjm_addHField(void* model) {
// add skin to model
mjmSkin* mjm_addSkin(void* model) {
mjCModel* modelC = static_cast<mjCModel*>(model);
mjmSkin* mjm_addSkin(mjmModel* model) {
mjCModel* modelC = reinterpret_cast<mjCModel*>(model->element);
mjCSkin* skin = modelC->AddSkin();
return &skin->spec;
}
@@ -166,8 +166,8 @@ mjmSkin* mjm_addSkin(void* model) {
// add texture to model
mjmTexture* mjm_addTexture(void* model) {
mjCModel* modelC = static_cast<mjCModel*>(model);
mjmTexture* mjm_addTexture(mjmModel* model) {
mjCModel* modelC = reinterpret_cast<mjCModel*>(model->element);
mjCTexture* texture = modelC->AddTexture();
return &texture->spec;
}
@@ -175,8 +175,8 @@ mjmTexture* mjm_addTexture(void* model) {
// add material to model
mjmMaterial* mjm_addMaterial(void* model, mjmDefault* defspec) {
mjCModel* modelC = static_cast<mjCModel*>(model);
mjmMaterial* mjm_addMaterial(mjmModel* model, mjmDefault* defspec) {
mjCModel* modelC = reinterpret_cast<mjCModel*>(model->element);
mjCDef* def = defspec ? reinterpret_cast<mjCDef*>(defspec->element) : 0;
mjCMaterial* material = modelC->AddMaterial(def);
return &material->spec;
@@ -185,8 +185,8 @@ mjmMaterial* mjm_addMaterial(void* model, mjmDefault* defspec) {
// add pair to model
mjmPair* mjm_addPair(void* model, mjmDefault* defspec) {
mjCModel* modelC = static_cast<mjCModel*>(model);
mjmPair* mjm_addPair(mjmModel* model, mjmDefault* defspec) {
mjCModel* modelC = reinterpret_cast<mjCModel*>(model->element);
mjCDef* def = defspec ? reinterpret_cast<mjCDef*>(defspec->element) : 0;
mjCPair* pair = modelC->AddPair(def);
return &pair->spec;
@@ -195,8 +195,8 @@ mjmPair* mjm_addPair(void* model, mjmDefault* defspec) {
// add pair exclusion to model
mjmExclude* mjm_addExclude(void* model) {
mjCModel* modelC = static_cast<mjCModel*>(model);
mjmExclude* mjm_addExclude(mjmModel* model) {
mjCModel* modelC = reinterpret_cast<mjCModel*>(model->element);
mjCBodyPair* bodypair = modelC->AddExclude();
return &bodypair->spec;
}
@@ -204,8 +204,8 @@ mjmExclude* mjm_addExclude(void* model) {
// add equality to model
mjmEquality* mjm_addEquality(void* model, mjmDefault* defspec) {
mjCModel* modelC = static_cast<mjCModel*>(model);
mjmEquality* mjm_addEquality(mjmModel* model, mjmDefault* defspec) {
mjCModel* modelC = reinterpret_cast<mjCModel*>(model->element);
mjCDef* def = defspec ? reinterpret_cast<mjCDef*>(defspec->element) : 0;
mjCEquality* equality = modelC->AddEquality(def);
return &equality->spec;
@@ -214,8 +214,8 @@ mjmEquality* mjm_addEquality(void* model, mjmDefault* defspec) {
// add tendon to model
mjmTendon* mjm_addTendon(void* model, mjmDefault* defspec) {
mjCModel* modelC = static_cast<mjCModel*>(model);
mjmTendon* mjm_addTendon(mjmModel* model, mjmDefault* defspec) {
mjCModel* modelC = reinterpret_cast<mjCModel*>(model->element);
mjCDef* def = defspec ? reinterpret_cast<mjCDef*>(defspec->element) : 0;
mjCTendon* tendon = modelC->AddTendon(def);
return &tendon->spec;
@@ -260,8 +260,8 @@ mjmWrap* mjm_wrapPulley(mjmTendon* tendonspec, double divisor) {
// add actuator to model
mjmActuator* mjm_addActuator(void* model, mjmDefault* defspec) {
mjCModel* modelC = static_cast<mjCModel*>(model);
mjmActuator* mjm_addActuator(mjmModel* model, mjmDefault* defspec) {
mjCModel* modelC = reinterpret_cast<mjCModel*>(model->element);
mjCDef* def = defspec ? reinterpret_cast<mjCDef*>(defspec->element) : 0;
mjCActuator* actuator = modelC->AddActuator(def);
return &actuator->spec;
@@ -270,8 +270,8 @@ mjmActuator* mjm_addActuator(void* model, mjmDefault* defspec) {
// add sensor to model
mjmSensor* mjm_addSensor(void* model) {
mjCModel* modelC = static_cast<mjCModel*>(model);
mjmSensor* mjm_addSensor(mjmModel* model) {
mjCModel* modelC = reinterpret_cast<mjCModel*>(model->element);
mjCSensor* sensor = modelC->AddSensor();
return &sensor->spec;
}
@@ -279,8 +279,8 @@ mjmSensor* mjm_addSensor(void* model) {
// add numeric to model
mjmNumeric* mjm_addNumeric(void* model) {
mjCModel* modelC = static_cast<mjCModel*>(model);
mjmNumeric* mjm_addNumeric(mjmModel* model) {
mjCModel* modelC = reinterpret_cast<mjCModel*>(model->element);
mjCNumeric* numeric = modelC->AddNumeric();
return &numeric->spec;
}
@@ -288,8 +288,8 @@ mjmNumeric* mjm_addNumeric(void* model) {
// add text to model
mjmText* mjm_addText(void* model) {
mjCModel* modelC = static_cast<mjCModel*>(model);
mjmText* mjm_addText(mjmModel* model) {
mjCModel* modelC = reinterpret_cast<mjCModel*>(model->element);
mjCText* text = modelC->AddText();
return &text->spec;
}
@@ -297,8 +297,8 @@ mjmText* mjm_addText(void* model) {
// add tuple to model
mjmTuple* mjm_addTuple(void* model) {
mjCModel* modelC = static_cast<mjCModel*>(model);
mjmTuple* mjm_addTuple(mjmModel* model) {
mjCModel* modelC = reinterpret_cast<mjCModel*>(model->element);
mjCTuple* tuple = modelC->AddTuple();
return &tuple->spec;
}
@@ -306,8 +306,8 @@ mjmTuple* mjm_addTuple(void* model) {
// add keyframe to model
mjmKey* mjm_addKey(void* model) {
mjCModel* modelC = static_cast<mjCModel*>(model);
mjmKey* mjm_addKey(mjmModel* model) {
mjCModel* modelC = reinterpret_cast<mjCModel*>(model->element);
mjCKey* key = modelC->AddKey();
return &key->spec;
}
@@ -315,8 +315,8 @@ mjmKey* mjm_addKey(void* model) {
// add plugin to model
mjElement mjm_addPlugin(void* model) {
mjCModel* modelC = static_cast<mjCModel*>(model);
mjElement mjm_addPlugin(mjmModel* model) {
mjCModel* modelC = reinterpret_cast<mjCModel*>(model->element);
mjCPlugin* plugin = modelC->AddPlugin();
return (mjElement)plugin;
}
@@ -324,8 +324,8 @@ mjElement mjm_addPlugin(void* model) {
// add default to model
mjmDefault* mjm_addDefault(void* model, const char* classname, int parentid) {
mjCModel* modelC = static_cast<mjCModel*>(model);
mjmDefault* mjm_addDefault(mjmModel* model, const char* classname, int parentid) {
mjCModel* modelC = reinterpret_cast<mjCModel*>(model->element);
mjCDef* def = modelC->AddDef(classname, parentid);
if (def) {
return &def->spec;
@@ -337,8 +337,8 @@ mjmDefault* mjm_addDefault(void* model, const char* classname, int parentid) {
// get objects
void* mjm_getModel(mjmBody* bodyspec) {
return reinterpret_cast<mjCBody*>(bodyspec->element)->model;
mjmModel* mjm_getModel(mjmBody* bodyspec) {
return &(reinterpret_cast<mjCBody*>(bodyspec->element)->model->spec);
}
@@ -351,8 +351,8 @@ mjmDefault* mjm_getDefault(mjElement element) {
// find body in model by name
mjmBody* mjm_findBody(void* modelspec, const char* name) {
mjCModel* model = static_cast<mjCModel*>(modelspec);
mjmBody* mjm_findBody(mjmModel* modelspec, const char* name) {
mjCModel* model = reinterpret_cast<mjCModel*>(modelspec->element);
mjCBase* body = model->FindObject(mjOBJ_BODY, std::string(name));
if (!body) {
return 0;
+26 -22
View File
@@ -71,6 +71,10 @@ typedef enum _mjtLimited { // type of limit specification
//---------------------------------- attribute structs (mjm) ---------------------------------------
typedef struct _mjmModel { // model specification
mjElement element; // internal, do not modify
} mjmModel;
typedef struct _mjmOrientation { // alternative orientation specifiers
double axisangle[4]; // rotation axis and angle
double xyaxes[6]; // x and y axes
@@ -662,10 +666,10 @@ typedef struct _mjmDefault { // default specification
//---------------------------------- API functions -------------------------------------------------
// Create model.
MJAPI void* mjm_createModel();
MJAPI mjmModel* mjm_createModel();
// Delete model.
MJAPI void mjm_deleteModel(void* modelspec);
MJAPI void mjm_deleteModel(mjmModel* modelspec);
// Copy spec into private attributes.
MJAPI void mjm_finalize(mjElement object);
@@ -695,34 +699,34 @@ MJAPI mjmLight* mjm_addLight(mjmBody* body, mjmDefault* def);
MJAPI mjmFrame* mjm_addFrame(mjmBody* body, mjmFrame* parentframe);
// Add flex to model.
MJAPI mjmFlex* mjm_addFlex(void* model);
MJAPI mjmFlex* mjm_addFlex(mjmModel* model);
// Add mesh to model.
MJAPI mjmMesh* mjm_addMesh(void* model, mjmDefault* def);
MJAPI mjmMesh* mjm_addMesh(mjmModel* model, mjmDefault* def);
// Add height field to model.
MJAPI mjmHField* mjm_addHField(void* model);
MJAPI mjmHField* mjm_addHField(mjmModel* model);
// Add skin to model.
MJAPI mjmSkin* mjm_addSkin(void* model);
MJAPI mjmSkin* mjm_addSkin(mjmModel* model);
// Add texture to model.
MJAPI mjmTexture* mjm_addTexture(void* model);
MJAPI mjmTexture* mjm_addTexture(mjmModel* model);
// Add material to model.
MJAPI mjmMaterial* mjm_addMaterial(void* model, mjmDefault* def);
MJAPI mjmMaterial* mjm_addMaterial(mjmModel* model, mjmDefault* def);
// Add pair to model.
MJAPI mjmPair* mjm_addPair(void* model, mjmDefault* def);
MJAPI mjmPair* mjm_addPair(mjmModel* model, mjmDefault* def);
// Add excluded body pair to model.
MJAPI mjmExclude* mjm_addExclude(void *model);
MJAPI mjmExclude* mjm_addExclude(mjmModel *model);
// Add equality to model.
MJAPI mjmEquality* mjm_addEquality(void* model, mjmDefault* def);
MJAPI mjmEquality* mjm_addEquality(mjmModel* model, mjmDefault* def);
// Add tendon to model.
MJAPI mjmTendon* mjm_addTendon(void* model, mjmDefault* def);
MJAPI mjmTendon* mjm_addTendon(mjmModel* model, mjmDefault* def);
// Wrap site using tendon.
MJAPI mjmWrap* mjm_wrapSite(mjmTendon* tendon, const char* name);
@@ -737,37 +741,37 @@ MJAPI mjmWrap* mjm_wrapJoint(mjmTendon* tendon, const char* name, double coef);
MJAPI mjmWrap* mjm_wrapPulley(mjmTendon* tendon, double divisor);
// Add actuator to model.
MJAPI mjmActuator* mjm_addActuator(void* model, mjmDefault* def);
MJAPI mjmActuator* mjm_addActuator(mjmModel* model, mjmDefault* def);
// Add sensor to model.
MJAPI mjmSensor* mjm_addSensor(void* model);
MJAPI mjmSensor* mjm_addSensor(mjmModel* model);
// Add numeric to model.
MJAPI mjmNumeric* mjm_addNumeric(void* model);
MJAPI mjmNumeric* mjm_addNumeric(mjmModel* model);
// Add text to model.
MJAPI mjmText* mjm_addText(void* model);
MJAPI mjmText* mjm_addText(mjmModel* model);
// Add tuple to model.
MJAPI mjmTuple* mjm_addTuple(void* model);
MJAPI mjmTuple* mjm_addTuple(mjmModel* model);
// Add keyframe to model.
MJAPI mjmKey* mjm_addKey(void* model);
MJAPI mjmKey* mjm_addKey(mjmModel* model);
// Add plugin to model.
MJAPI mjElement mjm_addPlugin(void* model);
MJAPI mjElement mjm_addPlugin(mjmModel* model);
// Add default to model.
MJAPI mjmDefault* mjm_addDefault(void* model, const char* classname, int parentid);
MJAPI mjmDefault* mjm_addDefault(mjmModel* model, const char* classname, int parentid);
// Get model from body.
MJAPI void* mjm_getModel(mjmBody* body);
MJAPI mjmModel* mjm_getModel(mjmBody* body);
// Get default corresponding to an mjElement.
MJAPI mjmDefault* mjm_getDefault(mjElement element);
// Find body in model by name.
MJAPI mjmBody* mjm_findBody(void* modelspec, const char* name);
MJAPI mjmBody* mjm_findBody(mjmModel* modelspec, const char* name);
// Find child body by name.
MJAPI mjmBody* mjm_findChild(mjmBody* body, const char* name);
+16 -16
View File
@@ -551,7 +551,7 @@ bool mjCComposite::MakeParticle(mjCModel* model, mjmBody* body, char* error, int
mju::sprintf_arr(txt2, "%sS%d", prefix.c_str(), v1);
// create tendon
mjmTendon* ten = mjm_addTendon(model, &def[mjCOMPKIND_TENDON].spec);
mjmTendon* ten = mjm_addTendon(&model->spec, &def[mjCOMPKIND_TENDON].spec);
mjm_setDefault(ten->element, &model->defaults[0]->spec);
mjm_setString(ten->name, txt0);
ten->group = 4;
@@ -559,7 +559,7 @@ bool mjCComposite::MakeParticle(mjCModel* model, mjmBody* body, char* error, int
mjm_wrapSite(ten, txt2);
// add equality constraint
mjmEquality* eq = mjm_addEquality(model, &def[mjCOMPKIND_TENDON].spec);
mjmEquality* eq = mjm_addEquality(&model->spec, &def[mjCOMPKIND_TENDON].spec);
mjm_setDefault(eq->element, &model->defaults[0]->spec);
eq->type = mjEQ_TENDON;
mjm_setString(eq->name1, mjm_getString(ten->name));
@@ -673,7 +673,7 @@ bool mjCComposite::MakeGrid(mjCModel* model, mjmBody* body, char* error, int err
ten->WrapSite(txt2);
// add equality constraint
mjmEquality* eq = mjm_addEquality(model, &def[mjCOMPKIND_TENDON].spec);
mjmEquality* eq = mjm_addEquality(&model->spec, &def[mjCOMPKIND_TENDON].spec);
mjm_setDefault(eq->element, &model->defaults[0]->spec);
eq->type = mjEQ_TENDON;
mjm_setString(eq->name1, ten->name.c_str());
@@ -714,7 +714,7 @@ bool mjCComposite::MakeCable(mjCModel* model, mjmBody* body, char* error, int er
}
// add name to model
mjmText* pte = mjm_addText(model);
mjmText* pte = mjm_addText(&model->spec);
mjm_setString(pte->name, ("composite_" + prefix).c_str());
mjm_setString(pte->data, ("rope_" + prefix).c_str());
@@ -880,7 +880,7 @@ mjmBody* mjCComposite::AddCableBody(mjCModel* model, mjmBody* body, int ix, mjtN
// exclude contact pair
if (!last) {
mjmExclude* exclude = mjm_addExclude(model);
mjmExclude* exclude = mjm_addExclude(&model->spec);
mjm_setString(exclude->bodyname1, std::string(this_body).c_str());
mjm_setString(exclude->bodyname2, std::string(next_body).c_str());
}
@@ -944,7 +944,7 @@ bool mjCComposite::MakeRope(mjCModel* model, mjmBody* body, char* error, int err
char txt2[200];
// add equality constraint
mjmEquality* eq = mjm_addEquality(model, 0);
mjmEquality* eq = mjm_addEquality(&model->spec, 0);
eq->type = mjEQ_CONNECT;
mju::sprintf_arr(txt, "%sB0", prefix.c_str());
mju::sprintf_arr(txt2, "%sB%d", prefix.c_str(), count[0]-1);
@@ -955,7 +955,7 @@ bool mjCComposite::MakeRope(mjCModel* model, mjmBody* body, char* error, int err
mju_copy(eq->solimp, solimpsmooth, mjNIMP);
// remove contact between connected bodies
mjmExclude* pair = mjm_addExclude(model);
mjmExclude* pair = mjm_addExclude(&model->spec);
mjm_setString(pair->bodyname1, std::string(txt).c_str());
mjm_setString(pair->bodyname2, std::string(txt2).c_str());
}
@@ -1035,7 +1035,7 @@ mjmBody* mjCComposite::AddRopeBody(mjCModel* model, mjmBody* body, int ix, int i
mjuu_setvec(jnt->axis, 1, 0, 0);
// add constraint
mjmEquality* eq = mjm_addEquality(model, &def[mjCOMPKIND_TWIST].spec);
mjmEquality* eq = mjm_addEquality(&model->spec, &def[mjCOMPKIND_TWIST].spec);
mjm_setDefault(eq->element, &model->defaults[0]->spec);
eq->type = mjEQ_JOINT;
mjm_setString(eq->name1, mjm_getString(jnt->name));
@@ -1053,7 +1053,7 @@ mjmBody* mjCComposite::AddRopeBody(mjCModel* model, mjmBody* body, int ix, int i
mjuu_setvec(jnt->axis, 1, 0, 0);
// add constraint
mjmEquality* eq = mjm_addEquality(model, &def[mjCOMPKIND_STRETCH].spec);
mjmEquality* eq = mjm_addEquality(&model->spec, &def[mjCOMPKIND_STRETCH].spec);
mjm_setDefault(eq->element, &model->defaults[0]->spec);
eq->type = mjEQ_JOINT;
mjm_setString(eq->name1, mjm_getString(jnt->name));
@@ -1174,7 +1174,7 @@ bool mjCComposite::MakeBox(mjCModel* model, mjmBody* body, char* error, int erro
mjuu_setvec(jnt->axis, 0, 0, 1);
// add fix constraint
mjmEquality* eq = mjm_addEquality(model, &def[mjCOMPKIND_JOINT].spec);
mjmEquality* eq = mjm_addEquality(&model->spec, &def[mjCOMPKIND_JOINT].spec);
mjm_setDefault(eq->element, &model->defaults[0]->spec);
eq->type = mjEQ_JOINT;
mjm_setString(eq->name1, mjm_getString(jnt->name));
@@ -1194,7 +1194,7 @@ bool mjCComposite::MakeBox(mjCModel* model, mjmBody* body, char* error, int erro
char txt2[200];
mju::sprintf_arr(txt2,
"%sJ%d_%d_%d", prefix.c_str(), ix1, iy1, iz1);
mjmEquality* eqn = mjm_addEquality(model, 0);
mjmEquality* eqn = mjm_addEquality(&model->spec, 0);
mju_copy(eqn->solref, solrefsmooth, mjNREF);
mju_copy(eqn->solimp, solimpsmooth, mjNIMP);
eqn->type = mjEQ_JOINT;
@@ -1208,7 +1208,7 @@ bool mjCComposite::MakeBox(mjCModel* model, mjmBody* body, char* error, int erro
}
// finalize fixed tendon
mjmEquality* eqt = mjm_addEquality(model, &def[mjCOMPKIND_TENDON].spec);
mjmEquality* eqt = mjm_addEquality(&model->spec, &def[mjCOMPKIND_TENDON].spec);
mjm_setDefault(eqt->element, &model->defaults[0]->spec);
eqt->type = mjEQ_TENDON;
mjm_setString(eqt->name1, ten->name.c_str());
@@ -1244,7 +1244,7 @@ void mjCComposite::MakeShear(mjCModel* model) {
ten->name = txt;
// equality constraint
mjmEquality* eq = mjm_addEquality(model, &def[mjCOMPKIND_SHEAR].spec);
mjmEquality* eq = mjm_addEquality(&model->spec, &def[mjCOMPKIND_SHEAR].spec);
mjm_setDefault(eq->element, &model->defaults[0]->spec);
eq->type = mjEQ_TENDON;
mjm_setString(eq->name1, txt);
@@ -1286,7 +1286,7 @@ void mjCComposite::MakeSkin2(mjCModel* model, mjtNum inflate) {
int N = count[0]*count[1];
// add skin, set name and material
mjmSkin* skin = mjm_addSkin(model);
mjmSkin* skin = mjm_addSkin(&model->spec);
mju::sprintf_arr(txt, "%sSkin", prefix.c_str());
mjm_setString(skin->name, txt);
mjm_setString(skin->material, skinmaterial.c_str());
@@ -1879,7 +1879,7 @@ void mjCComposite::MakeSkin2Subgrid(mjCModel* model, mjtNum inflate) {
// add skin, set name and material
char txt[100];
mjmSkin* skin = mjm_addSkin(model);
mjmSkin* skin = mjm_addSkin(&model->spec);
mju::sprintf_arr(txt, "%sSkin", prefix.c_str());
mjm_setString(skin->name, txt);
mjm_setString(skin->material, skinmaterial.c_str());
@@ -2034,7 +2034,7 @@ void mjCComposite::MakeSkin3(mjCModel* model) {
mju::sprintf_arr(cnt2, "%d", count[2]-1);
// add skin, set name and material
mjmSkin* skin = mjm_addSkin(model);
mjmSkin* skin = mjm_addSkin(&model->spec);
mju::sprintf_arr(txt, "%sSkin", prefix.c_str());
mjm_setString(skin->name, txt);
mjm_setString(skin->material, skinmaterial.c_str());
+1 -1
View File
@@ -484,7 +484,7 @@ bool mjCFlexcomp::Make(mjCModel* model, mjmBody* body, char* error, int error_sz
// create edge equality constraint
if (equality) {
mjmEquality* pe = mjm_addEquality(model, &def.spec);
mjmEquality* pe = mjm_addEquality(&model->spec, &def.spec);
mjm_setDefault(pe->element, &model->defaults[0]->spec);
pe->type = mjEQ_FLEX;
pe->active = true;
+5
View File
@@ -41,6 +41,7 @@
#include "engine/engine_util_blas.h"
#include "engine/engine_util_errmem.h"
#include "engine/engine_util_misc.h"
#include "user/user_api.h"
#include "user/user_objects.h"
#include "user/user_util.h"
@@ -214,6 +215,10 @@ mjCModel::mjCModel() {
object_lists[mjOBJ_TUPLE] = (std::vector<mjCBase*>*) &tuples;
object_lists[mjOBJ_KEY] = (std::vector<mjCBase*>*) &keys;
object_lists[mjOBJ_PLUGIN] = (std::vector<mjCBase*>*) &plugins;
// point to model from spec
spec.element = (mjElement)this;
}
+2
View File
@@ -72,6 +72,8 @@ class mjCModel {
mjCModel(); // constructor
~mjCModel(); // destructor
mjmModel spec;
mjModel* Compile(const mjVFS* vfs = 0); // COMPILER: construct mjModel
bool CopyBack(const mjModel*); // DECOMPILER: copy numeric back
void FuseStatic(void); // fuse static bodies with parent