crocoddyl 1.9.0
Contact RObot COntrol by Differential DYnamic programming Library (Crocoddyl)
 
Loading...
Searching...
No Matches
actuation-base.hpp
1
2// BSD 3-Clause License
3//
4// Copyright (C) 2019-2021, LAAS-CNRS, University of Edinburgh
5// Copyright note valid unless otherwise stated in individual files.
6// All rights reserved.
8
9#ifndef CROCODDYL_CORE_ACTUATION_BASE_HPP_
10#define CROCODDYL_CORE_ACTUATION_BASE_HPP_
11
12#include <stdexcept>
13#include <boost/shared_ptr.hpp>
14#include <boost/make_shared.hpp>
15
16#include "crocoddyl/core/fwd.hpp"
17#include "crocoddyl/core/mathbase.hpp"
18#include "crocoddyl/core/state-base.hpp"
19#include "crocoddyl/core/utils/exception.hpp"
20
21namespace crocoddyl {
22
38template <typename _Scalar>
40 public:
41 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
42
43 typedef _Scalar Scalar;
47 typedef typename MathBase::VectorXs VectorXs;
48 typedef typename MathBase::MatrixXs MatrixXs;
49
56 ActuationModelAbstractTpl(boost::shared_ptr<StateAbstract> state, const std::size_t nu);
58
67 virtual void calc(const boost::shared_ptr<ActuationDataAbstract>& data, const Eigen::Ref<const VectorXs>& x,
68 const Eigen::Ref<const VectorXs>& u) = 0;
69
79 void calc(const boost::shared_ptr<ActuationDataAbstract>& data, const Eigen::Ref<const VectorXs>& x);
80
88 virtual void calcDiff(const boost::shared_ptr<ActuationDataAbstract>& data, const Eigen::Ref<const VectorXs>& x,
89 const Eigen::Ref<const VectorXs>& u) = 0;
90
100 void calcDiff(const boost::shared_ptr<ActuationDataAbstract>& data, const Eigen::Ref<const VectorXs>& x);
101
107 virtual boost::shared_ptr<ActuationDataAbstract> createData();
108
112 std::size_t get_nu() const;
113
117 const boost::shared_ptr<StateAbstract>& get_state() const;
118
122 template <class Scalar>
123 friend std::ostream& operator<<(std::ostream& os, const ResidualModelAbstractTpl<Scalar>& model);
124
130 virtual void print(std::ostream& os) const;
131
132 protected:
133 std::size_t nu_;
134 boost::shared_ptr<StateAbstract> state_;
135};
136
137template <typename _Scalar>
139 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
140
141 typedef _Scalar Scalar;
143 typedef typename MathBase::VectorXs VectorXs;
144 typedef typename MathBase::MatrixXs MatrixXs;
145
146 template <template <typename Scalar> class Model>
147 explicit ActuationDataAbstractTpl(Model<Scalar>* const model)
148 : tau(model->get_state()->get_nv()),
149 dtau_dx(model->get_state()->get_nv(), model->get_state()->get_ndx()),
150 dtau_du(model->get_state()->get_nv(), model->get_nu()) {
151 tau.setZero();
152 dtau_dx.setZero();
153 dtau_du.setZero();
154 }
155 virtual ~ActuationDataAbstractTpl() {}
156
157 VectorXs tau;
158 MatrixXs dtau_dx;
159 MatrixXs dtau_du;
160};
161
162} // namespace crocoddyl
163
164/* --- Details -------------------------------------------------------------- */
165/* --- Details -------------------------------------------------------------- */
166/* --- Details -------------------------------------------------------------- */
167#include "crocoddyl/core/actuation-base.hxx"
168
169#endif // CROCODDYL_CORE_ACTUATION_BASE_HPP_
Abstract class for the actuation-mapping model.
virtual void calc(const boost::shared_ptr< ActuationDataAbstract > &data, const Eigen::Ref< const VectorXs > &x, const Eigen::Ref< const VectorXs > &u)=0
Compute the actuation signal from the state point and control input .
virtual boost::shared_ptr< ActuationDataAbstract > createData()
Create the actuation data.
friend std::ostream & operator<<(std::ostream &os, const ResidualModelAbstractTpl< Scalar > &model)
Print information on the residual model.
void calc(const boost::shared_ptr< ActuationDataAbstract > &data, const Eigen::Ref< const VectorXs > &x)
Ignore the computation of the actuation signal.
virtual void print(std::ostream &os) const
Print relevant information of the residual model.
void calcDiff(const boost::shared_ptr< ActuationDataAbstract > &data, const Eigen::Ref< const VectorXs > &x)
Ignore the computation of the Jacobians of the actuation function.
const boost::shared_ptr< StateAbstract > & get_state() const
Return the state.
boost::shared_ptr< StateAbstract > state_
Model of the state.
virtual void calcDiff(const boost::shared_ptr< ActuationDataAbstract > &data, const Eigen::Ref< const VectorXs > &x, const Eigen::Ref< const VectorXs > &u)=0
Compute the Jacobians of the actuation function.
std::size_t nu_
Control dimension.
std::size_t get_nu() const
Return the dimension of the control input.
ActuationModelAbstractTpl(boost::shared_ptr< StateAbstract > state, const std::size_t nu)
Initialize the actuation model.
Abstract class for residual models.
Abstract class for the state representation.
Definition: state-base.hpp:42
MatrixXs dtau_dx
Partial derivatives of the actuation model w.r.t. the state point.
VectorXs tau
Actuation (generalized force) signal.
MatrixXs dtau_du
Partial derivatives of the actuation model w.r.t. the control input.