34 velEst(40,0.05), biasInt(0.0,Vector(3,0.0)),
46 Vector gyroFiltered, magn;
50 yError()<<
"imuFilter: the imu is not attached";
58 yError()<<
"imuFilter: unable to get gyro";
62 if (std::fabs(gyroTs - prevTs) < 1
e-6 ){
70 yError()<<
"imuFilter: unable to get magnetometer measures";
75 double t0=Time::now();
78 gyroFiltered = gyroFilt.
filt(gyro);
81 gyroFiltered -= gyroBias;
84 Vector mag_filt=magFilt.
filt(magn);
87 adaptGyroBias=adaptGyroBias?(magVel<mag_vel_thres_up):(magVel<mag_vel_thres_down);
88 gyroBias=biasInt.
integrate(adaptGyroBias?gyroFiltered:Vector(3,0.0));
89 double dt=Time::now()-t0;
91 if (bPort.getOutputCount()>0)
93 bPort.prepare()=gyroBias;
94 bPort.setEnvelope(stampBias);
100 yInfo(
"imuFilter: magVel = %g => [%s]",magVel,adaptGyroBias?
"adapt-gyroBias":
"no-adaption");
101 yInfo(
"imuFilter: gyro = %s",gyro.toString(3,3).c_str());
102 yInfo(
"imuFilter: gyroBias = %s",gyroBias.toString(3,3).c_str());
103 yInfo(
"imuFilter: dt = %.0f [us]",dt*1e6);
119 yError()<<
"ImuFilter: failed to open proxy device";
123 string name=config.check(
"name",Value(
"imuFilter")).asString();
124 string robot=config.check(
"robot",Value(
"icub")).asString();
125 size_t gyro_order=(size_t)config.check(
"gyro-order",Value(5)).asInt32();
126 size_t mag_order=(size_t)config.check(
"mag-order",Value(51)).asInt32();
128 mag_vel_thres_up=config.check(
"mag-vel-thres-up",Value(0.04)).asFloat64();
129 mag_vel_thres_down=config.check(
"mag-vel-thres-down",Value(0.02)).asFloat64();
130 bias_gain=config.check(
"bias-gain",Value(0.001)).asFloat64();
131 verbose=config.check(
"verbose");
135 biasInt.
setTs(bias_gain);
136 gyroBias.resize(3,0.0);
139 m_period_ms=config.check(
"period",Value(20)).asInt32();
141 if (name.at(0) !=
'/')
143 ok &= bPort.open(name+
"/bias:o");
145 this->setPeriod(m_period_ms / 1000.0);
148 yError()<<
"imuFilter: failed to open the bias port";