编码器用于计算轮子的移动距离。有两个问题需要解决。
1)高精度编码器太敏感,稍微抖动,会产生大量的不准确的值。
2) 计数器的溢出。
编码器抖动
用AB两项抵消抖动数据
计数器溢出
解决办法:
1)定义变量
self.encoder_min = rospy.get_param('encoder_min', -32768)
self.encoder_max = rospy.get_param('encoder_max', 32768)
self.encoder_low_wrap = rospy.get_param('wheel_low_wrap', (self.encoder_max - self.encoder_min) * 0.3 + self.encoder_min )
self.encoder_high_wrap