9 #ifndef CROCODDYL_CORE_RESIDUAL_BASE_HPP_
10 #define CROCODDYL_CORE_RESIDUAL_BASE_HPP_
12 #include <boost/make_shared.hpp>
15 #include "crocoddyl/core/activation-base.hpp"
16 #include "crocoddyl/core/cost-base.hpp"
17 #include "crocoddyl/core/data-collector-base.hpp"
18 #include "crocoddyl/core/fwd.hpp"
19 #include "crocoddyl/core/state-base.hpp"
43 template <
typename _Scalar>
46 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
48 typedef _Scalar Scalar;
55 typedef typename MathBase::VectorXs VectorXs;
56 typedef typename MathBase::MatrixXs MatrixXs;
57 typedef typename MathBase::DiagonalMatrixXs DiagonalMatrixXs;
73 const std::size_t nr,
const std::size_t nu,
74 const bool q_dependent =
true,
75 const bool v_dependent =
true,
76 const bool u_dependent =
true);
93 const std::size_t nr,
const bool q_dependent =
true,
94 const bool v_dependent =
true,
95 const bool u_dependent =
true);
105 virtual void calc(
const std::shared_ptr<ResidualDataAbstract>& data,
106 const Eigen::Ref<const VectorXs>& x,
107 const Eigen::Ref<const VectorXs>& u);
118 virtual void calc(
const std::shared_ptr<ResidualDataAbstract>& data,
119 const Eigen::Ref<const VectorXs>& x);
131 virtual void calcDiff(
const std::shared_ptr<ResidualDataAbstract>& data,
132 const Eigen::Ref<const VectorXs>& x,
133 const Eigen::Ref<const VectorXs>& u);
145 virtual void calcDiff(
const std::shared_ptr<ResidualDataAbstract>& data,
146 const Eigen::Ref<const VectorXs>& x);
175 const std::shared_ptr<CostDataAbstract>& cdata,
176 const std::shared_ptr<ResidualDataAbstract>& rdata,
177 const std::shared_ptr<ActivationDataAbstract>& adata,
178 const bool update_u =
true);
183 const std::shared_ptr<StateAbstract>&
get_state()
const;
213 template <
class Scalar>
222 virtual void print(std::ostream& os)
const;
237 template <
typename _Scalar>
239 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
241 typedef _Scalar Scalar;
244 typedef typename MathBase::VectorXs VectorXs;
245 typedef typename MathBase::MatrixXs MatrixXs;
247 template <
template <
typename Scalar>
class Model>
252 Rx(model->get_nr(), model->get_state()->get_ndx()),
253 Ru(model->get_nr(), model->get_nu()),
254 Arr_Rx(model->get_nr(), model->get_state()->get_ndx()),
255 Arr_Ru(model->get_nr(), model->get_nu()) {
277 #include "crocoddyl/core/residual-base.hxx"
Abstract class for residual models.
bool get_q_dependent() const
Return true if the residual function depends on q.
virtual void calcDiff(const std::shared_ptr< ResidualDataAbstract > &data, const Eigen::Ref< const VectorXs > &x, const Eigen::Ref< const VectorXs > &u)
Compute the Jacobian of the residual vector.
std::shared_ptr< StateAbstract > state_
State description.
ResidualModelAbstractTpl(std::shared_ptr< StateAbstract > state, const std::size_t nr, const std::size_t nu, const bool q_dependent=true, const bool v_dependent=true, const bool u_dependent=true)
Initialize the residual model.
virtual void print(std::ostream &os) const
Print relevant information of the residual model.
virtual void calcDiff(const std::shared_ptr< ResidualDataAbstract > &data, const Eigen::Ref< const VectorXs > &x)
Compute the Jacobian of the residual functions with respect to the state only.
virtual void calcCostDiff(const std::shared_ptr< CostDataAbstract > &cdata, const std::shared_ptr< ResidualDataAbstract > &rdata, const std::shared_ptr< ActivationDataAbstract > &adata, const bool update_u=true)
Compute the derivative of the cost function.
friend std::ostream & operator<<(std::ostream &os, const ResidualModelAbstractTpl< Scalar > &model)
Print information on the residual model.
virtual void calc(const std::shared_ptr< ResidualDataAbstract > &data, const Eigen::Ref< const VectorXs > &x, const Eigen::Ref< const VectorXs > &u)
Compute the residual vector.
bool get_v_dependent() const
Return true if the residual function depends on v.
virtual void calc(const std::shared_ptr< ResidualDataAbstract > &data, const Eigen::Ref< const VectorXs > &x)
Compute the residual vector for nodes that depends only on the state.
const std::shared_ptr< StateAbstract > & get_state() const
Return the state.
std::size_t nu_
Control dimension.
virtual std::shared_ptr< ResidualDataAbstract > createData(DataCollectorAbstract *const data)
Create the residual data.
ResidualModelAbstractTpl(std::shared_ptr< StateAbstract > state, const std::size_t nr, const bool q_dependent=true, const bool v_dependent=true, const bool u_dependent=true)
Initialize the residual model.
VectorXs unone_
No control vector.
std::size_t nr_
Residual vector dimension.
bool get_u_dependent() const
Return true if the residual function depends on u.
std::size_t get_nr() const
Return the dimension of the residual vector.
std::size_t get_nu() const
Return the dimension of the control input.
Abstract class for the state representation.
MatrixXs Ru
Jacobian of the residual vector with respect the control.
MatrixXs Rx
Jacobian of the residual vector with respect the state.
DataCollectorAbstract * shared
Shared data allocated by the action model.
VectorXs r
Residual vector.