23#include <yarp/os/Bottle.h>
24#include <yarp/math/Math.h>
29using namespace yarp::os;
30using namespace yarp::sig;
31using namespace yarp::math;
57 for (
size_t i=0; i<
F.size(); i++)
71 enabled=options.check(
"smith_predictor",Value(
"off")).asString()==
"on";
78 Vector Kp(chain.
getDOF(),1.0);
79 Vector Tz(chain.
getDOF(),0.0);
80 Vector Tw(chain.
getDOF(),0.0);
81 Vector Zeta(chain.
getDOF(),0.0);
82 for (
unsigned int i=0; i<chain.
getDOF(); i++)
85 double Ts=options.check(
"Ts",Value(0.01)).asFloat64();
87 Matrix lim(chain.
getDOF(),2);
93 for (
unsigned int j=0; j<chain.
getN(); j++)
95 if (!chain[j].isBlocked())
98 lim(i,0)=chain[j].getMin();
99 lim(i,1)=chain[j].getMax();
103 string entry_str(entry.str());
104 if (options.check(entry_str))
106 if (Bottle *params=options.find(entry_str).asList())
108 if (params->check(
"Kp"))
109 Kp[i]=params->find(
"Kp").asFloat64();
111 if (params->check(
"Tz"))
112 Tz[i]=params->find(
"Tz").asFloat64();
114 if (params->check(
"Tw"))
115 Tw[i]=params->find(
"Tw").asFloat64();
117 if (params->check(
"Zeta"))
118 Zeta[i]=params->find(
"Zeta").asFloat64();
120 if (params->check(
"Td"))
122 int depth=(int)ceil(params->find(
"Td").asFloat64()/Ts);
143 double twoTs2=2.0*Ts2;
144 for (
unsigned int i=0; i<chain.
getDOF(); i++)
147 double _num_0=2.0*Tz[i]*Ts;
148 num[0]=Kp[i] * (Ts2 + _num_0);
149 num[1]=Kp[i] * twoTs2;
150 num[2]=Kp[i] * (Ts2 - _num_0);
152 double _den_0=4.0*Tw[i]*Tw[i];
153 double _den_1=2.0*_den_0;
154 double _den_2=4.0*Zeta[i]*Ts*Tw[i];
155 den[0]=Ts2 + _den_2 + _den_0;
156 den[1]=twoTs2 - _den_1;
157 den[2]=Ts2 - _den_2 + _den_0;
160 F.push_back(
new Filter(num,den,y01));
183 for (
size_t i=0; i<
F.size(); i++)
198 for (
size_t i=0; i<
F.size(); i++)
200 Vector u1(1); u1[0]=u[i];
201 Vector _y=
F[i]->filt(u1);
206 Vector
out(
y.length());
207 for (
size_t i=0; i<
out.length(); i++)
217 return zeros((
int)u.length());
std::deque< std::deque< double > * > tappedDelays
void configure(const yarp::os::Property &options, iCub::iKin::iKinChain &chain)
yarp::sig::Vector computeCmd(const yarp::sig::Vector &u)
std::deque< iCub::ctrl::Filter * > F
iCub::ctrl::Integrator * I
void restart(const yarp::sig::Vector &y0)
A class for defining a saturated integrator based on Tustin formula: .
const yarp::sig::Vector & get() const
Returns the current output vector.
const yarp::sig::Vector & integrate(const yarp::sig::Vector &x)
Executes one-step integration of input vector.
void reset(const yarp::sig::Vector &y0)
Resets the internal state and sets the output vector to the given value.
A Base class for defining a Serial Link Chain.
yarp::sig::Vector getAng()
Returns the current free joint angles values.
unsigned int getN() const
Returns the number of Links belonging to the Chain.
unsigned int getDOF() const
Returns the current number of Chain's DOF.