Modify signature of plugin reset callback.
The `reset` function is called inside `mj_resetData`, before any physics forwarding call has been made. It is therefore an error to read anything from mjData at this stage. The only valid operation on mjData during `reset` is for a plugin to write into its own state variable slots and data struct. We modify the function signature to only provide access to these. PiperOrigin-RevId: 495032492 Change-Id: Ic6d2967d2571a9083cbca1ba239ca70a8a51f474
This commit is contained in:
committed by
Copybara-Service
parent
2e6af64b31
commit
5c021d042b
@@ -224,8 +224,9 @@ int RegisterSensorPlugin() {
|
||||
TestSensor::DestroyCount()++;
|
||||
};
|
||||
|
||||
plugin.reset = +[](const mjModel* m, mjData* d, int instance) {
|
||||
auto sensor = reinterpret_cast<TestSensor*>(d->plugin_data[instance]);
|
||||
plugin.reset = +[](const mjModel* m, double* plugin_state, void* plugin_data,
|
||||
int instance) {
|
||||
auto sensor = reinterpret_cast<TestSensor*>(plugin_data);
|
||||
sensor->Reset();
|
||||
};
|
||||
plugin.compute = +[](const mjModel* m, mjData* d, int instance, int type) {
|
||||
@@ -266,8 +267,9 @@ int RegisterActuatorPlugin() {
|
||||
TestActuator::DestroyCount()++;
|
||||
};
|
||||
|
||||
plugin.reset = +[](const mjModel* m, mjData* d, int instance) {
|
||||
auto actuator = reinterpret_cast<TestActuator*>(d->plugin_data[instance]);
|
||||
plugin.reset = +[](const mjModel* m, double* plugin_state, void* plugin_data,
|
||||
int instance) {
|
||||
auto actuator = reinterpret_cast<TestActuator*>(plugin_data);
|
||||
actuator->Reset();
|
||||
};
|
||||
plugin.compute = +[](const mjModel* m, mjData* d, int instance, int type) {
|
||||
@@ -306,8 +308,9 @@ int RegisterPassivePlugin() {
|
||||
d->plugin_data[instance] = 0;
|
||||
};
|
||||
|
||||
plugin.reset = +[](const mjModel* m, mjData* d, int instance) {
|
||||
auto passive = reinterpret_cast<TestPassive*>(d->plugin_data[instance]);
|
||||
plugin.reset = +[](const mjModel* m, double* plugin_state, void* plugin_data,
|
||||
int instance) {
|
||||
auto passive = reinterpret_cast<TestPassive*>(plugin_data);
|
||||
passive->Reset();
|
||||
};
|
||||
plugin.compute = +[](const mjModel* m, mjData* d, int instance, int type) {
|
||||
|
||||
Reference in New Issue
Block a user