ut-robotics / picr21-team-sauna-madis

0 stars 0 forks source link

Use enums #10

Closed ReikoR closed 2 years ago

ReikoR commented 2 years ago

Documentation: https://docs.python.org/3/library/enum.html

https://github.com/ut-robotics/picr21-team-sauna-madis/blob/cb62bf36c7e155ff79965e80d67b5a4e670aae09/saun/main.py#L75

https://github.com/ut-robotics/picr21-team-sauna-madis/blob/cb62bf36c7e155ff79965e80d67b5a4e670aae09/saun/main.py#L97

Instead of using plain strings, create and use enums. Enums help to avoid bugs caused by typos in strings.

For example:

from enum import Enum

class MoveStyle(Enum):
    CONTROLLER = 1
    AUTO = 2

move_style = MoveStyle.AUTO

if move_style == MoveStyle.CONTROLLER:
ReikoR commented 2 years ago

Some more places where enums could be used:

https://github.com/ut-robotics/picr21-team-sauna-madis/blob/1f4b77ebae64bb29882fd5f36271e09f96811f76/saun/imageProcess.py#L32-L40

https://github.com/ut-robotics/picr21-team-sauna-madis/blob/1f4b77ebae64bb29882fd5f36271e09f96811f76/saun/main.py#L17

https://github.com/ut-robotics/picr21-team-sauna-madis/blob/1f4b77ebae64bb29882fd5f36271e09f96811f76/saun/main.py#L27

uschults commented 2 years ago

They are now using enums.