40 if (R.isDiagonal(1e-10))
return setWeightR(R.diagonal().asDiagonal());
93 cost.noalias() = u_k.transpose() *
_R_diag * u_k;
95 cost.noalias() = u_k.transpose() *
_R * u_k;
101 cost.noalias() = ud.transpose() *
_R_diag * ud;
103 cost.noalias() = ud.transpose() *
_R * ud;
112 assert(cost.size() == 1);
119 cost[0] += u_k.transpose() *
_R_diag * u_k;
121 cost[0] += u_k.transpose() *
_R * u_k;
127 cost[0] += ud.transpose() *
_R_diag * ud;
129 cost[0] += ud.transpose() *
_R * ud;
142 *issues <<
"QuadraticControlCost: diagonal matrix dimension of R (" <<
_R_diag.
diagonal().size()
143 <<
") does not match control input vector dimension (" << control_dim <<
"); Please specify diagonal elements only."
150 if (
_R.rows() != control_dim ||
_R.cols() != control_dim)
153 *issues <<
"QuadraticControlCost: Matrix dimension of R (" <<
_R.rows() <<
"x" <<
_R.cols()
154 <<
") does not match control input vector dimension (" << control_dim <<
"); Please specify " << (control_dim * control_dim)
155 <<
" elements (Row-Major)." << std::endl;
163 #ifdef MESSAGE_SUPPORT
164 bool QuadraticControlCost::fromMessage(
const messages::QuadraticControlCost& message, std::stringstream* issues)
172 *issues <<
"QuadraticControlCost: cannot set diagonal weight matrix R.\n";
180 if (
q *
q != message.r_size())
182 *issues <<
"QuadraticControlCost: weight matrix R is not square.\n";
191 *issues <<
"QuadraticControlCost: weight matrix R is not positive definite.\n";
206 void QuadraticControlCost::toMessage(messages::QuadraticControlCost& message)
const
212 message.mutable_r()->Resize(Rdiag.size(), 0);
215 message.set_diagonal_only(
true);
219 Eigen::MatrixXd R =
_R;
220 message.mutable_r()->Resize(R.rows() * R.cols(), 0);
224 message.set_diagonal_only(
false);