10 #ifndef CROCODDYL_CORE_ACTIVATIONS_QUADRATIC_HPP_
11 #define CROCODDYL_CORE_ACTIVATIONS_QUADRATIC_HPP_
15 #include "crocoddyl/core/activation-base.hpp"
16 #include "crocoddyl/core/fwd.hpp"
17 #include "crocoddyl/core/utils/exception.hpp"
21 template <
typename _Scalar>
24 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
26 typedef _Scalar Scalar;
30 typedef typename MathBase::VectorXs VectorXs;
31 typedef typename MathBase::MatrixXs MatrixXs;
36 virtual void calc(
const boost::shared_ptr<ActivationDataAbstract>& data,
37 const Eigen::Ref<const VectorXs>& r) {
38 if (
static_cast<std::size_t
>(r.size()) != nr_) {
39 throw_pretty(
"Invalid argument: "
40 <<
"r has wrong dimension (it should be " +
41 std::to_string(nr_) +
")");
43 data->a_value = Scalar(0.5) * r.dot(r);
46 virtual void calcDiff(
const boost::shared_ptr<ActivationDataAbstract>& data,
47 const Eigen::Ref<const VectorXs>& r) {
48 if (
static_cast<std::size_t
>(r.size()) != nr_) {
49 throw_pretty(
"Invalid argument: "
50 <<
"r has wrong dimension (it should be " +
51 std::to_string(nr_) +
")");
56 assert_pretty(MatrixXs(data->Arr).isApprox(MatrixXs::Identity(nr_, nr_)),
57 "Arr has wrong value");
60 virtual boost::shared_ptr<ActivationDataAbstract> createData() {
61 boost::shared_ptr<ActivationDataAbstract> data =
62 boost::allocate_shared<ActivationDataAbstract>(
63 Eigen::aligned_allocator<ActivationDataAbstract>(),
this);
64 data->Arr.diagonal().setOnes();
73 virtual void print(std::ostream& os)
const {
74 os <<
"ActivationModelQuad {nr=" << nr_ <<
"}";
virtual void print(std::ostream &os) const
Print relevant information of the quadratic model.