diff --git a/src/ZMPRefTrajectoryGeneration/generator-vel-ref.cpp b/src/ZMPRefTrajectoryGeneration/generator-vel-ref.cpp index 6fc63b1bf47dce5668748dc8ef3a8ca873a090bc..2812fa8e8be11ac7f99a41c4524fcdd135d7d3b7 100755 --- a/src/ZMPRefTrajectoryGeneration/generator-vel-ref.cpp +++ b/src/ZMPRefTrajectoryGeneration/generator-vel-ref.cpp @@ -68,27 +68,28 @@ GeneratorVelRef::Ponderation( double weight, objective_e type) void -GeneratorVelRef::preview_support_states( double Time, const SupportFSM * FSM, +GeneratorVelRef::preview_support_states( double time, const SupportFSM * FSM, const deque<FootAbsolutePosition> & FinalLeftFootTraj_deq, const deque<FootAbsolutePosition> & FinalRightFootTraj_deq, deque<support_state_t> & SupportStates_deq ) { + const FootAbsolutePosition * FAP = 0; + // DETERMINE CURRENT SUPPORT STATE: // -------------------------------- const reference_t & RefVel = IntermedData_->Reference(); support_state_t & CurrentSupport = IntermedData_->SupportState(); - FSM->set_support_state(CurrentTime_, 0, CurrentSupport, RefVel); - if(CurrentSupport.StateChanged == true) + FSM->set_support_state( CurrentTime_, 0, CurrentSupport, RefVel ); + if( CurrentSupport.StateChanged == true ) { - FootAbsolutePosition FAP; - if(CurrentSupport.Foot == LEFT) - FAP = FinalLeftFootTraj_deq.back(); + if( CurrentSupport.Foot == LEFT ) + FAP = & FinalLeftFootTraj_deq.front(); else - FAP = FinalRightFootTraj_deq.back(); - CurrentSupport.X = FAP.x; - CurrentSupport.Y = FAP.y; - CurrentSupport.Yaw = FAP.theta*M_PI/180.0; - CurrentSupport.StartTime = Time; + FAP = & FinalRightFootTraj_deq.front(); + CurrentSupport.X = FAP->x; + CurrentSupport.Y = FAP->y; + CurrentSupport.Yaw = FAP->theta*M_PI/180.0; + CurrentSupport.StartTime = time; } SupportStates_deq.push_back( CurrentSupport ); IntermedData_->SupportState( CurrentSupport ); @@ -99,9 +100,20 @@ GeneratorVelRef::preview_support_states( double Time, const SupportFSM * FSM, // initialize the previewed support state before previewing support_state_t PreviewedSupport = CurrentSupport; PreviewedSupport.StepNumber = 0; - for(unsigned int i=1;i<=N_;i++) + for( unsigned spNb=1; spNb<=N_; spNb++ ) { - FSM->set_support_state( CurrentTime_, i, PreviewedSupport, RefVel ); + FSM->set_support_state( CurrentTime_, spNb, PreviewedSupport, RefVel ); + if( spNb == 1 && PreviewedSupport.StateChanged )//Foot down + { + if( PreviewedSupport.Foot == LEFT ) + FAP = & FinalLeftFootTraj_deq.back(); + else + FAP = & FinalRightFootTraj_deq.back(); + PreviewedSupport.X = FAP->x; + PreviewedSupport.Y = FAP->y; + PreviewedSupport.Yaw = FAP->theta*M_PI/180.0; + PreviewedSupport.StartTime = time+spNb*Tprw_; + } SupportStates_deq.push_back( PreviewedSupport ); } diff --git a/src/ZMPRefTrajectoryGeneration/mpc-trajectory-generation.cpp b/src/ZMPRefTrajectoryGeneration/mpc-trajectory-generation.cpp index 6ea3389956e2ba5efa5c97d5bfa5b9197091ecdc..25e1090577569a13ee159fbc64e2983ab6223e61 100644 --- a/src/ZMPRefTrajectoryGeneration/mpc-trajectory-generation.cpp +++ b/src/ZMPRefTrajectoryGeneration/mpc-trajectory-generation.cpp @@ -35,8 +35,8 @@ MPCTrajectoryGeneration::MPCTrajectoryGeneration(SimplePluginManager *lSPM) : SimplePlugin(lSPM) , Tsingle_(0.) , Tdble_(0.) - , T_Ctr_(0.) - , T_Prw_(0.) + , Tctr_(0.) + , Tprw_(0.) , PreviewControlTime_(0.) , N_(0) , NbVariables_(0) @@ -101,7 +101,7 @@ void MPCTrajectoryGeneration::CallMethod(std::string & Method, std::istringstrea } else if (Method==":samplingperiod") { - strm >> T_Prw_; + strm >> Tprw_; ODEBUG(":samplingperiod" << T_Ctr_ << " ID: " << this); } diff --git a/src/ZMPRefTrajectoryGeneration/mpc-trajectory-generation.hh b/src/ZMPRefTrajectoryGeneration/mpc-trajectory-generation.hh index e57de71b1b4307f6e10b0d274c41575c3f77fda4..30279dd321c24f86028332742ef9399cf5129fc2 100644 --- a/src/ZMPRefTrajectoryGeneration/mpc-trajectory-generation.hh +++ b/src/ZMPRefTrajectoryGeneration/mpc-trajectory-generation.hh @@ -57,7 +57,7 @@ namespace PatternGeneratorJRL double Tdble_; /// \brief Sampling periods control and preview - double T_Ctr_, T_Prw_; + double Tctr_, Tprw_; /* ! \brief Preview control window in second. */ double PreviewControlTime_; @@ -146,19 +146,19 @@ namespace PatternGeneratorJRL /// \brief Get the sampling period for the control, set to 0.005 by default. */ inline const double & SamplingPeriodControl() const - { return T_Ctr_; }; + { return Tctr_; }; /// \brief Set the sampling period for the control. */ inline void SamplingPeriodControl(double SamplingPeriod) - { T_Ctr_ = SamplingPeriod;}; + { Tctr_ = SamplingPeriod;}; /// \brief Get the sampling period for the preview, set to 0.100 by default. inline const double & SamplingPeriodPreview() const - { return T_Prw_; }; + { return Tprw_; }; /// \brief Set the sampling period for the preview. inline void SamplingPeriodPreview(double SamplingPeriod) - { T_Prw_ = SamplingPeriod;}; + { Tprw_ = SamplingPeriod;}; /// \brief Get the sampling period for the preview, set to 0.100 by default. inline const unsigned int & NbPrwSamplings() const