Skip to content

Conversation

@ilge
Copy link
Contributor

@ilge ilge commented Aug 14, 2020

A previous bug introduced a behavior that started the EMA value at 0.0 that caused unintended qvel spikes due to drastic position change. This change allows the EMA to pass the first sample and initialize the EMA memory at the initial sample, avoiding any discontinuity issues.

@ilge ilge requested review from bayesian and raul-openai August 14, 2020 04:11
smooth_pos_setpoint = (smoothing_factor * ctrl_ema) + (1 - smoothing_factor) * d.ctrl[id]
# Apply Exponential Moving Average smoothing to the position setpoint, applying warmstart
# on the first iteration.
if d.time > 0.0:
Copy link

@raul-openai raul-openai Aug 14, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this the best condition to check for? Ie: it happens at d.time == 0, but could it also happen under certain resets that clear data, but do not reset time?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm I'm not sure if we reset the PID controller ever. are you aware of an action triggering that?

Copy link

@raul-openai raul-openai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor comment on condition, but otherwise 👍

@ilge ilge merged commit 4830435 into master Aug 14, 2020
Comment on lines +179 to +183
ctrl_ema = d.userdata[id * NUM_USER_DATA_PER_ACT + IDX_CAS_STORED_EMA_SMOOTH]
smoothing_factor = m.actuator_gainprm[id * NGAIN + IDX_CAS_EMA_SMOOTH]
smooth_pos_setpoint = (smoothing_factor * ctrl_ema) + (1 - smoothing_factor) * d.ctrl[id]
else:
smooth_pos_setpoint = d.ctrl[id]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This logic looks good!

smoothing_factor = m.actuator_gainprm[id * NGAIN + IDX_CAS_EMA_SMOOTH]
smooth_pos_setpoint = (smoothing_factor * ctrl_ema) + (1 - smoothing_factor) * d.ctrl[id]
else:
smooth_pos_setpoint = d.ctrl[id]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shall we also set d.userdata[id * NUM_USER_DATA_PER_ACT + IDX_CAS_STORED_EMA_SMOOTH] to be 0 here, just to be safe.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bayesian the reassignment happens on the next line, is that needed?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

got it. thx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants