22 #include "MAWalkBaseBehaviors.hpp" 24 #include "types/MAComplexIndicators.hpp" 25 #include "types/MAGoals.hpp" 26 #include "types/MARobotState.hpp" 27 #include "MAAvoidObstacleMaster.hpp" 28 #include "MARecognizeFloorSurface.hpp" 29 #include "MAWalkBalanceToLeft.hpp" 30 #include "MAWalkBalanceToRight.hpp" 31 #include "MAWalkPushBackward.hpp" 32 #include "MAWalkPushForward.hpp" 33 #include "MAWalkSwingBackward.hpp" 34 #include "MAWalkSwingForward.hpp" 40 if (MA::RobotState->ComplexIndicators->ElapsedForwardWalkTime > 0 &&
41 MA::RobotState->ComplexIndicators->NearObjectForward > 90)
43 MC_LOG(
"Stop walking: near object forward (%d)",
44 (
int)MA::RobotState->ComplexIndicators->NearObjectForward);
48 if (MA::RobotState->ComplexIndicators->ElapsedForwardWalkTime > 0 &&
49 MA::RobotState->ComplexIndicators->AbyssWhileWalking > 90)
51 MC_LOG(
"Stop walking: abyss while walking (%d)",
52 (
int)MA::RobotState->ComplexIndicators->AbyssWhileWalking);
56 if (MA::RobotState->Goals->LiePostureDesire > 0 || MA::RobotState->Goals->SitPostureDesire > 0 ||
57 MA::RobotState->Goals->StandPostureDesire > 0)
59 MC_LOG(
"Stop walking: desired posture (lie: %d, sit: %d, stand: %d)",
60 (
int)MA::RobotState->Goals->LiePostureDesire, (
int)MA::RobotState->Goals->SitPostureDesire,
61 (
int)MA::RobotState->Goals->StandPostureDesire);
64 if (MA::RobotState->Goals->DesiredLeftTurnDuration > 0)
66 MC_LOG(
"Stop walking: to turn left");
69 if (MA::RobotState->Goals->DesiredRightTurnDuration > 0)
71 MC_LOG(
"Stop walking: to turn right");
74 if (MA::RobotState->ComplexIndicators->ElapsedForwardWalkTime > 0 &&
75 MA::RobotState->Goals->DesiredBackwardWalkDuration > 0)
77 MC_LOG(
"Stop walking: to walk backward");
80 if (MA::RobotState->ComplexIndicators->ElapsedBackwardWalkTime > 0 &&
81 MA::RobotState->Goals->DesiredForwardWalkDuration > 0)
83 MC_LOG(
"Stop walking: to walk forward");
88 int DesiredDuration = 0;
89 int CurrentDuration = 0;
91 if (MA::RobotState->Goals->DesiredForwardWalkDuration > 0 &&
92 MA::RobotState->ComplexIndicators->ElapsedForwardWalkTime > 0)
94 DesiredDuration = MA::RobotState->Goals->DesiredForwardWalkDuration;
95 CurrentDuration = MA::RobotState->ComplexIndicators->ElapsedForwardWalkTime;
97 if (MA::RobotState->Goals->DesiredBackwardWalkDuration > 0 &&
98 MA::RobotState->ComplexIndicators->ElapsedBackwardWalkTime > 0)
100 DesiredDuration = MA::RobotState->Goals->DesiredBackwardWalkDuration;
101 CurrentDuration = MA::RobotState->ComplexIndicators->ElapsedBackwardWalkTime;
103 return CurrentDuration >= DesiredDuration;
107 MAWalkLegBehaviorBase::MAWalkLegBehaviorBase(
const std::string& behavior_name, MA::Leg::LegTypes leg_type) :
115 return IsWalkFinished();
122 for (
int i = (
int)MA::Leg::LF; i <= (int)MA::Leg::RH; ++i)
128 for (
int i = (
int)MA::Leg::LF; i <= (int)MA::Leg::RH; ++i)
139 MAWalkBehaviorBase::MAWalkBehaviorBase(
const std::string& behavior_name,
bool dynamic) :
147 return IsWalkFinished();
Balances the body to left.
#define MABEHAVIOR_DELETE(_behavior)
Delete a behavior safely (mark it dirty if exists)
Base class for leg behaviors.
MABehavior(const std::string &type_name, bool dynamic=true)
Create a behavior.
virtual bool IsFailed() override
Whether the behavior is failed.
#define MABEHAVIOR_CREATE(_behavior, _master,...)
Create behaviors with custom constructor safely.
Avoid an abyss or an object while walking.
virtual void FailingActions() override
Perform actions when the behavior is being failed.
virtual bool IsFailed() override
Whether the behavior is failed.
Indicate the floor surface recognition period.
#define MC_LOG(...)
Debug macro.
Balances the body to Right.