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>
38 class ResidualModelAbstractTpl {
40 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
42 typedef _Scalar Scalar;
43 typedef MathBaseTpl<Scalar> MathBase;
44 typedef ResidualDataAbstractTpl<Scalar> ResidualDataAbstract;
45 typedef StateAbstractTpl<Scalar> StateAbstract;
46 typedef DataCollectorAbstractTpl<Scalar> DataCollectorAbstract;
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);
75 ResidualModelAbstractTpl(boost::shared_ptr<StateAbstract> state,
const std::size_t nr,
const bool q_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);
111 virtual boost::shared_ptr<ResidualDataAbstract>
createData(DataCollectorAbstract*
const data);
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;
137 std::size_t
get_nr()
const;
142 std::size_t
get_nu()
const;
162 template <
class Scalar>
163 friend std::ostream& operator<<(std::ostream& os, const ResidualModelAbstractTpl<Scalar>& model);
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()) {
202 virtual ~ResidualDataAbstractTpl() {}
215 #include "crocoddyl/core/residual-base.hxx" 217 #endif // CROCODDYL_CORE_RESIDUAL_BASE_HPP_ bool get_v_dependent() const
Return true if the residual function depends on v.
std::size_t nr_
Residual vector dimension.
bool get_u_dependent() const
Return true if the residual function depends on u.
bool q_dependent_
Label that indicates if the residual function depends on q.
bool u_dependent_
Label that indicates if the residual function depends on u.
const boost::shared_ptr< StateAbstract > & get_state() const
Return the state.
std::size_t get_nr() const
Return the dimension of the residual vector.
virtual boost::shared_ptr< ResidualDataAbstract > createData(DataCollectorAbstract *const data)
Create the residual data.
std::size_t nu_
Control dimension.
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.
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.
MatrixXs Rx
Jacobian of the residual vector with respect the state.
MatrixXs Ru
Jacobian of the residual vector with respect the control.
bool get_q_dependent() const
Return true if the residual function depends on q.
virtual void print(std::ostream &os) const
Print relevant information of the residual model.
boost::shared_ptr< StateAbstract > state_
State description.
std::size_t get_nu() const
Return the dimension of the control input.
VectorXs unone_
No control vector.
bool v_dependent_
Label that indicates if the residual function depends on v.
VectorXs r
Residual vector.
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.
DataCollectorAbstract * shared
Shared data allocated by the action model.