Skip to content

Commit 8f4024c

Browse files
GiulioRomualdilowerbodyqdd
authored andcommitted
Reset EMAWithLimits with the current position
1 parent d414aaf commit 8f4024c

2 files changed

Lines changed: 14 additions & 5 deletions

File tree

src/JointLevelControllers/include/BipedalLocomotion/JointLevelControllers/EMAWithLimits.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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

9595
private:
9696
/** Private implementation */

src/JointLevelControllers/src/EMAWithLimits.cpp

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)