Move tactile sensor to the engine.

PiperOrigin-RevId: 788863133
Change-Id: I3172ebb7641fa8146469da25cba7db794760e7b1
This commit is contained in:
Alessio Quaglino
2025-07-30 05:26:39 -07:00
committed by Copybara-Service
parent 89f4789085
commit 51babec9c5
28 changed files with 418 additions and 687 deletions
+5
View File
@@ -1166,6 +1166,11 @@ int mjs_sensorDim(const mjsSensor* sensor) {
case mjSENS_CONTACT:
return sensor->intprm[2] * mju_condataSize(sensor->intprm[0]);
case mjSENS_TACTILE:
return 3 * static_cast<const mjCMesh*>(
static_cast<mjCSensor*>(sensor->element)->get_obj())
->nvert();
case mjSENS_USER:
return sensor->dim;
+24 -2
View File
@@ -6720,9 +6720,12 @@ void mjCSensor::ResolveReferences(const mjCModel* m) {
throw mjCError(this, "unrecognized name '%s' of sensorized object", objname_.c_str());
}
// if geom mark it as non visual
// if geom or mesh, mark it as non visual
if (objtype == mjOBJ_GEOM) {
((mjCGeom*)obj)->SetNotVisual();
static_cast<mjCGeom*>(obj)->SetNotVisual();
}
if (objtype == mjOBJ_MESH) {
static_cast<mjCMesh*>(obj)->SetNotVisual();
}
} else if (type != mjSENS_E_POTENTIAL &&
@@ -6746,6 +6749,14 @@ void mjCSensor::ResolveReferences(const mjCModel* m) {
throw mjCError(this, "unrecognized name '%s' of object", refname_.c_str());
}
// if geom or mesh, mark it as non visual
if (reftype == mjOBJ_GEOM) {
static_cast<mjCGeom*>(ref)->SetNotVisual();
}
if (reftype == mjOBJ_MESH) {
static_cast<mjCMesh*>(ref)->SetNotVisual();
}
// must be attached to object with spatial frame
if (reftype != mjOBJ_BODY && reftype != mjOBJ_XBODY &&
reftype != mjOBJ_GEOM && reftype != mjOBJ_SITE && reftype != mjOBJ_CAMERA) {
@@ -7147,6 +7158,17 @@ void mjCSensor::Compile(void) {
}
break;
case mjSENS_TACTILE:
needstage = mjSTAGE_ACC;
datatype = mjDATATYPE_REAL;
if (objtype != mjOBJ_MESH) {
throw mjCError(this, "sensor must be associated with a mesh");
}
if (reftype != mjOBJ_GEOM) {
throw mjCError(this, "sensor must be associated with a geom");
}
break;
case mjSENS_PLUGIN:
datatype = mjDATATYPE_REAL; // no noise added to plugin sensors, this attribute is unused
+3
View File
@@ -1799,6 +1799,9 @@ class mjCSensor : public mjCSensor_, private mjsSensor {
const std::string& get_objname() { return spec_objname_; }
const std::string& get_refname() { return spec_refname_; }
const mjCBase* get_obj() { return obj; }
const mjCBase* get_ref() { return ref; }
private:
void Compile(void); // compiler
void CopyFromSpec();