39 const Eigen::MatrixXd &m_b,
40 const Eigen::MatrixXd &m_c,
41 const Eigen::MatrixXd &m_d,
const double ts,
42 Eigen::MatrixXd *ptr_a_d, Eigen::MatrixXd *ptr_b_d,
43 Eigen::MatrixXd *ptr_c_d, Eigen::MatrixXd *ptr_d_d) {
45 AERROR <<
"ContinuousToDiscrete : ts is less than or equal to zero";
51 if (m_a.rows() == 0) {
52 AERROR <<
"ContinuousToDiscrete: matrix_a size 0 ";
56 if (m_a.cols() != m_b.rows() || m_b.cols() != m_d.cols() ||
57 m_c.rows() != m_d.rows() || m_a.cols() != m_c.cols()) {
58 AERROR <<
"ContinuousToDiscrete: matrix dimensions mismatch";
62 Eigen::MatrixXd m_identity =
63 Eigen::MatrixXd::Identity(m_a.cols(), m_a.rows());
66 (m_identity - ts * 0.5 * m_a).inverse() * (m_identity + ts * 0.5 * m_a);
68 *ptr_b_d = std::sqrt(ts) * (m_identity - ts * 0.5 * m_a).inverse() * m_b;
70 *ptr_c_d = std::sqrt(ts) * m_c * (m_identity - ts * 0.5 * m_a).inverse();
72 *ptr_d_d = 0.5 * m_c * (m_identity - ts * 0.5 * m_a).inverse() * m_b + m_d;
bool ContinuousToDiscrete(const Eigen::MatrixXd &m_a, const Eigen::MatrixXd &m_b, const Eigen::MatrixXd &m_c, const Eigen::MatrixXd &m_d, const double ts, Eigen::MatrixXd *ptr_a_d, Eigen::MatrixXd *ptr_b_d, Eigen::MatrixXd *ptr_c_d, Eigen::MatrixXd *ptr_d_d)