Closed mjhealy closed 1 year ago
Hi there!
I think you've filed this in the wrong place. This is the release repo for Phoenix, so CTR Electronics devices and software (Talon, Victor, Pigeon, etc.).
You'll need to reach out to Rev for support with their libraries.
(smack forehead) You're quite right. My apologies!
Description:
Calls to the
SetPosition()
method on aSparkMaxRelativeEncoder
are not immediately reflected in the value returned byGetPosition()
; instead, the encoder appears to be receiving the update asynchronously at some later point in time.This can result in unexpected/incorrect behavior in client code.
Example steps to reproduce:
Assumptions:
class DriveForDistance : public frc2::CommandHelper<frc2::CommandBase, DriveForDistance> { private: DriveBase driveBase; const double distance; double start; public: DriveForDistance(DriveBase base, double meters) : driveBase(base), distance(meters), start(0) { AddRequirements(driveBase); } void Initialize() { driveBase->resetEncoders(); // should print success message start = driveBase->getLeftPosition(); std::cerr << "Left position on init: " << start << std::endl; // should report 0 } void IsFinished() { double position = driveBase->getLeftPosition(); std::cerr << "Current position: " << position << std::endl; return (position >= start + distance); } void Execute() { driveBase->drive(0.3); } void End() { driveBase->drive(0); } };