9 #ifndef CROCODDYL_CORE_RESIDUAL_BASE_HPP_
10 #define CROCODDYL_CORE_RESIDUAL_BASE_HPP_
12 #include <boost/shared_ptr.hpp>
13 #include <boost/make_shared.hpp>
15 #include "crocoddyl/core/fwd.hpp"
16 #include "crocoddyl/core/state-base.hpp"
17 #include "crocoddyl/core/data-collector-base.hpp"
37 template <
typename _Scalar>
40 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
42 typedef _Scalar Scalar;
47 typedef typename MathBase::VectorXs VectorXs;
48 typedef typename MathBase::MatrixXs MatrixXs;
61 const bool q_dependent =
true,
const bool v_dependent =
true,
62 const bool u_dependent =
true);
76 const bool v_dependent =
true,
const bool u_dependent =
true);
86 virtual void calc(
const boost::shared_ptr<ResidualDataAbstract>& data,
const Eigen::Ref<const VectorXs>& x,
87 const Eigen::Ref<const VectorXs>& u);
98 virtual void calc(
const boost::shared_ptr<ResidualDataAbstract>& data,
const Eigen::Ref<const VectorXs>& x);
109 virtual void calcDiff(
const boost::shared_ptr<ResidualDataAbstract>& data,
const Eigen::Ref<const VectorXs>& x,
110 const Eigen::Ref<const VectorXs>& u);
121 virtual void calcDiff(
const boost::shared_ptr<ResidualDataAbstract>& data,
const Eigen::Ref<const VectorXs>& x);
138 const boost::shared_ptr<StateAbstract>&
get_state()
const;
168 template <
class Scalar>
176 virtual void print(std::ostream& os)
const;
188 template <
typename _Scalar>
190 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
192 typedef _Scalar Scalar;
195 typedef typename MathBase::VectorXs VectorXs;
196 typedef typename MathBase::MatrixXs MatrixXs;
198 template <
template <
typename Scalar>
class Model>
202 Rx(model->get_nr(), model->get_state()->get_ndx()),
203 Ru(model->get_nr(), model->get_nu()) {
221 #include "crocoddyl/core/residual-base.hxx"
Abstract class for residual models.
ResidualModelAbstractTpl(boost::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.
bool get_q_dependent() const
Return true if the residual function depends on q.
const boost::shared_ptr< StateAbstract > & get_state() const
Return the state.
virtual void calc(const boost::shared_ptr< ResidualDataAbstract > &data, const Eigen::Ref< const VectorXs > &x)
Compute the residual vector for nodes that depends only on the state.
virtual void calcDiff(const boost::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 print(std::ostream &os) const
Print relevant information of the residual model.
ResidualModelAbstractTpl(boost::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.
bool u_dependent_
Label that indicates if the residual function depends on u.
virtual void calc(const boost::shared_ptr< ResidualDataAbstract > &data, const Eigen::Ref< const VectorXs > &x, const Eigen::Ref< const VectorXs > &u)
Compute the residual vector.
friend std::ostream & operator<<(std::ostream &os, const ResidualModelAbstractTpl< Scalar > &model)
Print information on the residual model.
bool get_v_dependent() const
Return true if the residual function depends on v.
boost::shared_ptr< StateAbstract > state_
State description.
std::size_t nu_
Control dimension.
virtual void calcDiff(const boost::shared_ptr< ResidualDataAbstract > &data, const Eigen::Ref< const VectorXs > &x, const Eigen::Ref< const VectorXs > &u)
Compute the Jacobian of the residual vector.
VectorXs unone_
No control vector.
bool q_dependent_
Label that indicates if the residual function depends on q.
std::size_t nr_
Residual vector dimension.
virtual boost::shared_ptr< ResidualDataAbstract > createData(DataCollectorAbstract *const data)
Create the residual data.
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.
bool v_dependent_
Label that indicates if the residual function depends on v.
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.