|
From: Jon E. <el...@pi...> - 2010-10-30 17:08:55
|
Well, before I can do anything with velocity estimation, I need to just
get the
scaled velocity pin exported. I added a couple more elements to the encoder
structure :
hal_float_t *vel; /* output: scaled velocity */
hal_float_t min_speed; /* parameter: min speed for velocity
estimation */
and exported the pin to HAL :
retval = hal_pin_float_newf(HAL_OUT, &(slot->encoder[n].vel), comp_id,
"ppmc.%d.encoder.%02d.vel",bus->busnum,bus->last_encoder);
if (retval != 0) {
return retval;
}
and then wrote a value to it :
*(slot->encoder[i].delta) = pos.l - slot->encoder[i].oldreading;
*(slot->encoder[i].vel) = (pos.l - slot->encoder[i].oldreading) /
(slot->encoder[i].scale * read_period);
The first line is old code and writes out the velocity in raw encoder
counts, the second line is the new one
that writes out the velocity scaled by both linear scaling factor and
sampling period.
I see the pin and can watch it with Halscope, but the vel pin always has
a value of zero, even though the
line above produces a correct unscaled delta value.
Any ideas, have I missed something to get the value exported properly to
the HAL pin?
Jon
|