Skip to content

Commit

Permalink
Add a FSM in MANN to handle the status of the advanceable
Browse files Browse the repository at this point in the history
  • Loading branch information
GiulioRomualdi committed Apr 26, 2023
1 parent a1897a3 commit 31b8e91
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/ML/src/MANN.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ using namespace BipedalLocomotion;

struct MANN::Impl
{
enum class FSM
{
NotInitialized, Initialized, Running,
};

struct DataStructured
{
BipedalLocomotion::System::VariablesHandler handler;
Expand All @@ -44,6 +49,8 @@ struct MANN::Impl

Impl();
bool populateInput(const MANNInput& input);

FSM state{FSM::NotInitialized};
};

MANN::Impl::Impl()
Expand Down Expand Up @@ -259,11 +266,18 @@ bool MANN::initialize(
m_pimpl->output.jointVelocities.resize(numberOfJoints);
m_pimpl->output.projectedBaseVelocity = manif::SE2Tangentd::Zero();

m_pimpl->state = Impl::FSM::Initialized;

return true;
}

bool MANN::setInput(const MANNInput& input)
{
if (m_pimpl->state != Impl::FSM::Initialized && m_pimpl->state != Impl::FSM::Running)
{
log()->error("[MANN::setInput] The network is not initialized, please call initialize()");
return false;
}
return m_pimpl->populateInput(input);
}

Expand Down Expand Up @@ -306,12 +320,15 @@ bool MANN::advance()
unpackMatrix("base_velocity", tempVector);
m_pimpl->output.projectedBaseVelocity
= manif::SE2Tangentd(tempVector(0), tempVector(1), tempVector(2));

m_pimpl->state = Impl::FSM::Running;

return true;
}

bool MANN::isOutputValid() const
{
return true;
return m_pimpl->state == Impl::FSM::Running;
}

const MANNOutput& MANN::getOutput() const
Expand Down

0 comments on commit 31b8e91

Please sign in to comment.