Open alexanderbenfox opened 7 years ago
Made the Encoder
class while moving files around for #100. sensors_encoders.h
still exists for compatibility reasons, but now it just calls into the new Encoder
stuff. As is, Encoder
doesn't convert to millimeters like you have above, but I'll argue that should be contained within the new motion layer logic and not within the Encoder
class. (i.e. I think Encoder
should only concern itself with counts, though in float
form)
Wrote up a concept for Wheel
in #75. Also in #75 is SkidSteerCar
, which would be the equivalent of WheelContainer
.
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); };