63 humoto::walking::Stance::operator=(stance);
77 const std::string &name =
"walk_state")
const 82 logger.log(
LogEntryName(subname).add(
"theta") , theta_ );
83 logger.log(
LogEntryName(subname).add(
"step_height"), step_height_);
85 logger.log(
LogEntryName(subname).add(
"cvel_ref") , cvel_ref_);
86 logger.log(
LogEntryName(subname).add(
"rotation") , rotation_);
87 logger.log(
LogEntryName(subname).add(
"R_cvel_ref"), R_cvel_ref_);
88 logger.log(
LogEntryName(subname).add(
"fd_bounds") , fd_bounds_);
89 logger.log(
LogEntryName(subname).add(
"cop_bounds"), cop_bounds_);
121 const std::string &name =
"preview_interval")
const 126 logger.log(
LogEntryName(subname).add(
"state_index") , state_index_);
127 logger.log(
LogEntryName(subname).add(
"omega") , omega_ );
129 logger.log(
LogEntryName(subname).add(
"cvel_ref") , cvel_ref_ );
153 std::size_t getNumberOfVariableSteps()
const;
167 std::size_t state_index = intervals_[interval_index].state_index_;
168 return (walk_states_[state_index].cop_bounds_);
181 std::size_t interval_index = variable_steps_indices_[var_support_index];
182 std::size_t state_index = intervals_[interval_index].state_index_;
183 return (walk_states_[state_index].fd_bounds_);
196 std::size_t state_index = intervals_[interval_index].state_index_;
197 return (walk_states_[state_index].rotation_);
210 std::size_t state_index = intervals_[interval_index].state_index_;
211 return (walk_states_[state_index]);
220 void previewStates(
const Model &model,
223 const std::size_t preview_duration);
239 const std::size_t preview_duration)
241 std::vector<humoto::walking::Stance> stances;
247 double ds_theta = (lss_theta + rss_theta) / 2.;
249 walk_states_.resize(stances.size());
250 for(std::size_t i = 0; i < stances.size(); ++i)
253 state = stances.at(i);
303 ds_theta = rss_theta;
310 ds_theta = lss_theta;
324 getConstraints(state, model);
326 walk_states_[i] = state;
339 return (variable_steps_indices_.size());
359 bool preview_horizon_formed =
true;
364 std::size_t walk_index = 0;
365 std::size_t num_intervals_left = 0;
368 previewStates(model, stance_fsm, walk_parameters, preview_horizon_length_*sampling_time_ms_);
370 if(walk_states_.empty())
372 preview_horizon_formed =
false;
373 return (preview_horizon_formed);
376 variable_steps_indices_.clear();
378 std::vector<std::size_t> support_indices;
380 intervals_.resize(preview_horizon_length_);
382 std::size_t interval_index = 0;
383 while(interval_index < preview_horizon_length_)
385 WalkState state = walk_states_.at(walk_index);
392 support_indices.push_back(interval_index);
403 state = walk_states_.at(walk_index);
417 --num_intervals_left;
422 intervals_[interval_index] = interval;
430 variable_steps_indices_.push_back(interval_index);
438 state = walk_states_.at(walk_index);
441 intervals_[interval_index] = interval;
451 std::size_t max_index = std::min(preview_horizon_length_, interval_index + num_intervals_left);
452 for(std::size_t i = interval_index; i < max_index; ++i)
454 intervals_[i] = interval;
457 interval_index += num_intervals_left;
461 return (preview_horizon_formed);
553 const std::string &name =
"preview_horizon")
const 561 logger.log(
LogEntryName(subname).add(
"variable_steps_indices"), variable_steps_indices_);
565 subname_loop = subname;
566 subname_loop.
add(
"interval");
567 for (std::size_t i = 0; i < intervals_.size(); ++i)
569 intervals_[i].log(logger,
LogEntryName(subname_loop).add(i),
"");
574 subname_loop = subname;
575 subname_loop.
add(
"state");
576 for (std::size_t i = 0; i < walk_states_.size(); ++i)
578 walk_states_[i].log(logger,
LogEntryName(subname_loop).add(i),
"");
humoto::rigidbody::RigidBodyState getFootState(const humoto::LeftOrRight::Type left_or_right) const
Returns current foot state.
StanceSubType::Type subtype_
void log(humoto::Logger &logger, const LogEntryName &parent=LogEntryName(), const std::string &name="preview_interval") const
Log.
etools::Matrix2 getFootPositionBounds(const std::size_t var_support_index) const
Get bounds on foot position.
void previewStates(const Model &model, const humoto::walking::StanceFiniteStateMachine &stance_fsm, const WalkParameters &walk_parameters, const std::size_t preview_duration)
Preview a sequence of walk states with velocities, rotations etc.
std::size_t preview_horizon_length_
Length of the preview horizon (N)
etools::Vector2 com_velocity_
Preview horizon of an MPC [form_preview_horizon.m].
WalkState & operator=(const humoto::walking::Stance &stance)
Copy stance info.
#define HUMOTO_GLOBAL_LOGGER_IF_DEFINED
#define HUMOTO_ASSERT(condition, message)
void log(humoto::Logger &logger, const LogEntryName &parent=LogEntryName(), const std::string &name="walk_state") const
Log.
Parameters of an MPC problem. [set_parameters_mpc.m].
double HUMOTO_LOCAL convertMillisecondToSecond(const std::size_t milliseconds)
Converts milliseconds to seconds.
etools::Matrix2 getCoPBounds(const std::size_t interval_index) const
Get CoP bounds.
#define HUMOTO_THROW_MSG(s)
HUMOTO_THROW_MSG throws an error message concatenated with the name of the function (if supported)...
etools::Vector2 last_stance_com_velocity_
Represents log entry name.
static double getOmega(const double com_height)
etools::Vector2 first_stance_com_velocity_
etools::Vector2 cvel_ref_
in TDS points to the next SS
etools::Matrix2 cop_bounds_
std::size_t getNumberOfVariableSteps() const
Returns number of variable steps in the preview.
Class containing options of the walking pattern generator.
etools::Vector2 R_cvel_ref_
A helper class defining one interval of a preview horizon.
Transitional double support.
WalkState()
Default constructor.
Threaded logger: any data sent to this logger is wrapped in a message and pushed to a queue...
bool form(const MPCParameters &mpc_params, const Model &model, const humoto::walking::StanceFiniteStateMachine &stance_fsm, const WalkParameters &walk_parameters)
Form the preview horizon object.
std::vector< PreviewHorizonInterval > intervals_
void getConstraints(humoto::wpg04::WalkState &state, const Model &model)
Get constraints for each state.
void log(humoto::Logger &logger, const LogEntryName &parent=LogEntryName(), const std::string &name="stance") const
Log.
double getCoMHeight() const
Get CoM height.
std::vector< Stance > previewStances(const std::size_t preview_duration_ms) const
Preview sequence of Stances of the FSM.
etools::Matrix2 rotation_
const WalkState & getWalkState(const std::size_t interval_index) const
Get walk state corresponding to the given interval.
The root namespace of HuMoTo.
etools::Vector2 cvel_ref_
void log(humoto::Logger &, const LogEntryName &, const std::string &) const
Log.
StanceType::Type previous_nontds_stance_type_
etools::Matrix2 getRotationMatrix(const std::size_t interval_index) const
Get orientation of the support corresponding to the given interval.
A class representing a "state" of the walk.
etools::Matrix2 fd_bounds_
std::vector< WalkState > walk_states_
Finite state machine for walking. [initialize_contact_walk_fsm.m].
LogEntryName & add(const char *name)
extends entry name with a subname
std::size_t sampling_time_ms_
Sampling time in milliseconds (T_ms)
std::size_t tds_sampling_time_ms_
Sampling time of a transitional double support in milliseconds (Ttds_ms)
std::vector< std::size_t > variable_steps_indices_