I was trying to understand multiwii quadcopter code. I started with understanding GPS code. Here is a section of the code where I have doubt. Why actual position = pos + velocity contribution + acceleration contribution ? I mean velocity contribution and acceleration contribution, both are the same thing (I Think). So what is the purpose of adding both vel contribution and acceleration contribution ?
Here is the section of the code:
class LeadFilter {
public:
LeadFilter() :
_last_velocity(0) {
}
// setup min and max radio values in CLI
int32_t get_position(int32_t pos, int16_t vel, float lag_in_seconds = 1.0);
void clear() { _last_velocity = 0; }
private:
int16_t _last_velocity;
};
int32_t LeadFilter::get_position(int32_t pos, int16_t vel, float lag_in_seconds)
{
int16_t accel_contribution = (vel - _last_velocity) * lag_in_seconds * lag_in_seconds;
int16_t vel_contribution = vel * lag_in_seconds;
// store velocity for next iteration
_last_velocity = vel;
return pos + vel_contribution + accel_contribution;
}