Wait for enough learning data before using it for quantization
namespace R2C2 {
SpeedQuantizer::SpeedQuantizer(unsigned n):
- steps(n+1)
+ steps(n+1),
+ weight_limit(10)
{
if(n<1)
throw InvalidParameterValue("Must have at leats one speed step");
{
if(i==0)
return 0;
- if(steps[i].weight)
+ if(steps[i].weight>=weight_limit)
return steps[i].speed;
unsigned low;
unsigned high;
for(low=i; low>0; --low)
- if(steps[low].weight)
+ if(steps[low].weight>=weight_limit)
break;
for(high=i; high+1<steps.size(); ++high)
- if(steps[high].weight)
+ if(steps[high].weight>=weight_limit)
break;
if(steps[high].weight)
unsigned high = 0;
unsigned last = 0;
for(unsigned i=0; (!high && i<steps.size()); ++i)
- if(steps[i].weight)
+ if(steps[i].weight>=weight_limit)
{
last = i;
if(steps[i].speed>=speed)
};
std::vector<SpeedStep> steps;
+ float weight_limit;
public:
SpeedQuantizer(unsigned);
// Compute speed and update related state
float travel_time_secs = (Time::now()-last_entry_time)/Time::sec;
- if(pure_speed && speed_quantizer && current_speed_step>0)
+ if(pure_speed && speed_quantizer && current_speed_step>0 && travel_time_secs>=2)
speed_quantizer->learn(current_speed_step, travel_dist/travel_time_secs, travel_time_secs);
travel_dist = 0;