49 inputTraj_ = Eigen::VectorXd::Zero(NB_STEPS * INPUT_SIZE);
50 stateTraj_ = Eigen::VectorXd::Zero((NB_STEPS + 1) * STATE_SIZE);
55 if(stateTraj.size() / STATE_SIZE != 1 + inputTraj.size() / INPUT_SIZE)
57 LOG_ERROR(
"Invalid state/input sizes, respectively " << stateTraj.size() <<
" and " << inputTraj.size());
59 stateTraj_ = stateTraj;
60 inputTraj_ = inputTraj;
65 if(playbackStep_ < NB_STEPS)
77 Eigen::Vector3d comddd;
78 comddd.head<INPUT_SIZE>() = inputTraj_.segment<INPUT_SIZE>(INPUT_SIZE * playbackStep_);
81 if(playbackTime_ >= (playbackStep_ + 1) * SAMPLING_PERIOD)
90 Eigen::Vector3d comddd;
91 Eigen::VectorXd lastState = stateTraj_.segment<STATE_SIZE>(STATE_SIZE * NB_STEPS);
92 Eigen::Vector2d comd_f = lastState.segment<2>(2);
93 Eigen::Vector2d comdd_f = lastState.segment<2>(4);
94 if(std::abs(comd_f.x() * comdd_f.y() - comd_f.y() * comdd_f.x()) > 1e-4)
96 LOG_WARNING(
"MPC terminal condition is not properly fulfilled");
98 double omega_f = -comd_f.dot(comdd_f) / comd_f.dot(comd_f);
99 double lambda_f = std::pow(omega_f, 2);
100 comddd = -omega_f * pendulum.
comdd() - lambda_f * pendulum.
comd();
static constexpr unsigned INPUT_SIZE
Input is the 2D horizontal CoM jerk.
const Eigen::Vector3d & comdd() const
CoM acceleration in the world frame.
void integratePostPlayback(Pendulum &state, double dt)
Post-playback integration of state reference.
State of the inverted pendulum model.
const Eigen::Vector3d & comd() const
CoM velocity in the world frame.
static constexpr unsigned NB_STEPS
Number of sampling steps.
static EIGEN_MAKE_ALIGNED_OPERATOR_NEW constexpr double SAMPLING_PERIOD
Duration of each sampling step in [s].
void integrateCoMJerk(const Eigen::Vector3d &comddd, double dt)
Integrate constant CoM jerk for a given duration.
static constexpr unsigned STATE_SIZE
State is the 6D stacked vector of CoM positions, velocities and accelerations.
void integratePlayback(Pendulum &state, double dt)
Playback integration of state reference.
Main controller namespace.
EIGEN_MAKE_ALIGNED_OPERATOR_NEW Preview()
Initialize with zero state and input trajectories.
void integrate(Pendulum &state, double dt)
Integrate playback on reference.