pi-top / pi-top-Python-SDK

pi-top's Python SDK (pitop package)
Apache License 2.0
27 stars 4 forks source link

Saving and loading the configuration of an encoder configuration fails #606

Closed nincns closed 1 year ago

nincns commented 1 year ago

from time import sleep from pitop import BrakingType, EncoderMotor, ForwardDirection

motor_fl = EncoderMotor("M0", ForwardDirection.CLOCKWISE) motor_fl.braking_type = BrakingType.COAST

I use smaller wheels and would like to save them as a configuration in order to reuse them faster with less code, I would also like to load the direction of rotation of all four wheels by means of configuration.

motor_fl.save_config('m0.conf') Storing configuration in m0.conf

Then I would like to reload the configuration.

motor_fl.from_file('m0.conf') Loading configuration from m0.conf Recreating EncoderMotor (from pitop.pma.encoder_motor) with {'port_name': 'M0', 'name': 'encoder_motor', 'forward_direction': 1, 'braking_type': 0, 'wheel_diameter': 0.6} Traceback (most recent call last): File "", line 1, in File "/usr/lib/python3/dist-packages/pitop/core/mixins/recreatable.py", line 57, in from_file return cls.from_config(config_dict) File "/usr/lib/python3/dist-packages/pitop/core/mixins/recreatable.py", line 48, in from_config return main_cls(**config_dict) File "/usr/lib/python3/dist-packages/pitop/pma/encoder_motor.py", line 65, in init self.__motor_core = EncoderMotorController(self._pma_port, braking_type.value) AttributeError: 'int' object has no attribute 'value'

jcapona commented 1 year ago

hey @nincns - we have fixed the issue and will release an update with the fix shortly