File tree Expand file tree Collapse file tree
src/JointLevelControllers
include/BipedalLocomotion/JointLevelControllers Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -90,7 +90,7 @@ class EMAWithLimits
9090 * Reset the EMAWithLimits with a new input.
9191 * @param input the new input to reset the EMAWithLimits.
9292 */
93- void reset ();
93+ void reset (Eigen::Ref< const Eigen::VectorXd> input );
9494
9595private:
9696 /* * Private implementation */
Original file line number Diff line number Diff line change @@ -136,7 +136,7 @@ bool EMAWithLimits::initialize(
136136 m_pimpl->state = Impl::State::NotReset;
137137
138138 // reset the system state
139- this ->reset ();
139+ this ->reset (Eigen::VectorXd::Zero (m_pimpl-> lowerLimit . size ()) );
140140
141141 log ()->info (" {} EMAWithLimits successfully initialized." , logPrefix);
142142 return true ;
@@ -186,11 +186,20 @@ const EMAWithLimits::Output& EMAWithLimits::getOutput() const
186186 return m_pimpl->processedActions ;
187187}
188188
189- void EMAWithLimits::reset ()
189+ void EMAWithLimits::reset (Eigen::Ref< const Eigen::VectorXd> initialCondition )
190190{
191- m_pimpl->previousAppliedActions = Eigen::VectorXd::Zero (m_pimpl->softLowerLimit .size ());
191+ if (initialCondition.size () != m_pimpl->softLowerLimit .size ())
192+ {
193+ throw std::runtime_error (
194+ " [EMAWithLimits::reset] Initial condition size mismatch. Provided "
195+ " initial condition has size "
196+ + std::to_string (initialCondition.size ()) + " while the expected size is "
197+ + std::to_string (m_pimpl->softLowerLimit .size ()));
198+ }
199+
200+ m_pimpl->previousAppliedActions = initialCondition;
192201 m_pimpl->input = Eigen::VectorXd::Zero (m_pimpl->softLowerLimit .size ());
193- m_pimpl->processedActions = Eigen::VectorXd::Zero ( m_pimpl->softLowerLimit . size ()) ;
202+ m_pimpl->processedActions = m_pimpl->previousAppliedActions ;
194203 m_pimpl->state = Impl::State::WaitingForAdvance;
195204}
196205
You can’t perform that action at this time.
0 commit comments