107 rotation_ = Eigen::Rotation2Dd(theta);
123 const std::string & name =
"preview_interval")
const 127 logger.log(
LogEntryName(subname).add(
"base_height") , base_height_ );
128 logger.log(
LogEntryName(subname).add(
"body_height") , body_height_ );
129 logger.log(
LogEntryName(subname).add(
"base_mass") , base_mass_ );
130 logger.log(
LogEntryName(subname).add(
"body_mass") , body_mass_ );
133 logger.log(
LogEntryName(subname).add(
"base_vel_ref") , base_vel_ref_);
134 logger.log(
LogEntryName(subname).add(
"base_pos_ref") , base_pos_ref_);
135 logger.log(
LogEntryName(subname).add(
"theta") , theta_ );
136 logger.log(
LogEntryName(subname).add(
"rotation") , rotation_);
137 logger.log(
LogEntryName(subname).add(
"body_bounds"), body_bounds_);
138 logger.log(
LogEntryName(subname).add(
"cop_bounds"), cop_bounds_);
139 logger.log(
LogEntryName(subname).add(
"nominal_base_velocity_bounds"), nominal_base_velocity_bounds_);
140 logger.log(
LogEntryName(subname).add(
"nominal_base_acceleration_bounds"), nominal_base_acceleration_bounds_);
169 bool preview_horizon_formed =
false;
183 intervals_[i].initialize(theta, mpc_params, motion_parameters, model);
186 preview_horizon_formed =
true;
189 return (preview_horizon_formed);
204 const std::deque<MotionParameters> &motion_parameters_deque)
206 bool preview_horizon_formed =
false;
214 std::size_t remainder_ms = 0;
215 for ( std::deque<MotionParameters>::const_iterator it = motion_parameters_deque.begin();
216 it != motion_parameters_deque.end();
223 intervals_[i].initialize(theta, mpc_params, *it, model);
225 preview_horizon_formed =
true;
230 std::size_t number_of_iterations = std::min(
231 static_cast<std::size_t>( (remainder_ms + it->duration_ms_) / mpc_params.
sampling_time_ms_),
234 for (std::size_t j = 0; j < number_of_iterations; ++i, ++j)
236 intervals_[i].initialize(theta, mpc_params, *it, model);
241 preview_horizon_formed =
true;
246 remainder_ms =
static_cast<std::size_t
>(
252 return (preview_horizon_formed);
263 return (intervals_.size());
276 return (intervals_[interval_index].nominal_base_velocity_bounds_);
289 return (intervals_[interval_index].nominal_base_acceleration_bounds_);
302 return (intervals_[interval_index].body_bounds_);
315 return (intervals_[interval_index].cop_bounds_);
328 return (intervals_[interval_index].base_vel_ref_);
341 return (intervals_[interval_index].base_pos_ref_);
354 return (intervals_[interval_index].rotation_);
369 for (std::size_t interval_index = 0; interval_index < intervals_.size(); ++interval_index)
371 std::size_t interval_duration_ms = intervals_[interval_index].T_ms_;
373 if (offset_ms > interval_duration_ms)
375 offset_ms -= interval_duration_ms;
379 return (interval_index);
383 HUMOTO_THROW_MSG(
"The requested time offset is outside of the preview horizon.");
398 for (std::size_t interval_index = 0; interval_index < intervals_.size(); ++interval_index)
400 double interval_duration = intervals_[interval_index].T_;
402 if (offset > interval_duration)
404 offset -= interval_duration;
408 return (interval_index);
412 HUMOTO_THROW_MSG(
"The requested time offset is outside of the preview horizon.");
425 const std::string & name =
"preview_horizon")
const 428 subname.
add(name).
add(
"interval");
431 for (std::size_t i = 0; i < intervals_.size(); ++i)
433 intervals_[i].log(logger,
LogEntryName(subname).add(i),
"");
etools::Vector2 getBaseVelocity() const
Get base reference velocity.
std::size_t preview_horizon_length_
Length of the preview horizon (N)
etools::Vector2 base_pos_ref_
double getBaseAngularVelocity() const
Get theta increment.
double getBodyHeight() const
Get body height.
etools::Matrix2 getBodyBounds() const
Get respective bounds.
PreviewHorizonInterval()
Default constructor.
void log(humoto::Logger &logger, const LogEntryName &parent=LogEntryName(), const std::string &name="preview_horizon") const
Log.
void log(humoto::Logger &logger, const LogEntryName &parent=LogEntryName(), const std::string &name="preview_interval") const
Log.
std::size_t getIntervalIndexByTimeOffset(std::size_t &offset_ms) const
Finds interval which contains the time instant with the given offset from the beginning of the previe...
std::ptrdiff_t duration_ms_
std::size_t getPreviewHorizonLength() const
Get preview horizon length.
#define HUMOTO_GLOBAL_LOGGER_IF_DEFINED
etools::Matrix2 body_bounds_
std::size_t getIntervalIndexByTimeOffset(double &offset) const
Finds interval which contains the time instant with the given offset from the beginning of the previe...
#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.
etools::Matrix2 getNominalBaseAccelerationBounds() const
Get respective bounds.
double getBaseMass() const
Get base mass.
etools::Matrix2 getBodyBounds(const std::size_t interval_index) const
Get body bounds.
etools::Matrix2 getNominalBaseAccelerationBounds(const std::size_t interval_index) const
Get nominal base acceleration bounds for a given interval.
bool form(const MPCParameters &mpc_params, const Model &model, const std::deque< MotionParameters > &motion_parameters_deque)
Form the preview horizon object.
Parameters of the motion.
etools::Matrix2 nominal_base_velocity_bounds_
etools::Matrix2 getCoPBounds() const
Get respective bounds.
Threaded logger: any data sent to this logger is wrapped in a message and pushed to a queue...
std::size_t sampling_time_ms_
Sampling time in milliseconds (T_ms)
Parameters of the MPC problem.
etools::Vector2 base_vel_ref_
double getBaseOrientation() const
Get base orientation.
double getBaseHeight() const
Get base height.
A helper class defining one interval of a preview horizon.
etools::Matrix2 getNominalBaseVelocityBounds(const std::size_t interval_index) const
Get nominal base velocity bounds for a given interval.
etools::Matrix2 cop_bounds_
The root namespace of HuMoTo.
humoto::pepper_mpc::RobotParameters robot_parameters_
robot parameters
std::vector< PreviewHorizonInterval > intervals_
etools::Matrix2 nominal_base_acceleration_bounds_
bool form(const MPCParameters &mpc_params, const Model &model, const MotionParameters &motion_parameters)
Form the preview horizon object.
static const std::ptrdiff_t UNLIMITED_DURATION
etools::Vector2 getBaseReferenceVelocity(const std::size_t interval_index) const
Get base reference velocity.
etools::Matrix2 getRotationMatrix(const std::size_t interval_index) const
Get orientation of the support corresponding to the given interval.
etools::Matrix2 getNominalBaseVelocityBounds() const
Get respective bounds.
Preview horizon of an MPC [form_preview_horizon.m].
etools::Matrix2 rotation_
LogEntryName & add(const char *name)
extends entry name with a subname
etools::Vector2 getBasePosition() const
Get base reference position.
double getBodyMass() const
Get body mass.
void initialize(double &theta, const MPCParameters &mpc_params, const MotionParameters &motion_parameters, const Model &model)
Form the preview horizon object.
etools::Vector2 getBaseReferencePosition(const std::size_t interval_index) const
Get base reference position.
double getSamplingTime() const
Get sampling time in seconds.
etools::Matrix2 getCoPBounds(const std::size_t interval_index) const
Get CoP bounds for given interval.