You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am a researcher at Institute for Artificial Intelligence, University of Bremen, I use MuJoCo for my research.
My setup
MuJoCo: 3.2.7
API: C
OS: Ubuntu 20.04 / 24.04
What's happening? What did you expect?
I'm trying to implement a custom plugin for my use case, using the sensor plugin as a starting point. While working with touch_grid.xml, I noticed something unexpected:
In the XML, there is only one sensor attached to the site named "touch". However, during debugging, I observed the following behavior with the lambda function plugin.nsensordata:
It's called twice.
In the first call, the values are always:
m->sensor_objid[sensor_id] = 0
m->sensor_objtype[sensor_id] = mjOBJ_UNKNOWN
In the second call, the values are correct:
m->sensor_objid[sensor_id] and m->sensor_objtype[sensor_id] have the expected values.
Upon further investigation, I found that:
The first call determines sensor_size and the second call determines m->nsensordata to satisfy the constraint mentioned in engine_io.c.
This behavior creates a challenge for my use case because:
My sensor size depends on m->sensor_objid[sensor_id] and m->sensor_objtype[sensor_id].
This causes the constraint to be violated.
Questions:
How can I address this issue and ensure my sensor size is calculated correctly without violating the constraint?
I also noticed that the constructor for the sensor is called twice. Is this redundant, or is it expected behavior?
Any insights or suggestions would be greatly appreciated. Thank you!
const int obj_id = m->sensor_objid[sensor_id];
const char *obj_name = mj_id2name(m, mjtObj::mjOBJ_SITE, obj_id);
const int obj_type = m->sensor_objtype[sensor_id];
printf("Object id: %d\n", obj_id);
printf("Object name: %s\n", obj_name);
if (obj_type == mjOBJ_SITE)
{
printf("Object is of type mjOBJ_SITE\n");
}
else if (obj_type == mjOBJ_UNKNOWN)
{
printf("Object is of type mjOBJ_UNKNOWN\n");
}
else
{
printf("Object is of type %d\n", obj_type);
}
Build it and simulate touch_grid.xml or the below XML (with a dummy site).
The output would be:
Object id: 0
Object name: dummy
Object is of type mjOBJ_UNKNOWN
Object id: 1
Object name: touch
Object is of type mjOBJ_SITE
Intro
Hi!
I am a researcher at Institute for Artificial Intelligence, University of Bremen, I use MuJoCo for my research.
My setup
MuJoCo: 3.2.7
API: C
OS: Ubuntu 20.04 / 24.04
What's happening? What did you expect?
I'm trying to implement a custom plugin for my use case, using the sensor plugin as a starting point. While working with touch_grid.xml, I noticed something unexpected:
In the XML, there is only one sensor attached to the site named
"touch"
. However, during debugging, I observed the following behavior with the lambda function plugin.nsensordata:m->sensor_objid[sensor_id] = 0
m->sensor_objtype[sensor_id] = mjOBJ_UNKNOWN
m->sensor_objid[sensor_id]
andm->sensor_objtype[sensor_id]
have the expected values.Upon further investigation, I found that:
sensor_size
and the second call determinesm->nsensordata
to satisfy the constraint mentioned in engine_io.c.This behavior creates a challenge for my use case because:
m->sensor_objid[sensor_id]
andm->sensor_objtype[sensor_id]
.Questions:
Any insights or suggestions would be greatly appreciated. Thank you!
Steps for reproduction
Build it and simulate touch_grid.xml or the below XML (with a dummy site).
The output would be:
Minimal model for reproduction
Code required for reproduction
No response
Confirmations
The text was updated successfully, but these errors were encountered: