mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-24 01:31:46 +00:00
[wpilib] Prefix all NI DS specific controller classes (#8596)
Easier then the last one that put everything in a sub namespace. By prefixing the name less things break, and intellisense will be less confusing to new users during the transition.
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
package org.wpilib.examples.tankdrivegamepad;
|
||||
|
||||
import org.wpilib.framework.RobotBase;
|
||||
|
||||
/**
|
||||
* Do NOT add any static variables to this class, or any initialization at all. Unless you know what
|
||||
* you are doing, do not modify this file except to change the parameter class to the startRobot
|
||||
* call.
|
||||
*/
|
||||
public final class Main {
|
||||
private Main() {}
|
||||
|
||||
/**
|
||||
* Main initialization function. Do not perform any initialization here.
|
||||
*
|
||||
* <p>If you change your main robot class, change the parameter type.
|
||||
*/
|
||||
public static void main(String... args) {
|
||||
RobotBase.startRobot(Robot::new);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
package org.wpilib.examples.tankdrivegamepad;
|
||||
|
||||
import org.wpilib.drive.DifferentialDrive;
|
||||
import org.wpilib.driverstation.Gamepad;
|
||||
import org.wpilib.framework.TimedRobot;
|
||||
import org.wpilib.hardware.motor.PWMSparkMax;
|
||||
import org.wpilib.util.sendable.SendableRegistry;
|
||||
|
||||
/**
|
||||
* This is a demo program showing the use of the DifferentialDrive class. Runs the motors with tank
|
||||
* steering and a gamepad.
|
||||
*/
|
||||
public class Robot extends TimedRobot {
|
||||
private final PWMSparkMax m_leftMotor = new PWMSparkMax(0);
|
||||
private final PWMSparkMax m_rightMotor = new PWMSparkMax(1);
|
||||
private final DifferentialDrive m_robotDrive =
|
||||
new DifferentialDrive(m_leftMotor::set, m_rightMotor::set);
|
||||
private final Gamepad m_driverController = new Gamepad(0);
|
||||
|
||||
/** Called once at the beginning of the robot program. */
|
||||
public Robot() {
|
||||
SendableRegistry.addChild(m_robotDrive, m_leftMotor);
|
||||
SendableRegistry.addChild(m_robotDrive, m_rightMotor);
|
||||
|
||||
// We need to invert one side of the drivetrain so that positive voltages
|
||||
// result in both sides moving forward. Depending on how your robot's
|
||||
// gearbox is constructed, you might have to invert the left side instead.
|
||||
m_rightMotor.setInverted(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void teleopPeriodic() {
|
||||
// Drive with tank drive.
|
||||
// That means that the Y axis of the left stick moves the left side
|
||||
// of the robot forward and backward, and the Y axis of the right stick
|
||||
// moves the right side of the robot forward and backward.
|
||||
m_robotDrive.tankDrive(-m_driverController.getLeftY(), -m_driverController.getRightY());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user