19 #include <dynamic-graph/all-commands.h>
20 #include <dynamic-graph/command-bind.h>
21 #include <dynamic-graph/factory.h>
23 #include <sot/core/debug.hh>
24 #include <sot/core/stop-watch.hh>
28 namespace talos_balance {
29 namespace dg = ::dynamicgraph;
31 using namespace dg::command;
36 #define PROFILE_SATURATION_SOUT_COMPUTATION "Saturation: sOut computation"
38 #define INPUT_SIGNALS m_xSIN << m_ySIN << m_kSIN << m_xLimSIN << m_yLimSIN
40 #define OUTPUT_SIGNALS m_yOutSOUT
56 CONSTRUCT_SIGNAL_IN(k, double),
70 const double &
x = m_xSIN(iter)[0];
72 const double &
y = s[0];
73 const double &k = m_kSIN(iter);
74 const double &xLim = m_xLimSIN(iter)[0];
75 const double &yLim = m_yLimSIN(iter)[0];
79 assert(k > 0 &&
"k must be strictly positive");
80 assert(xLim > 0 &&
"xLim must be strictly positive");
81 assert(yLim > 0 &&
"yLim must be strictly positive");
83 if ((
x <= -xLim) or (
x > xLim)) {
85 }
else if (-xLim + yLim / k <
x and
x <= xLim - yLim / k) {
86 r = std::min(std::max(
y, -yLim), yLim);
87 }
else if (-xLim <
x and
x <= -xLim + yLim / k) {
88 r = std::min(std::max(
y, -k * (
x + xLim)), k * (
x + xLim));
89 }
else if (xLim - yLim / k <
x and
x <= xLim) {
90 r = std::min(std::max(
y, -yLim + k * (
x - xLim + yLim / k)),
91 yLim - k * (
x - xLim + yLim / k));
108 os <<
"Saturation " << getName();
110 getProfiler().report_all(3, os);
111 }
catch (ExceptionSignal e) {