Add clock sensor type.
PiperOrigin-RevId: 459720950 Change-Id: Ibda48ae7dc4aa7be451a947a1c53d10a7eaf176b
This commit is contained in:
committed by
Copybara-Service
parent
d3a86bb748
commit
c14a7ef4a7
@@ -113,17 +113,18 @@ static void apply_cutoff(const mjModel* m, mjData* d, mjtStage stage) {
|
||||
mjtNum cutoff = m->sensor_cutoff[i];
|
||||
|
||||
// process all dimensions
|
||||
for (int j=0; j<dim; j++)
|
||||
for (int j=0; j<dim; j++) {
|
||||
|
||||
// real: apply on both sides
|
||||
if (m->sensor_datatype[i]==mjDATATYPE_REAL)
|
||||
d->sensordata[adr+j] =
|
||||
mju_min(cutoff, mju_max(-cutoff, d->sensordata[adr+j]));
|
||||
if (m->sensor_datatype[i]==mjDATATYPE_REAL) {
|
||||
d->sensordata[adr+j] = mju_clip(d->sensordata[adr+j], -cutoff, cutoff);
|
||||
}
|
||||
|
||||
// positive: apply on positive side only
|
||||
else if (m->sensor_datatype[i]==mjDATATYPE_POSITIVE)
|
||||
d->sensordata[adr+j] =
|
||||
mju_min(cutoff, d->sensordata[adr+j]);
|
||||
else if (m->sensor_datatype[i]==mjDATATYPE_POSITIVE) {
|
||||
d->sensordata[adr+j] = mju_min(cutoff, d->sensordata[adr+j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -312,6 +313,10 @@ void mj_sensorPos(const mjModel* m, mjData* d) {
|
||||
mju_copy3(d->sensordata+adr, d->subtree_com+3*objid);
|
||||
break;
|
||||
|
||||
case mjSENS_CLOCK: // clock
|
||||
d->sensordata[adr] = d->time;
|
||||
break;
|
||||
|
||||
case mjSENS_USER: // user
|
||||
nusersensor++;
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user