diff --git a/src/Mathematics/FootConstraintsAsLinearSystemForVelRef.h b/src/Mathematics/FootConstraintsAsLinearSystemForVelRef.h index e87cb3ad1089fb35cfe7f42fb2ca32442778ad89..fb697a3d9eb82feb0eba3408fa861ab4d2336a88 100644 --- a/src/Mathematics/FootConstraintsAsLinearSystemForVelRef.h +++ b/src/Mathematics/FootConstraintsAsLinearSystemForVelRef.h @@ -45,7 +45,7 @@ #include <PGTypes.h> #include <Mathematics/ConvexHull.h> #include <SimplePlugin.h> -#include <PreviewControl/SupportState.h> +#include <PreviewControl/SupportFSM.h> namespace PatternGeneratorJRL { diff --git a/src/PreviewControl/SupportState.cpp b/src/PreviewControl/SupportState.cpp deleted file mode 100644 index a1dd15d2dd0401c96bd79f8ce81e83048070751b..0000000000000000000000000000000000000000 --- a/src/PreviewControl/SupportState.cpp +++ /dev/null @@ -1,157 +0,0 @@ -/* - * Copyright 2010, - * - * Andrei Herdt - * Olivier Stasse - * - * JRL, CNRS/AIST - * - * This file is part of walkGenJrl. - * walkGenJrl is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * walkGenJrl is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * You should have received a copy of the GNU Lesser General Public License - * along with walkGenJrl. If not, see <http://www.gnu.org/licenses/>. - * - * Research carried out within the scope of the - * Joint Japanese-French Robotics Laboratory (JRL) - */ -/* TODO 3: Restructure the class - * setSupportState.cpp - */ - -#include <iostream> -#include <fstream> - -#include <PreviewControl/SupportState.h> -#include <Debug.h> - -using namespace PatternGeneratorJRL; -using namespace std; - -SupportState::SupportState(const double &SamplingPeriod) -{ - SSPeriod = 0.8; //Duration of one step - DSDuration = 1e9; //Duration of the DS phase - DSSSDuration = 0.8; - NbOfStepsSSDS = 200; - - m_T = SamplingPeriod; - //Initial current state - CurrentSupportPhase = 0; - CurrentSupportFoot = 1; - CurrentTimeLimit = 1000000000; - CurrentStepsLeft = 1; - StartSupportFoot = 1; - - eps = 0.00000001; - m_StateChanged = false; - - m_FullDebug = 0; - -} - - -SupportState::~SupportState() -{ -} - -void SupportState::setSupportState(const double &Time, const int &pi, const ReferenceAbsoluteVelocity & RefVel) - -{ - - m_StateChanged = false; - - if(pi==0) { - m_SupportPhase = &CurrentSupportPhase; - m_SupportFoot = &CurrentSupportFoot; - m_SupportStepsLeft = &CurrentStepsLeft; - m_SupportTimeLimit = &CurrentTimeLimit; - StepNumber = 0; - SSSS = 0; - } - else { - m_SupportPhase = &PrwSupportPhase; - m_SupportFoot = &PrwSupportFoot; - m_SupportStepsLeft = &PrwStepsLeft; - m_SupportTimeLimit = &PrwTimeLimit; - } - - - ReferenceGiven = -1; - if(fabs(RefVel.x)>0||fabs(RefVel.y)>0) - ReferenceGiven = 1; - - if(ReferenceGiven == 1 && *m_SupportPhase == 0 && (*m_SupportTimeLimit-Time-eps)>DSSSDuration) - { - *m_SupportTimeLimit = Time+DSSSDuration; - } - - - //FSM - if(Time+eps+pi*m_T >= *m_SupportTimeLimit) - { - //SS->DS - if(*m_SupportPhase == 1 && ReferenceGiven == -1 && *m_SupportStepsLeft==0) - { - *m_SupportPhase = 0; - *m_SupportTimeLimit = Time+pi*m_T + DSDuration; - m_StateChanged = true; - } - //DS->SS - else if(*m_SupportPhase == 0 && ReferenceGiven == 1) - { - *m_SupportPhase = 1; - *m_SupportTimeLimit = Time+pi*m_T + SSPeriod; - *m_SupportStepsLeft = NbOfStepsSSDS; - m_StateChanged = true; - } - //SS->SS - else if(((*m_SupportPhase == 1) && (*m_SupportStepsLeft>0)) || - ((*m_SupportStepsLeft==0) && (ReferenceGiven == 1))) - { - *m_SupportFoot = -1**m_SupportFoot; - m_StateChanged = true; - *m_SupportTimeLimit = Time+pi*m_T + SSPeriod; - StepNumber++; - SSSS = 1; - if (ReferenceGiven == -1) - *m_SupportStepsLeft = *m_SupportStepsLeft-1; - } - } - - - if(pi==0) - initializePreviewedState(); - - - if(m_FullDebug>0) - { - ofstream aof; - aof.open("SupportStates.dat", ios::app); - aof << "Time: "<<Time<<" PrwTime: "<<Time+pi*m_T<<" CSP: "<<CurrentSupportPhase - <<" CSF: "<<CurrentSupportFoot<<" CTL: "<<CurrentTimeLimit - <<" CSL: "<<CurrentStepsLeft<<" PrwSP: "<<PrwSupportPhase - <<" PrwSF: "<<PrwSupportFoot<<" PrwTL: "<<PrwTimeLimit - <<" PrwSL: "<<PrwStepsLeft<<" *SF: "<<*m_SupportFoot - <<" *SSL: "<<*m_SupportStepsLeft<<" SN: "<<StepNumber; - aof << endl; - aof.close(); - } - -} - -void SupportState::initializePreviewedState() -{ - PrwSupportPhase = CurrentSupportPhase; - PrwSupportFoot = CurrentSupportFoot; - PrwStepsLeft = CurrentStepsLeft; - PrwTimeLimit = CurrentTimeLimit; - StepNumber = 0; -} diff --git a/src/PreviewControl/SupportState.h b/src/PreviewControl/SupportState.h deleted file mode 100644 index 8c96671b61a47eff40eabbcdd9d22bc7692b08ad..0000000000000000000000000000000000000000 --- a/src/PreviewControl/SupportState.h +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright 2010, - * - * Andrei Herdt - * - * JRL, CNRS/AIST - * - * This file is part of walkGenJrl. - * walkGenJrl is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * walkGenJrl is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * You should have received a copy of the GNU Lesser General Public License - * along with walkGenJrl. If not, see <http://www.gnu.org/licenses/>. - * - * Research carried out within the scope of the - * Joint Japanese-French Robotics Laboratory (JRL) - */ -/* This object provides the finite state machine to determine the support parameters. */ - -#ifndef _SUPPORT_STATE_ -#define _SUPPORT_STATE_ - -#include <walkGenJrl/PGTypes.h> - -namespace PatternGeneratorJRL -{ - class SupportState - { - public: - /*! Constructor */ - SupportState(const double &SamplingPeriod); - - /*! Destructor */ - ~SupportState(); - - /*! \brief Initialize the previewed state. */ - void setSupportState(const double &Time, const int &pi, const ReferenceAbsoluteVelocity & RefVel); - - - - ///*! \brief Numerical precision */ - double eps; - - /*! \brief constants for the durations in the support phases */ - double DSDuration, SSPeriod, DSSSDuration; - - /*! \brief First support foot */ - int StartSupportFoot; - - /*! \brief Current support state */ - int CurrentSupportPhase, CurrentSupportFoot, CurrentStepsLeft; - - int SSSS; - - double CurrentTimeLimit; - - /*! \brief Future support state */ - int PrwSupportPhase, PrwSupportFoot, PrwStepsLeft; - - double PrwTimeLimit; - - bool m_StateChanged; - - int StepNumber; - - //Number of steps done before DS - unsigned int NbOfStepsSSDS; - - - private: - - /*! \Brief Sampling duration */ - double m_T; - - /*! \Brief Support state */ - int *m_SupportPhase, *m_SupportFoot, *m_SupportStepsLeft; - - double *m_SupportTimeLimit; - void initializePreviewedState(); - - int ReferenceGiven; - - int m_FullDebug; - - - ///*! Getter for the support state */ - //const void SupportState::getSupportState () const; - - - }; -}; - -#endif /* _SUPPORT_STATE_ */ diff --git a/src/ZMPRefTrajectoryGeneration/OrientationsPreview.h b/src/ZMPRefTrajectoryGeneration/OrientationsPreview.h index b53469941a12712db6f15601d210364edb380d54..9a7823b830009ac67e5bfbc16b3bbd272f03255a 100644 --- a/src/ZMPRefTrajectoryGeneration/OrientationsPreview.h +++ b/src/ZMPRefTrajectoryGeneration/OrientationsPreview.h @@ -37,7 +37,7 @@ #include <deque> /*! Framework includes */ -#include <PreviewControl/SupportState.h> +#include <PreviewControl/SupportFSM.h> /*! Framework includes */ #include <walkGenJrl/PGTypes.h>