VelocitySmoothing - (Re)set _state_init every time _state is (re)set

This commit is contained in:
bresch
2019-09-12 17:08:48 +02:00
committed by Matthias Grob
parent 654938f6a1
commit 8490266be8
2 changed files with 5 additions and 3 deletions

View File

@@ -48,6 +48,8 @@ void VelocitySmoothing::reset(float accel, float vel, float pos)
_state.a = accel; _state.a = accel;
_state.v = vel; _state.v = vel;
_state.x = pos; _state.x = pos;
_state_init = _state;
} }
float VelocitySmoothing::saturateT1ForAccel(float a0, float j_max, float T1, float a_max) float VelocitySmoothing::saturateT1ForAccel(float a0, float j_max, float T1, float a_max)

View File

@@ -100,11 +100,11 @@ public:
void setMaxVel(float max_vel) { _max_vel = max_vel; } void setMaxVel(float max_vel) { _max_vel = max_vel; }
float getCurrentJerk() const { return _state.j; } float getCurrentJerk() const { return _state.j; }
void setCurrentAcceleration(const float accel) { _state.a = accel; } void setCurrentAcceleration(const float accel) { _state.a = _state_init.a = accel; }
float getCurrentAcceleration() const { return _state.a; } float getCurrentAcceleration() const { return _state.a; }
void setCurrentVelocity(const float vel) { _state.v = vel; } void setCurrentVelocity(const float vel) { _state.v = _state_init.v = vel; }
float getCurrentVelocity() const { return _state.v; } float getCurrentVelocity() const { return _state.v; }
void setCurrentPosition(const float pos) { _state.x = pos; } void setCurrentPosition(const float pos) { _state.x = _state_init.x = pos; }
float getCurrentPosition() const { return _state.x; } float getCurrentPosition() const { return _state.x; }
float getVelSp() const { return _vel_sp; } float getVelSp() const { return _vel_sp; }