How does this class work internally - how does it track the angle of turning? Is there a built-in encoder inside the motors to facilitate that? is there a way to access the encoder directly?
I haven’t worked with the Python Drivetrain class, but there is an encoder in the new V5 motors. This encoder is very accurate (I’m saying this from experience) and is probably what the class uses to track the turning.
I believe what we’re having it do is issue two
rotate_for
commands to the drivetrain’s motors, with the amount to turn calculated from the circumference and wheel base width fed to the drivetrain’s constructor.
As for the details, yes V5 motors have built-in encoders. You can access them from methods on the motors themselves. Check out the reference page for the motor class. The
rotation
method polls the motor’s encoder.