mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
[wpilib] Add functional interface equivalents to MotorController (#6053)
This does not deprecate any current functionality, but prepares the way for future deprecation. The drive classes now accept void(double) functions, which makes them more flexible. The C++ API ended up a bit more verbose, but the Java API is really concise with method references, which is >80% of our userbase. For example: `DifferentialDrive drive = new DifferentialDrive(m_leftMotor::set, m_rightMotor::set);` Lambdas can be passed to interoperate with vendor motor controller APIs that don't have e.g., set(double), so CTRE doesn't have to maintain their WPI_ classes anymore. MotorControllerGroup was replaced with PWMMotorController.addFollower() for PWM motor controllers. Users of CAN motor controllers should use their vendor's follower functionality.
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include <units/time.h>
|
||||
#include <wpi/deprecated.h>
|
||||
|
||||
#include "TestBench.h"
|
||||
#include "frc/Encoder.h"
|
||||
@@ -37,6 +38,8 @@ std::ostream& operator<<(std::ostream& os, MotorEncoderTestType const& type) {
|
||||
|
||||
static constexpr auto kMotorTime = 0.5_s;
|
||||
|
||||
WPI_IGNORE_DEPRECATED
|
||||
|
||||
/**
|
||||
* A fixture that includes a PWM motor controller and an encoder connected to
|
||||
* the same motor.
|
||||
@@ -197,3 +200,5 @@ TEST_P(MotorEncoderTest, Reset) {
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(Tests, MotorEncoderTest,
|
||||
testing::Values(TEST_VICTOR, TEST_JAGUAR, TEST_TALON));
|
||||
|
||||
WPI_UNIGNORE_DEPRECATED
|
||||
|
||||
Reference in New Issue
Block a user