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
+15
View File
@@ -2160,6 +2160,7 @@ static int sensorSize(mjtSensor sensor_type, int sensor_dim) {
return 4;
case mjSENS_CONTACT:
case mjSENS_TACTILE:
case mjSENS_USER:
return sensor_dim;
@@ -2588,6 +2589,20 @@ const char* mj_validateReferences(const mjModel* m) {
if (nobj != -1 && (m->sensor_refid[i] < -1 || m->sensor_refid[i] >= nobj)) {
return "Invalid model: invalid sensor_refid";
}
if (sensor_type == mjSENS_TACTILE) {
int obj_id = m->sensor_objid[i];
int parent_body = m->geom_bodyid[obj_id];
int collision_geoms = 0;
for (int b = 0; b < m->body_geomnum[parent_body]; ++b) {
int geom_id = m->body_geomadr[parent_body]+b;
if (m->geom_contype[geom_id] || m->geom_conaffinity[geom_id]) {
collision_geoms++;
}
}
if (collision_geoms == 0) {
return "Touch sensor requires a body with at least one collision geom";
}
}
}
for (int i=0; i < m->nexclude; i++) {
int exclude_body1 = (m->exclude_signature[i] & 0xFFFF);