83 HUMOTO_THROW_MSG(
"Given stance type does not have corresponding support foot.");
94 #define HUMOTO_CONFIG_SECTION_ID "StanceFSMParameters" 95 #define HUMOTO_CONFIG_CONSTRUCTOR StanceFSMParameters 96 #define HUMOTO_CONFIG_ENTRIES \ 97 HUMOTO_CONFIG_SCALAR_(ss_duration_ms) \ 98 HUMOTO_CONFIG_SCALAR_(tds_duration_ms) \ 99 HUMOTO_CONFIG_SCALAR_(first_stance_duration_ms) \ 100 HUMOTO_CONFIG_SCALAR_(last_stance_duration_ms) \ 101 HUMOTO_CONFIG_SCALAR_(num_steps) \ 102 HUMOTO_CONFIG_ENUM_(first_stance) \ 103 HUMOTO_CONFIG_ENUM_(first_ss_type) \ 104 HUMOTO_CONFIG_ENUM_(last_stance) 105 #include HUMOTO_CONFIG_DEFINE_ACCESSORS 142 return last_stance_duration_ms_;
144 return tds_duration_ms_;
146 return ss_duration_ms_;
148 return ss_duration_ms_;
165 ss_duration_ms_ = 700;
166 tds_duration_ms_ = 100;
167 first_stance_duration_ms_ = 300;
168 last_stance_duration_ms_ = 2900;
201 total_duration_ms_ = 0;
213 const std::string &name =
"stance")
const 218 logger.log(
LogEntryName(subname).add(
"previous_nonds_stance_type") , previous_nonds_stance_type_ );
219 logger.log(
LogEntryName(subname).add(
"previous_nontds_stance_type"), previous_nontds_stance_type_);
220 logger.log(
LogEntryName(subname).add(
"subtype") , subtype_ );
221 logger.log(
LogEntryName(subname).add(
"duration_ms") , duration_ms_ );
222 logger.log(
LogEntryName(subname).add(
"total_duration_ms") , total_duration_ms_ );
237 HUMOTO_ASSERT(sfsm_params_.num_steps_ != 1,
"Unsupported number of steps.");
239 ss_states_to_termination_ = sfsm_params_.num_steps_;
240 current_time_ms_ = 0;
241 is_tds_started_ =
false;
244 current_stance_.type_ = sfsm_params_.first_stance_;
245 current_stance_.duration_ms_ = sfsm_params_.first_stance_duration_ms_;
247 switch (current_stance_.type_)
251 current_stance_.previous_nonds_stance_type_ = current_stance_.type_;
254 switch(sfsm_params_.first_ss_type_)
264 sfsm_params_.num_steps_ = 0;
287 void shiftTime(
const std::size_t shift_time_ms);
289 Stance getNextStance()
const;
290 std::vector<Stance> previewStances(
const std::size_t preview_duration_ms)
const;
301 sfsm_params_ = sfsm_params;
318 bool not_enough_states =
false;
320 std::vector<Stance> stance_types;
326 for (std::size_t duration_ms = preview_duration_ms; duration_ms > 0; )
346 not_enough_states =
true;
355 stance_types.push_back(stance_type);
359 if((not_enough_states ==
false) && (stance_types.back().type_ ==
StanceType::TDS))
373 stance_types.push_back(stance_type);
398 sfsm_params_ = sfsm_params;
410 for (std::size_t time_ms = shift_time_ms; time_ms > 0; )
412 is_tds_started_ =
false;
414 if(current_time_ms_ + time_ms < current_stance_.duration_ms_)
416 current_time_ms_ = current_time_ms_ + time_ms;
421 time_ms -= (current_stance_.duration_ms_ - current_time_ms_);
433 is_tds_started_ =
true;
437 switch(current_stance_.type_)
440 current_stance_.previous_nonds_stance_type_ = current_stance_.type_;
441 current_stance_.previous_nontds_stance_type_ = current_stance_.type_;
443 current_stance_.duration_ms_ = sfsm_params_.getDurationMs(
StanceType::TDS);
444 current_time_ms_ = 0;
448 current_stance_.previous_nonds_stance_type_ = current_stance_.type_;
449 current_stance_.previous_nontds_stance_type_ = current_stance_.type_;
451 current_stance_.duration_ms_ = sfsm_params_.getDurationMs(
StanceType::TDS);
452 current_time_ms_ = 0;
456 is_tds_started_ =
false;
458 if(ss_states_to_termination_ == 0)
462 current_stance_.duration_ms_ = sfsm_params_.getDurationMs(
StanceType::DS);
463 current_time_ms_ = 0;
467 if(ss_states_to_termination_ > 0)
469 ss_states_to_termination_ = ss_states_to_termination_ - 1;
475 current_stance_.duration_ms_ = sfsm_params_.getDurationMs(
StanceType::RSS);
476 current_time_ms_ = 0;
478 else if(current_stance_.previous_nonds_stance_type_ ==
StanceType::RSS)
481 current_stance_.duration_ms_ = sfsm_params_.getDurationMs(
StanceType::LSS);
482 current_time_ms_ = 0;
492 current_stance_.previous_nontds_stance_type_ = current_stance_.type_;
494 if(ss_states_to_termination_ == 0)
497 current_stance_.duration_ms_ = sfsm_params_.getDurationMs(
StanceType::DS);
498 current_time_ms_ = 0;
503 current_stance_.duration_ms_ = sfsm_params_.getDurationMs(
StanceType::TDS);
504 current_time_ms_ = 0;
523 const std::string &name =
"stance_fsm")
const 527 current_stance_.log(logger, subname,
"current_stance");
528 logger.log(
LogEntryName(subname).add(
"ss_states_to_termination"), ss_states_to_termination_);
529 logger.log(
LogEntryName(subname).add(
"current_time") , current_time_ms_ );
530 logger.log(
LogEntryName(subname).add(
"is_tds_started") , is_tds_started_ );
Stance()
Default constructor.
humoto::LeftOrRight::Type determineSupportFoot(const StanceType::Type &stance_type)
Determines support foot for the given single support stance.
void shiftTime(const std::size_t shift_time_ms)
Shift time.
std::size_t ss_states_to_termination_
StanceSubType::Type subtype_
void shiftStance()
Shift state of the model.
Possible stance types of the model.
Possible stance subtypes of the model.
void setParameters(const StanceFSMParameters &sfsm_params)
#define HUMOTO_GLOBAL_LOGGER_IF_DEFINED
#define HUMOTO_ASSERT(condition, message)
StanceType::Type first_ss_type_
Default configurable base is strict.
std::size_t first_stance_duration_ms_
#define HUMOTO_THROW_MSG(s)
HUMOTO_THROW_MSG throws an error message concatenated with the name of the function (if supported)...
Represents log entry name.
std::size_t total_duration_ms_
StanceFiniteStateMachine()
std::size_t ss_duration_ms_
std::size_t current_time_ms_
std::size_t last_stance_duration_ms_
Transitional double support.
Threaded logger: any data sent to this logger is wrapped in a message and pushed to a queue...
void setDefaults()
Default parameters of the finite state machine.
StanceFSMParameters sfsm_params_
void log(humoto::Logger &logger, const LogEntryName &parent=LogEntryName(), const std::string &name="stance") const
Log.
StanceType::Type last_stance_
std::vector< Stance > previewStances(const std::size_t preview_duration_ms) const
Preview sequence of Stances of the FSM.
std::size_t tds_duration_ms_
The root namespace of HuMoTo.
StanceType::Type previous_nonds_stance_type_
std::size_t getDurationMs(const StanceType::Type stance_type) const
Returns duration of a stance.
StanceType::Type previous_nontds_stance_type_
Stance getNextStance() const
Preview next walk state of the FSM.
Finite state machine for walking. [initialize_contact_walk_fsm.m].
LogEntryName & add(const char *name)
extends entry name with a subname
void log(humoto::Logger &, const LogEntryName &, const std::string &) const
Log.
StanceType::Type first_stance_
StanceFSMParameters()
Default constructor.
Class containing parameters of the stance finite state machine.