9 #ifndef CROCODDYL_CORE_DIFF_ACTION_BASE_HPP_ 10 #define CROCODDYL_CORE_DIFF_ACTION_BASE_HPP_ 13 #include <boost/shared_ptr.hpp> 14 #include <boost/make_shared.hpp> 16 #include "crocoddyl/core/fwd.hpp" 17 #include "crocoddyl/core/state-base.hpp" 18 #include "crocoddyl/core/utils/math.hpp" 52 template <
typename _Scalar>
55 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
57 typedef _Scalar Scalar;
61 typedef typename MathBase::VectorXs VectorXs;
62 typedef typename MathBase::MatrixXs MatrixXs;
72 const std::size_t nr = 0);
82 virtual void calc(
const boost::shared_ptr<DifferentialActionDataAbstract>& data,
const Eigen::Ref<const VectorXs>& x,
83 const Eigen::Ref<const VectorXs>& u) = 0;
94 virtual void calc(
const boost::shared_ptr<DifferentialActionDataAbstract>& data,
95 const Eigen::Ref<const VectorXs>& x);
108 virtual void calcDiff(
const boost::shared_ptr<DifferentialActionDataAbstract>& data,
109 const Eigen::Ref<const VectorXs>& x,
const Eigen::Ref<const VectorXs>& u) = 0;
120 virtual void calcDiff(
const boost::shared_ptr<DifferentialActionDataAbstract>& data,
121 const Eigen::Ref<const VectorXs>& x);
128 virtual boost::shared_ptr<DifferentialActionDataAbstract>
createData();
133 virtual bool checkData(
const boost::shared_ptr<DifferentialActionDataAbstract>& data);
147 virtual void quasiStatic(
const boost::shared_ptr<DifferentialActionDataAbstract>& data, Eigen::Ref<VectorXs> u,
148 const Eigen::Ref<const VectorXs>& x,
const std::size_t maxiter = 100,
149 const Scalar tol = Scalar(1e-9));
162 VectorXs
quasiStatic_x(
const boost::shared_ptr<DifferentialActionDataAbstract>& data,
const VectorXs& x,
163 const std::size_t maxiter = 100,
const Scalar tol = Scalar(1e-9));
168 std::size_t
get_nu()
const;
173 std::size_t
get_nr()
const;
178 const boost::shared_ptr<StateAbstract>&
get_state()
const;
198 void set_u_lb(
const VectorXs& u_lb);
203 void set_u_ub(
const VectorXs& u_ub);
208 template <
class Scalar>
209 friend std::ostream& operator<<(std::ostream& os, const DifferentialActionModelAbstractTpl<Scalar>& model);
216 virtual void print(std::ostream& os)
const;
227 void update_has_control_limits();
230 template <
typename _Scalar>
232 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
234 typedef _Scalar Scalar;
236 typedef typename MathBase::VectorXs VectorXs;
237 typedef typename MathBase::MatrixXs MatrixXs;
239 template <
template <
typename Scalar>
class Model>
242 xout(model->get_state()->get_nv()),
243 Fx(model->get_state()->get_nv(), model->get_state()->get_ndx()),
244 Fu(model->get_state()->get_nv(), model->get_nu()),
246 Lx(model->get_state()->get_ndx()),
248 Lxx(model->get_state()->get_ndx(), model->get_state()->get_ndx()),
249 Lxu(model->get_state()->get_ndx(), model->get_nu()),
250 Luu(model->get_nu(), model->get_nu()) {
261 virtual ~DifferentialActionDataAbstractTpl() {}
280 #include "crocoddyl/core/diff-action-base.hxx" 282 #endif // CROCODDYL_CORE_DIFF_ACTION_BASE_HPP_ VectorXs Lx
Jacobian of the cost function.
MatrixXs Fx
Jacobian of the dynamics.
const boost::shared_ptr< StateAbstract > & get_state() const
Return the state.
const VectorXs & get_u_ub() const
Return the control upper bound.
MatrixXs Lxx
Hessian of the cost function.
VectorXs u_lb_
Lower control limits.
Abstract class for differential action model.
MatrixXs Luu
Hessian of the cost function.
virtual void calcDiff(const boost::shared_ptr< DifferentialActionDataAbstract > &data, const Eigen::Ref< const VectorXs > &x, const Eigen::Ref< const VectorXs > &u)=0
Compute the derivatives of the dynamics and cost functions.
VectorXs unone_
Neutral state.
virtual bool checkData(const boost::shared_ptr< DifferentialActionDataAbstract > &data)
Checks that a specific data belongs to this model.
std::size_t nr_
Dimension of the cost residual.
Abstract class for the state representation.
DifferentialActionModelAbstractTpl(boost::shared_ptr< StateAbstract > state, const std::size_t nu, const std::size_t nr=0)
Initialize the differential action model.
void set_u_lb(const VectorXs &u_lb)
Modify the control lower bounds.
std::size_t get_nr() const
Return the dimension of the cost-residual vector.
virtual void calc(const boost::shared_ptr< DifferentialActionDataAbstract > &data, const Eigen::Ref< const VectorXs > &x, const Eigen::Ref< const VectorXs > &u)=0
Compute the system acceleration and cost value.
std::size_t nu_
Control dimension.
bool has_control_limits_
Indicates whether any of the control limits is finite.
virtual void quasiStatic(const boost::shared_ptr< DifferentialActionDataAbstract > &data, Eigen::Ref< VectorXs > u, const Eigen::Ref< const VectorXs > &x, const std::size_t maxiter=100, const Scalar tol=Scalar(1e-9))
Computes the quasic static commands.
std::size_t get_nu() const
Return the dimension of the control input.
virtual boost::shared_ptr< DifferentialActionDataAbstract > createData()
Create the differential action data.
MatrixXs Lxu
Hessian of the cost function.
virtual void print(std::ostream &os) const
Print relevant information of the differential action model.
boost::shared_ptr< StateAbstract > state_
Model of the state.
bool get_has_control_limits() const
Indicates if there are defined control limits.
VectorXs quasiStatic_x(const boost::shared_ptr< DifferentialActionDataAbstract > &data, const VectorXs &x, const std::size_t maxiter=100, const Scalar tol=Scalar(1e-9))
void set_u_ub(const VectorXs &u_ub)
Modify the control upper bounds.
MatrixXs Fu
Jacobian of the dynamics.
VectorXs u_ub_
Upper control limits.
VectorXs xout
evolution state
VectorXs Lu
Jacobian of the cost function.
const VectorXs & get_u_lb() const
Return the control lower bound.