43 #include <ilqgames/cost/orientation_cost.h> 44 #include <ilqgames/utils/types.h> 46 #include <glog/logging.h> 51 float OrientationCost::Evaluate(
const VectorXf& input)
const {
52 CHECK_LT(dim_, input.size());
55 const float angle_diff =
56 std::fmod(input(dim_) - nominal_ + M_PI, M_PI * 2.0) - M_PI;
58 return 0.5 * weight_ * angle_diff * angle_diff;
61 void OrientationCost::Quadraticize(
const VectorXf& input, MatrixXf* hess,
62 VectorXf* grad)
const {
63 CHECK_LT(dim_, input.size());
68 CHECK_EQ(input.size(), hess->rows());
69 CHECK_EQ(input.size(), hess->cols());
70 CHECK_EQ(input.size(), grad->size());
73 const float angle_diff =
74 std::fmod(input(dim_) - nominal_ + M_PI, M_PI * 2.0) - M_PI;
75 const float dx = weight_ * angle_diff;
76 const float ddx = weight_;
79 (*hess)(dim_, dim_) += ddx;