LemLib / hardware

Hardware Abstractions for the Vex V5
MIT License
1 stars 1 forks source link

🎨 Split `Motor` class into `Motor` and `MotorEncoder` #3

Closed SizzinSeal closed 1 month ago

SizzinSeal commented 3 months ago

Overview

Split the Motor class into the Motor and MotorEncoder class, and the MotorGroup class into a MotorGroup and MotorEncoderGroup

Motivation

A motor is something that moves something else. An encoder measures position. So why do we currently treat them as a the same thing? Well, its because it was thought that it wouldn't be possible to have them both completely independent from each other, that either would need to write to the motor firmware something that would affect the other. However, once Issue #2 is implemented, it's possible. When these objects are split, it will prevent mistakes from happening when interacting with the motors.

Implementation

The Motor class implements move, moveVelocity, getPort, and, if Issue #1 is implemented, getTemperature too. The MotorEncoder class inherits from the abstract Encoder class and implements the virtual methods. Same thing for the MotorGroup and MotorEncoderGroup class

SizzinSeal commented 1 month ago

This would complicate the API for adding or removing motors from a motor group that's being used by LemLib, as you would need to do the same thing for both the motor and motor encoder. This would also require an encoder group class, so this is not going to be implemented