Пример #1
0
 def update_averages(self,unused_event):
     wind = self.windsensor.angle
     smoothing = self.config['smoothing']
     self._wind_relative_avg = moving_avg(self._wind_relative_avg,wind,smoothing)
     self._compass_avg = moving_avg(self._compass_avg, self._compass_smoothed, smoothing)
     self._calculate_rate_of_turn(self._compass_smoothed)
     rate_of_turn_diff = self._rate_of_turn-self._rate_of_turn_average
     self._rate_of_turn_average += rate_of_turn_diff/smoothing
Пример #2
0
 def update_averages(self, unused_event):
     wind = self.windsensor.angle
     smoothing = self.config['smoothing']
     self._wind_relative_avg = moving_avg(self._wind_relative_avg, wind,
                                          smoothing)
     self._compass_avg = moving_avg(self._compass_avg,
                                    self._compass_smoothed, smoothing)
     self._calculate_rate_of_turn(self._compass_smoothed)
     rate_of_turn_diff = self._rate_of_turn - self._rate_of_turn_average
     self._rate_of_turn_average += rate_of_turn_diff / smoothing
Пример #3
0
 def update_compass_smoothed(self, unused_event):
     self._compass_smoothed = moving_avg(self._compass_smoothed, self.compass.bearing, self.config['compass smoothing'])
Пример #4
0
 def update_compass_smoothed(self, unused_event):
     self._compass_smoothed = moving_avg(self._compass_smoothed,
                                         self.compass.bearing,
                                         self.config['compass smoothing'])
Пример #5
0
 def test_moving_average_should_move_the_average_anitclockwise_if_next_sample_less(self):
     self.assertEqual(moving_avg(20,10,2),15)
     self.assertEqual(moving_avg(180,10,2),95)
     self.assertEqual(moving_avg(355.0,180.0,2),267.5)
     self.assertEqual(moving_avg(20,350.0,6),15.0)
Пример #6
0
 def test_moving_average_should_move_the_average_clockwise_if_next_sample_greater(self):
     self.assertEqual(moving_avg(10,20,2),15)
     self.assertEqual(moving_avg(10,180,2),95)
     self.assertEqual(moving_avg(180.0,355.0,2),267.5)
     self.assertEqual(moving_avg(340,20.0,2),0.0)