Skip to content

Create Encoder, Wheel, and Wheel Container classes and use them in motion.cpp #96

Description

@alexanderbenfox

Ideally, we'd like to encapsulate all calls to the encoders, motors, and PID controllers into one class and then use it in the motion.cpp. The class would contain an Encoder, Motor, and PIDController object and then would be able to set those things via methods. It would look something like:

class Wheel {
public:
float getPositionMillimeters(){
return _encoder.extrapolate() * MILLIMETERS_PER_TICK;
}

void setMotor(float error);
...
...

private:
Encoder _encoder;
Motor _motor;
PIDController _pid;
};

and then we'd like to encapsulate this in a container so that we can control all of the wheels if we want or just some

enum WheelType{
backleft, backright, frontleft, frontright, front, back, left, right, all
};

class WheelContainer{
WheelContainer();
void addNewWheel(EncoderPin pin, ...);

//this would set any or all of the motors
void setMotor(float error, WheelType type);
};

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions