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/to-string.hpp"
19 #include "crocoddyl/core/utils/math.hpp"
53 template <
typename _Scalar>
56 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
58 typedef _Scalar Scalar;
62 typedef typename MathBase::VectorXs VectorXs;
63 typedef typename MathBase::MatrixXs MatrixXs;
73 const std::size_t nr = 0);
83 virtual void calc(
const boost::shared_ptr<DifferentialActionDataAbstract>& data,
const Eigen::Ref<const VectorXs>& x,
84 const Eigen::Ref<const VectorXs>& u) = 0;
97 virtual void calcDiff(
const boost::shared_ptr<DifferentialActionDataAbstract>& data,
98 const Eigen::Ref<const VectorXs>& x,
const Eigen::Ref<const VectorXs>& u) = 0;
105 virtual boost::shared_ptr<DifferentialActionDataAbstract>
createData();
110 virtual bool checkData(
const boost::shared_ptr<DifferentialActionDataAbstract>& data);
118 void calc(
const boost::shared_ptr<DifferentialActionDataAbstract>& data,
const Eigen::Ref<const VectorXs>& x);
126 void calcDiff(
const boost::shared_ptr<DifferentialActionDataAbstract>& data,
const Eigen::Ref<const VectorXs>& x);
140 virtual void quasiStatic(
const boost::shared_ptr<DifferentialActionDataAbstract>& data, Eigen::Ref<VectorXs> u,
141 const Eigen::Ref<const VectorXs>& x,
const std::size_t maxiter = 100,
142 const Scalar tol = Scalar(1e-9));
155 VectorXs
quasiStatic_x(
const boost::shared_ptr<DifferentialActionDataAbstract>& data,
const VectorXs& x,
156 const std::size_t maxiter = 100,
const Scalar tol = Scalar(1e-9));
171 const boost::shared_ptr<StateAbstract>&
get_state()
const;
201 template <
class Scalar>
209 virtual void print(std::ostream& os)
const;
220 void update_has_control_limits();
223 template <
typename _Scalar>
225 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
227 typedef _Scalar Scalar;
229 typedef typename MathBase::VectorXs VectorXs;
230 typedef typename MathBase::MatrixXs MatrixXs;
232 template <
template <
typename Scalar>
class Model>
235 xout(model->get_state()->get_nv()),
236 Fx(model->get_state()->get_nv(), model->get_state()->get_ndx()),
237 Fu(model->get_state()->get_nv(), model->get_nu()),
239 Lx(model->get_state()->get_ndx()),
241 Lxx(model->get_state()->get_ndx(), model->get_state()->get_ndx()),
242 Lxu(model->get_state()->get_ndx(), model->get_nu()),
243 Luu(model->get_nu(), model->get_nu()) {
273 #include "crocoddyl/core/diff-action-base.hxx"
Abstract class for differential action model.
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.
void calcDiff(const boost::shared_ptr< DifferentialActionDataAbstract > &data, const Eigen::Ref< const VectorXs > &x)
Compute the derivatives of the dynamics and cost functions.
const boost::shared_ptr< StateAbstract > & get_state() const
Return the state.
VectorXs quasiStatic_x(const boost::shared_ptr< DifferentialActionDataAbstract > &data, const VectorXs &x, const std::size_t maxiter=100, const Scalar tol=Scalar(1e-9))
VectorXs u_lb_
Lower control limits.
DifferentialActionModelAbstractTpl(boost::shared_ptr< StateAbstract > state, const std::size_t nu, const std::size_t nr=0)
Initialize the differential action model.
VectorXs u_ub_
Upper control limits.
virtual boost::shared_ptr< DifferentialActionDataAbstract > createData()
Create the differential action data.
virtual void print(std::ostream &os) const
Print relevant information of the differential action model.
void set_u_ub(const VectorXs &u_ub)
Modify the control upper bounds.
const VectorXs & get_u_ub() const
Return the control upper bound.
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.
void calc(const boost::shared_ptr< DifferentialActionDataAbstract > &data, const Eigen::Ref< const VectorXs > &x)
Compute the system acceleration and cost value.
friend std::ostream & operator<<(std::ostream &os, const DifferentialActionModelAbstractTpl< Scalar > &model)
Print information on the differential action model.
bool has_control_limits_
Indicates whether any of the control limits is finite.
bool get_has_control_limits() const
Indicates if there are defined control limits.
boost::shared_ptr< StateAbstract > state_
Model of the state.
std::size_t nu_
Control dimension.
VectorXs unone_
Neutral state.
std::size_t nr_
Dimension of the cost residual.
std::size_t get_nr() const
Return the dimension of the cost-residual vector.
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.
void set_u_lb(const VectorXs &u_lb)
Modify the control lower bounds.
virtual bool checkData(const boost::shared_ptr< DifferentialActionDataAbstract > &data)
Checks that a specific data belongs to this model.
const VectorXs & get_u_lb() const
Return the control lower bound.
std::size_t get_nu() const
Return the dimension of the control input.
Abstract class for the state representation.
MatrixXs Fx
Jacobian of the dynamics.
MatrixXs Fu
Jacobian of the dynamics.
MatrixXs Luu
Hessian of the cost function.
VectorXs Lx
Jacobian of the cost function.
MatrixXs Lxx
Hessian of the cost function.
VectorXs Lu
Jacobian of the cost function.
VectorXs xout
evolution state
MatrixXs Lxu
Hessian of the cost function.