mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-25 01:41:43 +00:00
Gearsbot example: Use standard argument order (#1995)
The convention is to put the subsystem last.
This commit is contained in:
committed by
Peter Johnson
parent
75438ab2ce
commit
d4430b765e
@@ -31,11 +31,9 @@ RobotContainer::RobotContainer()
|
||||
m_drivetrain.Log();
|
||||
|
||||
m_drivetrain.SetDefaultCommand(TankDrive(
|
||||
&m_drivetrain,
|
||||
[this] { return m_joy.GetY(frc::GenericHID::JoystickHand::kLeftHand); },
|
||||
[this] {
|
||||
return m_joy.GetY(frc::GenericHID::JoystickHand::kRightHand);
|
||||
}));
|
||||
[this] { return m_joy.GetY(frc::GenericHID::JoystickHand::kRightHand); },
|
||||
&m_drivetrain));
|
||||
|
||||
// Configure the button bindings
|
||||
ConfigureButtonBindings();
|
||||
|
||||
@@ -9,9 +9,9 @@
|
||||
|
||||
#include "Robot.h"
|
||||
|
||||
TankDrive::TankDrive(DriveTrain* drivetrain, std::function<double()> left,
|
||||
std::function<double()> right)
|
||||
: m_drivetrain(drivetrain), m_left(left), m_right(right) {
|
||||
TankDrive::TankDrive(std::function<double()> left,
|
||||
std::function<double()> right, DriveTrain* drivetrain)
|
||||
: m_left(left), m_right(right), m_drivetrain(drivetrain) {
|
||||
SetName("TankDrive");
|
||||
AddRequirements({m_drivetrain});
|
||||
}
|
||||
|
||||
@@ -17,14 +17,14 @@
|
||||
*/
|
||||
class TankDrive : public frc2::CommandHelper<frc2::CommandBase, TankDrive> {
|
||||
public:
|
||||
TankDrive(DriveTrain* drivetrain, std::function<double()> left,
|
||||
std::function<double()> right);
|
||||
TankDrive(std::function<double()> left, std::function<double()> right,
|
||||
DriveTrain* drivetrain);
|
||||
void Execute() override;
|
||||
bool IsFinished() override;
|
||||
void End(bool interrupted) override;
|
||||
|
||||
private:
|
||||
DriveTrain* m_drivetrain;
|
||||
std::function<double()> m_left;
|
||||
std::function<double()> m_right;
|
||||
DriveTrain* m_drivetrain;
|
||||
};
|
||||
|
||||
@@ -67,8 +67,8 @@ public class RobotContainer {
|
||||
.putData("Deliver Soda", new Autonomous(m_drivetrain, m_claw, m_wrist, m_elevator));
|
||||
|
||||
// Assign default commands
|
||||
m_drivetrain.setDefaultCommand(new TankDrive(m_drivetrain, () -> m_joystick.getY(Hand.kLeft),
|
||||
() -> m_joystick.getY(Hand.kRight)));
|
||||
m_drivetrain.setDefaultCommand(new TankDrive(() -> m_joystick.getY(Hand.kLeft),
|
||||
() -> m_joystick.getY(Hand.kRight), m_drivetrain));
|
||||
|
||||
// Show what command your subsystem is running on the SmartDashboard
|
||||
SmartDashboard.putData(m_drivetrain);
|
||||
|
||||
@@ -25,11 +25,11 @@ public class TankDrive extends CommandBase {
|
||||
/**
|
||||
* Creates a new TankDrive command.
|
||||
*
|
||||
* @param drivetrain The drivetrain subsystem to drive
|
||||
* @param left The control input for the left side of the drive
|
||||
* @param right The control input for the right sight of the drive
|
||||
* @param drivetrain The drivetrain subsystem to drive
|
||||
*/
|
||||
public TankDrive(DriveTrain drivetrain, DoubleSupplier left, DoubleSupplier right) {
|
||||
public TankDrive(DoubleSupplier left, DoubleSupplier right, DriveTrain drivetrain) {
|
||||
m_drivetrain = drivetrain;
|
||||
m_left = left;
|
||||
m_right = right;
|
||||
|
||||
Reference in New Issue
Block a user