MotionMagic conflicts with DifferentialDrive

Our team is trying to set up our auto code with motion magic. But the robot did not move and reported that differential drive is not updated often enough. After we deleted the differentialDrive object the code worked. is it because the differential drive object prohibits setting the motor in the drivetrain separately? Could I keep both Talon methods and differentialDrive?

That happened because DifferentialDrive has a watchdog internally (a MotorSafety instance) that expires if one of its drive functions isn’t called often enough. When that happens, it calls StopMotor() on all motors passed to its constructor. If you were setting stuff on the Talon SRX directly rather than using the DifferentialDrive object for some period of time, that’s why your motors stopped.

Note that the MotorSafety from DifferentialDrive is separate from any MotorSafety implemented by the motor controller classes. In this case, TalonSRX doesn’t use MotorSafety due to a bug that cropped up December 2018.

To avoid the timeouts during autonomous, call SetSafetyEnabled(false) on the DifferentialDrive instance in autonomousInit(). Make sure to enable it again in teleopInit().

That solved the problem. Thanks a lot!