Skip to content

Commit 1406330

Browse files
committed
Truncate number of digits sent for dist per rot
Truncates the distance moved per rotation to five decimal places to prevent overflow on the Arduino side. This fixes the chain tolerance settings
1 parent 1ba4d44 commit 1406330

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

main.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -175,18 +175,18 @@ def computeSettings(self, section, key, value):
175175

176176
if self.config.has_option('Advanced Settings', 'leftChainTolerance'):
177177
distPerRotLeftChainTolerance = (1 + (float(self.config.get('Advanced Settings', 'leftChainTolerance')) / 100)) * float(self.config.get('Advanced Settings', 'gearTeeth')) * float(self.config.get('Advanced Settings', 'chainPitch'))
178-
self.config.set('Computed Settings', "distPerRotLeftChainTolerance", str(distPerRotLeftChainTolerance))
178+
self.config.set('Computed Settings', "distPerRotLeftChainTolerance", str("{0:.5f}".format(distPerRotLeftChainTolerance)))
179179
if self.config.has_option('Advanced Settings', 'rightChainTolerance'):
180180
distPerRotRightChainTolerance = (1 + (float(self.config.get('Advanced Settings', 'rightChainTolerance')) / 100)) * float(self.config.get('Advanced Settings', 'gearTeeth')) * float(self.config.get('Advanced Settings', 'chainPitch'))
181-
self.config.set('Computed Settings', "distPerRotRightChainTolerance", str(distPerRotRightChainTolerance))
181+
self.config.set('Computed Settings', "distPerRotRightChainTolerance", str("{0:.5f}".format(distPerRotRightChainTolerance)))
182182

183183
elif key == 'leftChainTolerance' and self.config.has_option('Advanced Settings', 'leftChainTolerance') and self.config.has_option('Computed Settings', 'distPerRot'):
184184
distPerRotLeftChainTolerance = (1 + (float(self.config.get('Advanced Settings', 'leftChainTolerance')) / 100)) * float(self.config.get('Computed Settings', 'distPerRot'))
185-
self.config.set('Computed Settings', "distPerRotLeftChainTolerance", str(distPerRotLeftChainTolerance))
185+
self.config.set('Computed Settings', "distPerRotLeftChainTolerance", str("{0:.5f}".format(distPerRotLeftChainTolerance)))
186186

187187
elif key == 'rightChainTolerance' and self.config.has_option('Advanced Settings', 'rightChainTolerance') and self.config.has_option('Computed Settings', 'distPerRot'):
188188
distPerRotRightChainTolerance = (1 + (float(self.config.get('Advanced Settings', 'rightChainTolerance')) / 100)) * float(self.config.get('Computed Settings', 'distPerRot'))
189-
self.config.set('Computed Settings', "distPerRotRightChainTolerance", str(distPerRotRightChainTolerance))
189+
self.config.set('Computed Settings', "distPerRotRightChainTolerance", str("{0:.5f}".format(distPerRotRightChainTolerance)))
190190

191191
elif key == 'enablePosPIDValues':
192192
for key in ('KpPos', 'KiPos', 'KdPos', 'propWeight'):
@@ -250,7 +250,7 @@ def configSettingChange(self, section, key, value):
250250
value = 3
251251
else:
252252
value = 0
253-
253+
254254

255255
# Update Computed Settings
256256
self.computeSettings(section, key, value)

0 commit comments

Comments
 (0)