Remove the use of plugin_state from PID plugin.
The plugin was storing a boolean to indicate whether the previous ctrl value was set in `act`. Use d->time == 0 instead. PiperOrigin-RevId: 585692686 Change-Id: I95335cebdb5716bd6fad81f463a4f248406c80ec
This commit is contained in:
committed by
Copybara-Service
parent
35c90844ae
commit
6412c95a37
@@ -50,6 +50,4 @@ The available options are:
|
||||
: : : :
|
||||
: : :If a bigger change is requested between two timesteps, it will be clipped to the range `[ctrl - slewmax * dt, ctrl + slewmax * dt]` :
|
||||
: : : :
|
||||
: : :If specified, one activation variable will be added to `mjData.act` containing the previous value of `ctrl`. One state variable will :
|
||||
: : :be added to `mjData.plugin_state`, to indicate whether the previous value of `ctrl` should be used (0 on first step, 1 :
|
||||
: : :otherwise). :
|
||||
: : :If specified, one activation variable will be added to `mjData.act` containing the previous value of `ctrl`. :
|
||||
|
||||
@@ -128,9 +128,6 @@ std::unique_ptr<Pid> Pid::Create(const mjModel* m, int instance) {
|
||||
void Pid::Reset(mjtNum* plugin_state) {
|
||||
integral_ = 0.0;
|
||||
previous_ctrl_ = 0.0;
|
||||
if (config_.slew_max.has_value()) {
|
||||
plugin_state[0] = false; // previous_ctrl_exists
|
||||
}
|
||||
}
|
||||
|
||||
mjtNum Pid::GetCtrl(const mjModel* m, const mjData* d, const State& state,
|
||||
@@ -208,15 +205,11 @@ void Pid::Compute(const mjModel* m, mjData* d, int instance) {
|
||||
}
|
||||
|
||||
void Pid::Advance(const mjModel* m, mjData* d, int instance) const {
|
||||
if (config_.slew_max.has_value()) {
|
||||
// previous_ctrl_exists = true
|
||||
d->plugin_state[m->plugin_stateadr[instance]] = true;
|
||||
}
|
||||
// act variables already updated by MuJoCo integrating act_dot
|
||||
}
|
||||
|
||||
int Pid::StateSize(const mjModel* m, int instance) {
|
||||
return HasSlew(m, instance) ? 1 : 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Pid::ActDim(const mjModel* m, int instance, int actuator_id) {
|
||||
@@ -232,7 +225,7 @@ Pid::State Pid::GetState(const mjModel* m, mjData* d, int instance) const {
|
||||
}
|
||||
if (config_.slew_max.has_value()) {
|
||||
state.previous_ctrl = d->act[state_idx++];
|
||||
state.previous_ctrl_exists = d->plugin_state[m->plugin_stateadr[instance]];
|
||||
state.previous_ctrl_exists = d->time > 0;
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user