9 #ifndef CROCODDYL_CORE_RESIDUAL_BASE_HPP_
10 #define CROCODDYL_CORE_RESIDUAL_BASE_HPP_
12 #include "crocoddyl/core/activation-base.hpp"
13 #include "crocoddyl/core/cost-base.hpp"
14 #include "crocoddyl/core/data-collector-base.hpp"
15 #include "crocoddyl/core/fwd.hpp"
16 #include "crocoddyl/core/state-base.hpp"
47 template <
typename _Scalar>
50 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
53 typedef _Scalar Scalar;
60 typedef typename MathBase::VectorXs VectorXs;
61 typedef typename MathBase::MatrixXs MatrixXs;
62 typedef typename MathBase::DiagonalMatrixXs DiagonalMatrixXs;
78 const std::size_t nr,
const std::size_t nu,
79 const bool q_dependent =
true,
80 const bool v_dependent =
true,
81 const bool u_dependent =
true);
98 const std::size_t nr,
const bool q_dependent =
true,
99 const bool v_dependent =
true,
100 const bool u_dependent =
true);
110 virtual void calc(
const std::shared_ptr<ResidualDataAbstract>& data,
111 const Eigen::Ref<const VectorXs>& x,
112 const Eigen::Ref<const VectorXs>& u);
123 virtual void calc(
const std::shared_ptr<ResidualDataAbstract>& data,
124 const Eigen::Ref<const VectorXs>& x);
136 virtual void calcDiff(
const std::shared_ptr<ResidualDataAbstract>& data,
137 const Eigen::Ref<const VectorXs>& x,
138 const Eigen::Ref<const VectorXs>& u);
150 virtual void calcDiff(
const std::shared_ptr<ResidualDataAbstract>& data,
151 const Eigen::Ref<const VectorXs>& x);
180 const std::shared_ptr<CostDataAbstract>& cdata,
181 const std::shared_ptr<ResidualDataAbstract>& rdata,
182 const std::shared_ptr<ActivationDataAbstract>& adata,
183 const bool update_u =
true);
188 const std::shared_ptr<StateAbstract>&
get_state()
const;
218 template <
class Scalar>
227 virtual void print(std::ostream& os)
const;
249 template <
typename _Scalar>
251 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
253 typedef _Scalar Scalar;
256 typedef typename MathBase::VectorXs VectorXs;
257 typedef typename MathBase::MatrixXs MatrixXs;
259 template <
template <
typename Scalar>
class Model>
264 Rx(model->get_nr(), model->get_state()->get_ndx()),
265 Ru(model->get_nr(), model->get_nu()),
266 Arr_Rx(model->get_nr(), model->get_state()->get_ndx()),
267 Arr_Ru(model->get_nr(), model->get_nu()) {
289 #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)
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.