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 calcDiff(
const boost::shared_ptr<ResidualDataAbstract>& data,
const Eigen::Ref<const VectorXs>& x,
99 const Eigen::Ref<const VectorXs>& u);
119 void calc(
const boost::shared_ptr<ResidualDataAbstract>& data,
const Eigen::Ref<const VectorXs>& x);
127 void calcDiff(
const boost::shared_ptr<ResidualDataAbstract>& data,
const Eigen::Ref<const VectorXs>& x);
132 const boost::shared_ptr<StateAbstract>&
get_state()
const;
162 template <
class Scalar>
170 virtual void print(std::ostream& os)
const;
182 template <
typename _Scalar>
184 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
186 typedef _Scalar Scalar;
189 typedef typename MathBase::VectorXs VectorXs;
190 typedef typename MathBase::MatrixXs MatrixXs;
192 template <
template <
typename Scalar>
class Model>
196 Rx(model->get_nr(), model->get_state()->get_ndx()),
197 Ru(model->get_nr(), model->get_nu()) {
215 #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.
void calcDiff(const boost::shared_ptr< ResidualDataAbstract > &data, const Eigen::Ref< const VectorXs > &x)
Compute the Jacobian of the residual vector.
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.
void calc(const boost::shared_ptr< ResidualDataAbstract > &data, const Eigen::Ref< const VectorXs > &x)
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.