9 #ifndef CROCODDYL_CORE_ACTION_BASE_HPP_ 10 #define CROCODDYL_CORE_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" 58 template <
typename _Scalar>
61 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
63 typedef _Scalar Scalar;
67 typedef typename MathBase::VectorXs VectorXs;
76 ActionModelAbstractTpl(boost::shared_ptr<StateAbstract> state,
const std::size_t nu,
const std::size_t nr = 0);
86 virtual void calc(
const boost::shared_ptr<ActionDataAbstract>& data,
const Eigen::Ref<const VectorXs>& x,
87 const Eigen::Ref<const VectorXs>& u) = 0;
98 virtual void calc(
const boost::shared_ptr<ActionDataAbstract>& data,
const Eigen::Ref<const VectorXs>& x);
111 virtual void calcDiff(
const boost::shared_ptr<ActionDataAbstract>& data,
const Eigen::Ref<const VectorXs>& x,
112 const Eigen::Ref<const VectorXs>& u) = 0;
123 virtual void calcDiff(
const boost::shared_ptr<ActionDataAbstract>& data,
const Eigen::Ref<const VectorXs>& x);
130 virtual boost::shared_ptr<ActionDataAbstract>
createData();
135 virtual bool checkData(
const boost::shared_ptr<ActionDataAbstract>& data);
149 virtual void quasiStatic(
const boost::shared_ptr<ActionDataAbstract>& data, Eigen::Ref<VectorXs> u,
150 const Eigen::Ref<const VectorXs>& x,
const std::size_t maxiter = 100,
151 const Scalar tol = Scalar(1e-9));
164 VectorXs
quasiStatic_x(
const boost::shared_ptr<ActionDataAbstract>& data,
const VectorXs& x,
165 const std::size_t maxiter = 100,
const Scalar tol = Scalar(1e-9));
170 std::size_t
get_nu()
const;
175 std::size_t
get_nr()
const;
180 const boost::shared_ptr<StateAbstract>&
get_state()
const;
200 void set_u_lb(
const VectorXs& u_lb);
205 void set_u_ub(
const VectorXs& u_ub);
210 template <
class Scalar>
211 friend std::ostream& operator<<(std::ostream& os, const ActionModelAbstractTpl<Scalar>& model);
218 virtual void print(std::ostream& os)
const;
235 template <
typename _Scalar>
237 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
239 typedef _Scalar Scalar;
241 typedef typename MathBase::VectorXs VectorXs;
242 typedef typename MathBase::MatrixXs MatrixXs;
244 template <
template <
typename Scalar>
class Model>
247 xnext(model->get_state()->get_nx()),
248 Fx(model->get_state()->get_ndx(), model->get_state()->get_ndx()),
249 Fu(model->get_state()->get_ndx(), model->get_nu()),
251 Lx(model->get_state()->get_ndx()),
253 Lxx(model->get_state()->get_ndx(), model->get_state()->get_ndx()),
254 Lxu(model->get_state()->get_ndx(), model->get_nu()),
255 Luu(model->get_nu(), model->get_nu()) {
266 virtual ~ActionDataAbstractTpl() {}
285 #include "crocoddyl/core/action-base.hxx" 287 #endif // CROCODDYL_CORE_ACTION_BASE_HPP_ void set_u_lb(const VectorXs &u_lb)
Modify the control lower bounds.
Abstract class for action model.
bool has_control_limits_
Indicates whether any of the control limits is finite.
const boost::shared_ptr< StateAbstract > & get_state() const
Return the state.
MatrixXs Lxx
Hessian of the cost function.
virtual boost::shared_ptr< ActionDataAbstract > createData()
Create the action data.
std::size_t nu_
Control dimension.
void update_has_control_limits()
Update the status of the control limits (i.e. if there are defined limits)
VectorXs xnext
evolution state
std::size_t get_nu() const
Return the dimension of the control input.
Abstract class for the state representation.
bool get_has_control_limits() const
Indicates if there are defined control limits.
void set_u_ub(const VectorXs &u_ub)
Modify the control upper bounds.
const VectorXs & get_u_lb() const
Return the control lower bound.
VectorXs quasiStatic_x(const boost::shared_ptr< ActionDataAbstract > &data, const VectorXs &x, const std::size_t maxiter=100, const Scalar tol=Scalar(1e-9))
std::size_t get_nr() const
Return the dimension of the cost-residual vector.
VectorXs Lx
Jacobian of the cost function.
VectorXs unone_
Neutral state.
MatrixXs Fx
Jacobian of the dynamics.
VectorXs Lu
Jacobian of the cost function.
virtual bool checkData(const boost::shared_ptr< ActionDataAbstract > &data)
Checks that a specific data belongs to this model.
ActionModelAbstractTpl(boost::shared_ptr< StateAbstract > state, const std::size_t nu, const std::size_t nr=0)
Initialize the action model.
VectorXs u_ub_
Upper control limits.
MatrixXs Luu
Hessian of the cost function.
VectorXs u_lb_
Lower control limits.
boost::shared_ptr< StateAbstract > state_
Model of the state.
virtual void quasiStatic(const boost::shared_ptr< ActionDataAbstract > &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.
virtual void calc(const boost::shared_ptr< ActionDataAbstract > &data, const Eigen::Ref< const VectorXs > &x, const Eigen::Ref< const VectorXs > &u)=0
Compute the next state and cost value.
virtual void calcDiff(const boost::shared_ptr< ActionDataAbstract > &data, const Eigen::Ref< const VectorXs > &x, const Eigen::Ref< const VectorXs > &u)=0
Compute the derivatives of the dynamics and cost functions.
virtual void print(std::ostream &os) const
Print relevant information of the action model.
MatrixXs Lxu
Hessian of the cost function.
std::size_t nr_
Dimension of the cost residual.
MatrixXs Fu
Jacobian of the dynamics.
const VectorXs & get_u_ub() const
Return the control upper bound.