14 #include <dynamic-graph/factory.h>    22 namespace dg = ::dynamicgraph;
    27 #define PROFILE_ADMITTANCECONTROLOPPOINT_WFORCE_COMPUTATION \    28   "AdmittanceControlOpPoint: w_force computation   "    30 #define PROFILE_ADMITTANCECONTROLOPPOINT_WDQ_COMPUTATION \    31   "AdmittanceControlOpPoint: w_dq computation      "    33 #define PROFILE_ADMITTANCECONTROLOPPOINT_DQ_COMPUTATION \    34   "AdmittanceControlOpPoint: dq computation        "    36 #define INPUT_SIGNALS                                                      \    37   m_KpSIN << m_KdSIN << m_dqSaturationSIN << m_forceSIN << m_w_forceDesSIN \    38           << m_opPoseSIN << m_sensorPoseSIN    40 #define INNER_SIGNALS m_w_forceSINNER << m_w_dqSINNER    42 #define OUTPUT_SIGNALS m_dqSOUT    50                                    "AdmittanceControlOpPoint");
    68       m_initSucceeded(false) {
    81   if (!m_dqSaturationSIN.isPlugged())
    82     return SEND_MSG(
"Init failed: signal dqSaturation is not plugged",
    84   if (!m_KpSIN.isPlugged())
    86   if (!m_KdSIN.isPlugged())
    88   if (!m_forceSIN.isPlugged())
    90   if (!m_w_forceDesSIN.isPlugged())
    91     return SEND_MSG(
"Init failed: signal w_forceDes is not plugged",
    93   if (!m_opPoseSIN.isPlugged())
    94     return SEND_MSG(
"Init failed: signal opPose is not plugged",
    96   if (!m_sensorPoseSIN.isPlugged())
    97     return SEND_MSG(
"Init failed: signal sensorPose is not plugged",
   117         "Cannot compute signal w_force before initialization!");
   120   if (
s.size() != 6) 
s.resize(6);
   124   const Vector &force = m_forceSIN(iter);
   126   assert(force.size() == 
m_n && 
"Unexpected size of signal force");
   128       sensorPose.matrix());  
   139         "Cannot compute signal w_dq before initialization!");
   142   if (
s.size() != 6) 
s.resize(6);
   146   const Vector &w_forceDes = m_w_forceDesSIN(iter);
   147   const Vector &w_force = m_w_forceSINNER(iter);
   148   const Vector &Kp = m_KpSIN(iter);
   149   const Vector &Kd = m_KdSIN(iter);
   150   const Vector &dqSaturation = m_dqSaturationSIN(iter);
   151   assert(w_force.size() == 
m_n && 
"Unexpected size of signal force");
   152   assert(w_forceDes.size() == 
m_n && 
"Unexpected size of signal w_forceDes");
   153   assert(Kp.size() == 
m_n && 
"Unexpected size of signal Kp");
   154   assert(Kd.size() == 
m_n && 
"Unexpected size of signal Kd");
   155   assert(dqSaturation.size() == 
m_n &&
   156          "Unexpected size of signal dqSaturation");
   158   m_w_dq = m_w_dq + 
m_dt * (Kp.cwiseProduct(w_forceDes - w_force)) -
   159            Kd.cwiseProduct(m_w_dq);
   161   for (
int i = 0; 
i < 
m_n; 
i++) {
   162     if (m_w_dq[
i] > dqSaturation[
i]) m_w_dq[i] = dqSaturation[i];
   163     if (m_w_dq[i] < -dqSaturation[i]) m_w_dq[i] = -dqSaturation[i];
   178   if (
s.size() != 6) 
s.resize(6);
   182   const Vector &w_dq = m_w_dqSINNER(iter);
   184   assert(w_dq.size() == 
m_n && 
"Unexpected size of signal w_dq");
   200   os << 
"AdmittanceControlOpPoint " << 
getName();
 Eigen::Transform< double, 3, Eigen::Affine > SOT_CORE_EXPORT MatrixHomogeneous
CommandVoid0< E > * makeCommandVoid0(E &entity, boost::function< void(void)> function, const std::string &docString)
Admittance controller for an operational point wrt to a force sensor. It can be a point of the model ...
void stop(std::string perf_name)
#define PROFILE_ADMITTANCECONTROLOPPOINT_DQ_COMPUTATION
void signalRegistration(const SignalArray< int > &signals)
#define CONSTRUCT_SIGNAL_IN(name, type)
CommandVoid1< E, T > * makeCommandVoid1(E &entity, boost::function< void(const T &)> function, const std::string &docString)
bool m_initSucceeded
True if the entity has been successfully initialized. 
std::string docCommandVoid1(const std::string &doc, const std::string &type)
EIGEN_MAKE_ALIGNED_OPERATOR_NEW AdmittanceControlOpPoint(const std::string &name)
DEFINE_SIGNAL_OUT_FUNCTION(dq, dynamicgraph::Vector)
std::string docCommandVoid0(const std::string &doc)
void init(const double &dt)
Initialize the entity. 
dynamicgraph::Vector m_w_dq
Internal state. 
int m_n
Dimension of the force signals and of the output. 
#define SEND_MSG(msg, type)
#define CONSTRUCT_SIGNAL_OUT(name, type, dep)
#define CONSTRUCT_SIGNAL_INNER(name, type, dep)
Stopwatch & getProfiler()
virtual void display(std::ostream &os) const
DEFINE_SIGNAL_INNER_FUNCTION(w_force, dynamicgraph::Vector)
const std::string & getName() const
DYNAMICGRAPH_FACTORY_ENTITY_PLUGIN(AdmittanceControlOpPoint, "AdmittanceControlOpPoint")
#define SEND_WARNING_STREAM_MSG(msg)
void start(std::string perf_name)
double m_dt
Time step of the control. 
void resetDq()
Reset the velocity. 
AdmittanceControlOpPoint EntityClassName
void addCommand(const std::string &name, command::Command *command)
#define PROFILE_ADMITTANCECONTROLOPPOINT_WFORCE_COMPUTATION
void report_all(int precision=2, std::ostream &output=std::cout)
#define PROFILE_ADMITTANCECONTROLOPPOINT_WDQ_COMPUTATION