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:
Saran Tunyasuvunakool
2022-12-13 08:40:59 -08:00
committed by Copybara-Service
parent 2e6af64b31
commit 5c021d042b
4 changed files with 13 additions and 9 deletions
+1 -1
View File
@@ -52,7 +52,7 @@ struct mjpPlugin_ {
void (*copy)(mjData* dest, const mjModel* m, const mjData* src, int instance);
// called when an mjData is being reset (required)
void (*reset)(const mjModel* m, mjData* d, int instance);
void (*reset)(const mjModel* m, double* plugin_state, void* plugin_data, int instance);
// called when the plugin needs to update its outputs (required)
void (*compute)(const mjModel* m, mjData* d, int instance, int capability_bit);