Alles verbessert

This commit is contained in:
2026-05-21 19:30:33 +02:00
parent 5dccc8985e
commit 33b71416ff
19 changed files with 855 additions and 229 deletions
@@ -4,31 +4,29 @@ import time
import os
config_filename = '../config/exomy.yaml'
WHEELS = ('fl', 'fr', 'cl', 'cr', 'rl', 'rr')
def get_driving_pins():
pin_list = []
with open(config_filename, 'r') as file:
param_dict = yaml.load(file)
for key, value in param_dict.items():
if('pin_drive_' in str(key)):
pin_list.append(value)
return pin_list
return [param_dict['pin_drive_' + wheel] for wheel in WHEELS]
def get_drive_pwm_neutral():
def get_drive_pwm_neutral_values():
with open(config_filename, 'r') as file:
param_dict = yaml.load(file)
for key, value in param_dict.items():
if('drive_pwm_neutral' in str(key)):
return value
default_value = 300
print('The parameter drive_pwm_neutral could not be found in the exomy.yaml \n')
print('It was set to the default value: '+ default_value + '\n')
return default_value
values = {}
for wheel in WHEELS:
key = 'drive_pwm_neutral_' + wheel
if key not in param_dict:
print('The parameter ' + key + ' could not be found in the exomy.yaml \n')
print('It was set to the default value: 300\n')
values[wheel] = 300
else:
values[wheel] = param_dict[key]
return values
if __name__ == "__main__":
print(
@@ -62,7 +60,7 @@ On each motor you have to turn the correction screw until the motor really stand
pwm = Adafruit_PCA9685.PCA9685()
'''
The drive_pwm_neutral value is determined from the exomy.yaml file.
The drive_pwm_neutral values are determined from the exomy.yaml file.
But it can be also calculated from the values of the PWM board and motors,
like shown in the following calculation:
@@ -83,11 +81,11 @@ On each motor you have to turn the correction screw until the motor really stand
value = int(duty_cycle*4096.0) # 307
'''
value = get_drive_pwm_neutral()
value_dict = get_drive_pwm_neutral_values()
pin_list = get_driving_pins()
for pin in pin_list:
pwm.set_pwm(pin, 0, value)
for index, pin in enumerate(pin_list):
pwm.set_pwm(pin, 0, value_dict[WHEELS[index]])
time.sleep(0.1)
raw_input('Press any button if you are done to complete configuration\n')