mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-23 01:21:42 +00:00
[examples] Clean up examples (#8674)
Move various "examples" into snippets. Several examples that were less than a full mechanism or robot were moved to snippets. `arcadedrive` and `tankdrive` were removed in favor of their Gamepad variants. `hidrumble` was removed due to being too simple. `potentiometerpid` was removed because of low utility. `gyromecanum` replaced `mecanumdrive` for deduplication and because very few teams run holonomic drivetrains without gyros.
This commit is contained in:
@@ -1,42 +0,0 @@
|
||||
// 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.arcadedrive;
|
||||
|
||||
import org.wpilib.drive.DifferentialDrive;
|
||||
import org.wpilib.driverstation.Joystick;
|
||||
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
|
||||
* arcade steering.
|
||||
*/
|
||||
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::setDutyCycle, m_rightMotor::setDutyCycle);
|
||||
private final Joystick m_stick = new Joystick(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 arcade drive.
|
||||
// That means that the Y axis drives forward
|
||||
// and backward, and the X turns left and right.
|
||||
m_robotDrive.arcadeDrive(-m_stick.getY(), -m_stick.getX());
|
||||
}
|
||||
}
|
||||
@@ -10,71 +10,6 @@
|
||||
"robotclass": "Robot",
|
||||
"commandversion": 2
|
||||
},
|
||||
{
|
||||
"name": "Tank Drive",
|
||||
"description": "Control a differential drive with twin-joystick tank drive in teleop.",
|
||||
"tags": [
|
||||
"Basic Robot",
|
||||
"Differential Drive",
|
||||
"Joystick"
|
||||
],
|
||||
"foldername": "tankdrive",
|
||||
"gradlebase": "java",
|
||||
"robotclass": "Robot",
|
||||
"commandversion": 2
|
||||
},
|
||||
{
|
||||
"name": "Arcade Drive",
|
||||
"description": "Control a differential drivetrain with single-joystick arcade drive in teleop.",
|
||||
"tags": [
|
||||
"Basic Robot",
|
||||
"Differential Drive",
|
||||
"Joystick"
|
||||
],
|
||||
"foldername": "arcadedrive",
|
||||
"gradlebase": "java",
|
||||
"robotclass": "Robot",
|
||||
"commandversion": 2
|
||||
},
|
||||
{
|
||||
"name": "Mecanum Drive",
|
||||
"description": "Control a mecanum drivetrain with a joystick in teleop.",
|
||||
"tags": [
|
||||
"Basic Robot",
|
||||
"Mecanum Drive",
|
||||
"Joystick"
|
||||
],
|
||||
"foldername": "mecanumdrive",
|
||||
"gradlebase": "java",
|
||||
"robotclass": "Robot",
|
||||
"commandversion": 2
|
||||
},
|
||||
{
|
||||
"name": "PDP CAN Monitoring",
|
||||
"description": "Monitor Power Distribution data such as voltage, current, temperature, etc.",
|
||||
"tags": [
|
||||
"Hardware",
|
||||
"PDP",
|
||||
"SmartDashboard"
|
||||
],
|
||||
"foldername": "canpdp",
|
||||
"gradlebase": "java",
|
||||
"robotclass": "Robot",
|
||||
"commandversion": 2
|
||||
},
|
||||
{
|
||||
"name": "Solenoids",
|
||||
"description": "Control a single and double solenoid from joystick buttons.",
|
||||
"tags": [
|
||||
"Hardware",
|
||||
"Joystick",
|
||||
"Pneumatics"
|
||||
],
|
||||
"foldername": "solenoid",
|
||||
"gradlebase": "java",
|
||||
"robotclass": "Robot",
|
||||
"commandversion": 2
|
||||
},
|
||||
{
|
||||
"name": "Encoder",
|
||||
"description": "View values from a quadrature encoder.",
|
||||
@@ -88,35 +23,6 @@
|
||||
"robotclass": "Robot",
|
||||
"commandversion": 2
|
||||
},
|
||||
{
|
||||
"name": "EventLoop",
|
||||
"description": "Manage a ball system using EventLoop and BooleanEvent.",
|
||||
"tags": [
|
||||
"Basic Robot",
|
||||
"Flywheel",
|
||||
"EventLoop"
|
||||
],
|
||||
"foldername": "eventloop",
|
||||
"gradlebase": "java",
|
||||
"robotclass": "Robot",
|
||||
"commandversion": 2
|
||||
},
|
||||
{
|
||||
"name": "Potentiometer PID",
|
||||
"description": "Maintain elevator position setpoints with a potentiometer and PID control.",
|
||||
"tags": [
|
||||
"Basic Robot",
|
||||
"Analog",
|
||||
"Elevator",
|
||||
"PID",
|
||||
"Joystick"
|
||||
],
|
||||
"foldername": "potentiometerpid",
|
||||
"gradlebase": "java",
|
||||
"robotclass": "Robot",
|
||||
"commandversion": 2,
|
||||
"hasunittests": true
|
||||
},
|
||||
{
|
||||
"name": "Elevator with trapezoid profiled PID",
|
||||
"description": "Reach elevator position setpoints with trapezoid profiles and smart motor controller PID.",
|
||||
@@ -169,7 +75,6 @@
|
||||
"Differential Drive",
|
||||
"PID",
|
||||
"Gyro",
|
||||
"Analog",
|
||||
"Joystick"
|
||||
],
|
||||
"foldername": "gyro",
|
||||
@@ -178,28 +83,15 @@
|
||||
"commandversion": 2
|
||||
},
|
||||
{
|
||||
"name": "Gyro Mecanum",
|
||||
"name": "Mecanum Drive",
|
||||
"description": "Drive a mecanum drivetrain using field-oriented controls with a joystick.",
|
||||
"tags": [
|
||||
"Basic Robot",
|
||||
"Mecanum Drive",
|
||||
"Gyro",
|
||||
"Analog",
|
||||
"Joystick"
|
||||
],
|
||||
"foldername": "gyromecanum",
|
||||
"gradlebase": "java",
|
||||
"robotclass": "Robot",
|
||||
"commandversion": 2
|
||||
},
|
||||
{
|
||||
"name": "HID Rumble",
|
||||
"description": "Make human interface devices (HID) rumble.",
|
||||
"tags": [
|
||||
"Hardware",
|
||||
"Gamepad"
|
||||
],
|
||||
"foldername": "hidrumble",
|
||||
"foldername": "mecanumdrive",
|
||||
"gradlebase": "java",
|
||||
"robotclass": "Robot",
|
||||
"commandversion": 2
|
||||
@@ -221,65 +113,6 @@
|
||||
"robotclass": "Robot",
|
||||
"commandversion": 2
|
||||
},
|
||||
{
|
||||
"name": "Motor Control",
|
||||
"description": "Control a single motor with a joystick, displaying the movement of the motor using an encoder.",
|
||||
"tags": [
|
||||
"Basic Robot",
|
||||
"Encoder",
|
||||
"SmartDashboard",
|
||||
"Joystick"
|
||||
],
|
||||
"foldername": "motorcontrol",
|
||||
"gradlebase": "java",
|
||||
"robotclass": "Robot",
|
||||
"commandversion": 2
|
||||
},
|
||||
{
|
||||
"name": "Simple Vision",
|
||||
"description": "Use the CameraServer class to stream from a USB Webcam without processing the images.",
|
||||
"tags": [
|
||||
"Vision"
|
||||
],
|
||||
"foldername": "quickvision",
|
||||
"gradlebase": "java",
|
||||
"robotclass": "Robot",
|
||||
"commandversion": 2
|
||||
},
|
||||
{
|
||||
"name": "Intermediate Vision",
|
||||
"description": "Acquire images from an attached USB camera and add some annotation to the image (as you might do for showing operators the result of some image recognition) and send it to the dashboard for display.",
|
||||
"tags": [
|
||||
"Vision"
|
||||
],
|
||||
"foldername": "intermediatevision",
|
||||
"gradlebase": "java",
|
||||
"robotclass": "Robot",
|
||||
"commandversion": 2
|
||||
},
|
||||
{
|
||||
"name": "HTTP Camera",
|
||||
"description": "Acquire images from an HTTP network camera and adds some annotation to the image (as you might do for showing operators the result of some image recognition), and sends it to the dashboard for display.",
|
||||
"tags": [
|
||||
"Vision"
|
||||
],
|
||||
"foldername": "httpcamera",
|
||||
"gradlebase": "java",
|
||||
"robotclass": "Robot",
|
||||
"commandversion": 2
|
||||
},
|
||||
{
|
||||
"name": "AprilTags Vision",
|
||||
"description": "On-roboRIO detection of AprilTags using an attached USB camera.",
|
||||
"tags": [
|
||||
"Vision",
|
||||
"AprilTags"
|
||||
],
|
||||
"foldername": "apriltagsvision",
|
||||
"gradlebase": "java",
|
||||
"robotclass": "Robot",
|
||||
"commandversion": 2
|
||||
},
|
||||
{
|
||||
"name": "'Traditional' Hatchbot",
|
||||
"description": "A fully-functional Commandv2 hatchbot for the 2019 game, written in the 'traditional' style, i.e. commands are given their own classes.",
|
||||
@@ -338,17 +171,6 @@
|
||||
"robotclass": "Robot",
|
||||
"commandversion": 2
|
||||
},
|
||||
{
|
||||
"name": "Select Command Example",
|
||||
"description": "Use SelectCommand to select an autonomous routine.",
|
||||
"tags": [
|
||||
"Commandv2"
|
||||
],
|
||||
"foldername": "selectcommand",
|
||||
"gradlebase": "java",
|
||||
"robotclass": "Robot",
|
||||
"commandversion": 2
|
||||
},
|
||||
{
|
||||
"name": "SwerveBot",
|
||||
"description": "Use kinematics and odometry with a swerve drive.",
|
||||
@@ -434,32 +256,6 @@
|
||||
"robotclass": "Robot",
|
||||
"commandversion": 2
|
||||
},
|
||||
{
|
||||
"name": "Duty Cycle Input",
|
||||
"description": "View duty-cycle input.",
|
||||
"tags": [
|
||||
"Hardware",
|
||||
"Duty Cycle",
|
||||
"SmartDashboard"
|
||||
],
|
||||
"foldername": "dutycycleinput",
|
||||
"gradlebase": "java",
|
||||
"robotclass": "Robot",
|
||||
"commandversion": 2
|
||||
},
|
||||
{
|
||||
"name": "Addressable LED",
|
||||
"description": "Display a rainbow pattern on an addressable LED strip.",
|
||||
"tags": [
|
||||
"Hardware",
|
||||
"Basic Robot",
|
||||
"AddressableLEDs"
|
||||
],
|
||||
"foldername": "addressableled",
|
||||
"gradlebase": "java",
|
||||
"robotclass": "Robot",
|
||||
"commandversion": 2
|
||||
},
|
||||
{
|
||||
"name": "DriveDistanceOffboard",
|
||||
"description": "Drive a differential drivetrain a set distance using TrapezoidProfile and smart motor controller PID.",
|
||||
@@ -722,45 +518,6 @@
|
||||
"xrp"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Digital Communication Sample",
|
||||
"description": "Communicates with external devices (such as an Arduino) using the roboRIO's DIO.",
|
||||
"tags": [
|
||||
"Hardware",
|
||||
"Digital Output"
|
||||
],
|
||||
"foldername": "digitalcommunication",
|
||||
"gradlebase": "java",
|
||||
"commandversion": 2,
|
||||
"robotclass": "Robot",
|
||||
"hasunittests": true
|
||||
},
|
||||
{
|
||||
"name": "I2C Communication Sample",
|
||||
"description": "Communicate with external devices (such as an Arduino) using the roboRIO's I2C port.",
|
||||
"tags": [
|
||||
"Hardware",
|
||||
"I2C"
|
||||
],
|
||||
"foldername": "i2ccommunication",
|
||||
"gradlebase": "java",
|
||||
"commandversion": 2,
|
||||
"robotclass": "Robot",
|
||||
"hasunittests": true
|
||||
},
|
||||
{
|
||||
"name": "Flywheel BangBangController",
|
||||
"description": "A sample program to demonstrate the use of a BangBangController with a flywheel to control RPM",
|
||||
"tags": [
|
||||
"Flywheel",
|
||||
"Simulation",
|
||||
"Joystick"
|
||||
],
|
||||
"foldername": "flywheelbangbangcontroller",
|
||||
"gradlebase": "java",
|
||||
"commandversion": 2,
|
||||
"robotclass": "Robot"
|
||||
},
|
||||
{
|
||||
"name": "SysIdRoutine",
|
||||
"description": "A sample Commandv2 robot demonstrating use of the SysIdRoutine command factory",
|
||||
|
||||
@@ -1,62 +0,0 @@
|
||||
// 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.gyromecanum;
|
||||
|
||||
import org.wpilib.drive.MecanumDrive;
|
||||
import org.wpilib.driverstation.Joystick;
|
||||
import org.wpilib.framework.TimedRobot;
|
||||
import org.wpilib.hardware.imu.OnboardIMU;
|
||||
import org.wpilib.hardware.motor.PWMSparkMax;
|
||||
import org.wpilib.util.sendable.SendableRegistry;
|
||||
|
||||
/**
|
||||
* This is a sample program that uses mecanum drive with a gyro sensor to maintain rotation vectors
|
||||
* in relation to the starting orientation of the robot (field-oriented controls).
|
||||
*/
|
||||
public class Robot extends TimedRobot {
|
||||
private static final int kFrontLeftChannel = 0;
|
||||
private static final int kRearLeftChannel = 1;
|
||||
private static final int kFrontRightChannel = 2;
|
||||
private static final int kRearRightChannel = 3;
|
||||
private static final OnboardIMU.MountOrientation kIMUMountOrientation =
|
||||
OnboardIMU.MountOrientation.kFlat;
|
||||
private static final int kJoystickPort = 0;
|
||||
|
||||
private final MecanumDrive m_robotDrive;
|
||||
private final OnboardIMU m_imu = new OnboardIMU(kIMUMountOrientation);
|
||||
private final Joystick m_joystick = new Joystick(kJoystickPort);
|
||||
|
||||
/** Called once at the beginning of the robot program. */
|
||||
public Robot() {
|
||||
PWMSparkMax frontLeft = new PWMSparkMax(kFrontLeftChannel);
|
||||
PWMSparkMax rearLeft = new PWMSparkMax(kRearLeftChannel);
|
||||
PWMSparkMax frontRight = new PWMSparkMax(kFrontRightChannel);
|
||||
PWMSparkMax rearRight = new PWMSparkMax(kRearRightChannel);
|
||||
|
||||
// Invert the right side motors.
|
||||
// You may need to change or remove this to match your robot.
|
||||
frontRight.setInverted(true);
|
||||
rearRight.setInverted(true);
|
||||
|
||||
m_robotDrive =
|
||||
new MecanumDrive(
|
||||
frontLeft::setDutyCycle,
|
||||
rearLeft::setDutyCycle,
|
||||
frontRight::setDutyCycle,
|
||||
rearRight::setDutyCycle);
|
||||
|
||||
SendableRegistry.addChild(m_robotDrive, frontLeft);
|
||||
SendableRegistry.addChild(m_robotDrive, rearLeft);
|
||||
SendableRegistry.addChild(m_robotDrive, frontRight);
|
||||
SendableRegistry.addChild(m_robotDrive, rearRight);
|
||||
}
|
||||
|
||||
/** Mecanum drive is used with the gyro angle as an input. */
|
||||
@Override
|
||||
public void teleopPeriodic() {
|
||||
m_robotDrive.driveCartesian(
|
||||
-m_joystick.getY(), -m_joystick.getX(), -m_joystick.getZ(), m_imu.getRotation2d());
|
||||
}
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
// 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.hidrumble;
|
||||
|
||||
import org.wpilib.driverstation.Gamepad;
|
||||
import org.wpilib.driverstation.GenericHID.RumbleType;
|
||||
import org.wpilib.framework.TimedRobot;
|
||||
|
||||
/** This is a demo program showing the use of GenericHID's rumble feature. */
|
||||
public class Robot extends TimedRobot {
|
||||
private final Gamepad m_hid = new Gamepad(0);
|
||||
|
||||
@Override
|
||||
public void autonomousInit() {
|
||||
// Turn on rumble at the start of auto
|
||||
m_hid.setRumble(RumbleType.kLeftRumble, 1.0);
|
||||
m_hid.setRumble(RumbleType.kRightRumble, 1.0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disabledInit() {
|
||||
// Stop the rumble when entering disabled
|
||||
m_hid.setRumble(RumbleType.kLeftRumble, 0.0);
|
||||
m_hid.setRumble(RumbleType.kRightRumble, 0.0);
|
||||
}
|
||||
}
|
||||
@@ -7,20 +7,26 @@ package org.wpilib.examples.mecanumdrive;
|
||||
import org.wpilib.drive.MecanumDrive;
|
||||
import org.wpilib.driverstation.Joystick;
|
||||
import org.wpilib.framework.TimedRobot;
|
||||
import org.wpilib.hardware.imu.OnboardIMU;
|
||||
import org.wpilib.hardware.motor.PWMSparkMax;
|
||||
import org.wpilib.util.sendable.SendableRegistry;
|
||||
|
||||
/** This is a demo program showing how to use Mecanum control with the MecanumDrive class. */
|
||||
/**
|
||||
* This is a sample program that uses mecanum drive with a gyro sensor to maintain rotation vectors
|
||||
* in relation to the starting orientation of the robot (field-oriented controls).
|
||||
*/
|
||||
public class Robot extends TimedRobot {
|
||||
private static final int kFrontLeftChannel = 2;
|
||||
private static final int kRearLeftChannel = 3;
|
||||
private static final int kFrontRightChannel = 1;
|
||||
private static final int kRearRightChannel = 0;
|
||||
|
||||
private static final int kJoystickChannel = 0;
|
||||
private static final int kFrontLeftChannel = 0;
|
||||
private static final int kRearLeftChannel = 1;
|
||||
private static final int kFrontRightChannel = 2;
|
||||
private static final int kRearRightChannel = 3;
|
||||
private static final OnboardIMU.MountOrientation kIMUMountOrientation =
|
||||
OnboardIMU.MountOrientation.kFlat;
|
||||
private static final int kJoystickPort = 0;
|
||||
|
||||
private final MecanumDrive m_robotDrive;
|
||||
private final Joystick m_stick;
|
||||
private final OnboardIMU m_imu = new OnboardIMU(kIMUMountOrientation);
|
||||
private final Joystick m_joystick = new Joystick(kJoystickPort);
|
||||
|
||||
/** Called once at the beginning of the robot program. */
|
||||
public Robot() {
|
||||
@@ -41,18 +47,18 @@ public class Robot extends TimedRobot {
|
||||
frontRight::setDutyCycle,
|
||||
rearRight::setDutyCycle);
|
||||
|
||||
m_stick = new Joystick(kJoystickChannel);
|
||||
|
||||
SendableRegistry.addChild(m_robotDrive, frontLeft);
|
||||
SendableRegistry.addChild(m_robotDrive, rearLeft);
|
||||
SendableRegistry.addChild(m_robotDrive, frontRight);
|
||||
SendableRegistry.addChild(m_robotDrive, rearRight);
|
||||
}
|
||||
|
||||
/** Mecanum drive is used with the gyro angle as an input. */
|
||||
@Override
|
||||
public void teleopPeriodic() {
|
||||
// Use the joystick Y axis for forward movement, X axis for lateral
|
||||
// movement, and Z axis for rotation.
|
||||
m_robotDrive.driveCartesian(-m_stick.getY(), -m_stick.getX(), -m_stick.getZ());
|
||||
m_robotDrive.driveCartesian(
|
||||
-m_joystick.getY(), -m_joystick.getX(), -m_joystick.getZ(), m_imu.getRotation2d());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,79 +0,0 @@
|
||||
// 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.potentiometerpid;
|
||||
|
||||
import org.wpilib.driverstation.Joystick;
|
||||
import org.wpilib.framework.TimedRobot;
|
||||
import org.wpilib.hardware.motor.PWMSparkMax;
|
||||
import org.wpilib.hardware.rotation.AnalogPotentiometer;
|
||||
import org.wpilib.math.controller.PIDController;
|
||||
|
||||
/**
|
||||
* This is a sample program to demonstrate how to use a soft potentiometer and a PID controller to
|
||||
* reach and maintain position setpoints on an elevator mechanism.
|
||||
*/
|
||||
public class Robot extends TimedRobot {
|
||||
static final int kPotChannel = 1;
|
||||
static final int kMotorChannel = 7;
|
||||
static final int kJoystickChannel = 3;
|
||||
|
||||
// The elevator can move 1.5 meters from top to bottom
|
||||
static final double kFullHeight = 1.5;
|
||||
|
||||
// Bottom, middle, and top elevator setpoints in meters
|
||||
static final double[] kSetpoints = {0.2, 0.8, 1.4};
|
||||
|
||||
// proportional, integral, and derivative velocity constants
|
||||
// DANGER: when tuning PID constants, high/inappropriate values for kP, kI,
|
||||
// and kD may cause dangerous, uncontrollable, or undesired behavior!
|
||||
private static final double kP = 0.7;
|
||||
private static final double kI = 0.35;
|
||||
private static final double kD = 0.25;
|
||||
|
||||
private final PIDController m_pidController = new PIDController(kP, kI, kD);
|
||||
// Scaling is handled internally
|
||||
private final AnalogPotentiometer m_potentiometer =
|
||||
new AnalogPotentiometer(kPotChannel, kFullHeight);
|
||||
private final PWMSparkMax m_elevatorMotor = new PWMSparkMax(kMotorChannel);
|
||||
private final Joystick m_joystick = new Joystick(kJoystickChannel);
|
||||
|
||||
private int m_index;
|
||||
|
||||
@Override
|
||||
public void teleopInit() {
|
||||
// Move to the bottom setpoint when teleop starts
|
||||
m_index = 0;
|
||||
m_pidController.setSetpoint(kSetpoints[m_index]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void teleopPeriodic() {
|
||||
// Read from the sensor
|
||||
double position = m_potentiometer.get();
|
||||
|
||||
// Run the PID Controller
|
||||
double pidOut = m_pidController.calculate(position);
|
||||
|
||||
// Apply PID output
|
||||
m_elevatorMotor.setDutyCycle(pidOut);
|
||||
|
||||
// when the button is pressed once, the selected elevator setpoint is incremented
|
||||
if (m_joystick.getTriggerPressed()) {
|
||||
// index of the elevator setpoint wraps around.
|
||||
m_index = (m_index + 1) % kSetpoints.length;
|
||||
System.out.println("m_index = " + m_index);
|
||||
m_pidController.setSetpoint(kSetpoints[m_index]);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
m_elevatorMotor.close();
|
||||
m_potentiometer.close();
|
||||
m_pidController.close();
|
||||
m_index = 0;
|
||||
super.close();
|
||||
}
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
// 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.tankdrive;
|
||||
|
||||
import org.wpilib.drive.DifferentialDrive;
|
||||
import org.wpilib.driverstation.Joystick;
|
||||
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, specifically it contains
|
||||
* the code necessary to operate a robot with tank drive.
|
||||
*/
|
||||
public class Robot extends TimedRobot {
|
||||
private final DifferentialDrive m_robotDrive;
|
||||
private final Joystick m_leftStick;
|
||||
private final Joystick m_rightStick;
|
||||
|
||||
private final PWMSparkMax m_leftMotor = new PWMSparkMax(0);
|
||||
private final PWMSparkMax m_rightMotor = new PWMSparkMax(1);
|
||||
|
||||
/** Called once at the beginning of the robot program. */
|
||||
public Robot() {
|
||||
// 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);
|
||||
|
||||
m_robotDrive = new DifferentialDrive(m_leftMotor::setDutyCycle, m_rightMotor::setDutyCycle);
|
||||
m_leftStick = new Joystick(0);
|
||||
m_rightStick = new Joystick(1);
|
||||
|
||||
SendableRegistry.addChild(m_robotDrive, m_leftMotor);
|
||||
SendableRegistry.addChild(m_robotDrive, m_rightMotor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void teleopPeriodic() {
|
||||
m_robotDrive.tankDrive(-m_leftStick.getY(), -m_rightStick.getY());
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
// 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.addressableled;
|
||||
package org.wpilib.snippets.addressableled;
|
||||
|
||||
import static org.wpilib.units.Units.Meters;
|
||||
import static org.wpilib.units.Units.MetersPerSecond;
|
||||
@@ -2,7 +2,7 @@
|
||||
// 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.apriltagsvision;
|
||||
package org.wpilib.snippets.apriltagsvision;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import org.opencv.core.Mat;
|
||||
@@ -2,7 +2,7 @@
|
||||
// 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.canpdp;
|
||||
package org.wpilib.snippets.canpdp;
|
||||
|
||||
import org.wpilib.framework.TimedRobot;
|
||||
import org.wpilib.hardware.power.PowerDistribution;
|
||||
@@ -2,7 +2,7 @@
|
||||
// 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.digitalcommunication;
|
||||
package org.wpilib.snippets.digitalcommunication;
|
||||
|
||||
import java.util.Optional;
|
||||
import org.wpilib.driverstation.DriverStation;
|
||||
@@ -2,7 +2,7 @@
|
||||
// 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.dutycycleinput;
|
||||
package org.wpilib.snippets.dutycycleinput;
|
||||
|
||||
import org.wpilib.framework.TimedRobot;
|
||||
import org.wpilib.hardware.rotation.DutyCycle;
|
||||
@@ -2,7 +2,7 @@
|
||||
// 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.eventloop;
|
||||
package org.wpilib.snippets.eventloop;
|
||||
|
||||
import org.wpilib.driverstation.Joystick;
|
||||
import org.wpilib.event.BooleanEvent;
|
||||
@@ -2,7 +2,7 @@
|
||||
// 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.flywheelbangbangcontroller;
|
||||
package org.wpilib.snippets.flywheelbangbangcontroller;
|
||||
|
||||
import org.wpilib.driverstation.Joystick;
|
||||
import org.wpilib.framework.TimedRobot;
|
||||
@@ -2,7 +2,7 @@
|
||||
// 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.httpcamera;
|
||||
package org.wpilib.snippets.httpcamera;
|
||||
|
||||
import org.opencv.core.Mat;
|
||||
import org.opencv.core.Point;
|
||||
@@ -2,7 +2,7 @@
|
||||
// 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.i2ccommunication;
|
||||
package org.wpilib.snippets.i2ccommunication;
|
||||
|
||||
import java.util.Optional;
|
||||
import org.wpilib.driverstation.DriverStation;
|
||||
@@ -2,7 +2,7 @@
|
||||
// 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.intermediatevision;
|
||||
package org.wpilib.snippets.intermediatevision;
|
||||
|
||||
import org.opencv.core.Mat;
|
||||
import org.opencv.core.Point;
|
||||
@@ -2,7 +2,7 @@
|
||||
// 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.motorcontrol;
|
||||
package org.wpilib.snippets.motorcontrol;
|
||||
|
||||
import org.wpilib.driverstation.Joystick;
|
||||
import org.wpilib.framework.TimedRobot;
|
||||
@@ -2,7 +2,7 @@
|
||||
// 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.quickvision;
|
||||
package org.wpilib.snippets.quickvision;
|
||||
|
||||
import org.wpilib.framework.TimedRobot;
|
||||
import org.wpilib.vision.stream.CameraServer;
|
||||
@@ -2,7 +2,7 @@
|
||||
// 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.selectcommand;
|
||||
package org.wpilib.snippets.selectcommand;
|
||||
|
||||
/**
|
||||
* The Constants class provides a convenient place for teams to hold robot-wide numerical or boolean
|
||||
@@ -2,7 +2,7 @@
|
||||
// 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.selectcommand;
|
||||
package org.wpilib.snippets.selectcommand;
|
||||
|
||||
import org.wpilib.command2.Command;
|
||||
import org.wpilib.command2.CommandScheduler;
|
||||
@@ -2,7 +2,7 @@
|
||||
// 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.selectcommand;
|
||||
package org.wpilib.snippets.selectcommand;
|
||||
|
||||
import java.util.Map;
|
||||
import org.wpilib.command2.Command;
|
||||
@@ -171,5 +171,166 @@
|
||||
"foldername": "profiledpidfeedforward",
|
||||
"gradlebase": "java",
|
||||
"robotclass": "Robot"
|
||||
},
|
||||
{
|
||||
"name": "Addressable LED",
|
||||
"description": "Display a rainbow pattern on an addressable LED strip.",
|
||||
"tags": [
|
||||
"Hardware",
|
||||
"Basic Robot",
|
||||
"AddressableLEDs"
|
||||
],
|
||||
"foldername": "addressableled",
|
||||
"gradlebase": "java",
|
||||
"robotclass": "Robot"
|
||||
},
|
||||
{
|
||||
"name": "AprilTags Vision",
|
||||
"description": "On-roboRIO detection of AprilTags using an attached USB camera.",
|
||||
"tags": [
|
||||
"Vision",
|
||||
"AprilTags"
|
||||
],
|
||||
"foldername": "apriltagsvision",
|
||||
"gradlebase": "java",
|
||||
"robotclass": "Robot"
|
||||
},
|
||||
{
|
||||
"name": "PDP CAN Monitoring",
|
||||
"description": "Monitor Power Distribution data such as voltage, current, temperature, etc.",
|
||||
"tags": [
|
||||
"Hardware",
|
||||
"PDP",
|
||||
"SmartDashboard"
|
||||
],
|
||||
"foldername": "canpdp",
|
||||
"gradlebase": "java",
|
||||
"robotclass": "Robot"
|
||||
},
|
||||
{
|
||||
"name": "Digital Communication Sample",
|
||||
"description": "Communicates with external devices (such as an Arduino) using the roboRIO's DIO.",
|
||||
"tags": [
|
||||
"Hardware",
|
||||
"Digital Output"
|
||||
],
|
||||
"foldername": "digitalcommunication",
|
||||
"gradlebase": "java",
|
||||
"robotclass": "Robot",
|
||||
"hasunittests": true
|
||||
},
|
||||
{
|
||||
"name": "Duty Cycle Input",
|
||||
"description": "View duty-cycle input.",
|
||||
"tags": [
|
||||
"Hardware",
|
||||
"Duty Cycle",
|
||||
"SmartDashboard"
|
||||
],
|
||||
"foldername": "dutycycleinput",
|
||||
"gradlebase": "java",
|
||||
"robotclass": "Robot"
|
||||
},
|
||||
{
|
||||
"name": "EventLoop",
|
||||
"description": "Manage a ball system using EventLoop and BooleanEvent.",
|
||||
"tags": [
|
||||
"Basic Robot",
|
||||
"Flywheel",
|
||||
"EventLoop"
|
||||
],
|
||||
"foldername": "eventloop",
|
||||
"gradlebase": "java",
|
||||
"robotclass": "Robot"
|
||||
},
|
||||
{
|
||||
"name": "Flywheel BangBangController",
|
||||
"description": "A sample program to demonstrate the use of a BangBangController with a flywheel to control RPM",
|
||||
"tags": [
|
||||
"Flywheel",
|
||||
"Simulation",
|
||||
"Joystick"
|
||||
],
|
||||
"foldername": "flywheelbangbangcontroller",
|
||||
"gradlebase": "java",
|
||||
"robotclass": "Robot"
|
||||
},
|
||||
{
|
||||
"name": "HTTP Camera",
|
||||
"description": "Acquire images from an HTTP network camera and adds some annotation to the image (as you might do for showing operators the result of some image recognition), and sends it to the dashboard for display.",
|
||||
"tags": [
|
||||
"Vision"
|
||||
],
|
||||
"foldername": "httpcamera",
|
||||
"gradlebase": "java",
|
||||
"robotclass": "Robot"
|
||||
},
|
||||
{
|
||||
"name": "I2C Communication Sample",
|
||||
"description": "Communicate with external devices (such as an Arduino) using the roboRIO's I2C port.",
|
||||
"tags": [
|
||||
"Hardware",
|
||||
"I2C"
|
||||
],
|
||||
"foldername": "i2ccommunication",
|
||||
"gradlebase": "java",
|
||||
"robotclass": "Robot",
|
||||
"hasunittests": true
|
||||
},
|
||||
{
|
||||
"name": "Intermediate Vision",
|
||||
"description": "Acquire images from an attached USB camera and add some annotation to the image (as you might do for showing operators the result of some image recognition) and send it to the dashboard for display.",
|
||||
"tags": [
|
||||
"Vision"
|
||||
],
|
||||
"foldername": "intermediatevision",
|
||||
"gradlebase": "java",
|
||||
"robotclass": "Robot"
|
||||
},
|
||||
{
|
||||
"name": "Motor Control",
|
||||
"description": "Control a single motor with a joystick, displaying the movement of the motor using an encoder.",
|
||||
"tags": [
|
||||
"Basic Robot",
|
||||
"Encoder",
|
||||
"SmartDashboard",
|
||||
"Joystick"
|
||||
],
|
||||
"foldername": "motorcontrol",
|
||||
"gradlebase": "java",
|
||||
"robotclass": "Robot"
|
||||
},
|
||||
{
|
||||
"name": "Select Command Example",
|
||||
"description": "Use SelectCommand to select an autonomous routine.",
|
||||
"tags": [
|
||||
"Commandv2"
|
||||
],
|
||||
"foldername": "selectcommand",
|
||||
"gradlebase": "java",
|
||||
"robotclass": "Robot",
|
||||
"commandversion": 2
|
||||
},
|
||||
{
|
||||
"name": "Simple Vision",
|
||||
"description": "Use the CameraServer class to stream from a USB Webcam without processing the images.",
|
||||
"tags": [
|
||||
"Vision"
|
||||
],
|
||||
"foldername": "quickvision",
|
||||
"gradlebase": "java",
|
||||
"robotclass": "Robot"
|
||||
},
|
||||
{
|
||||
"name": "Solenoids",
|
||||
"description": "Control a single and double solenoid from joystick buttons.",
|
||||
"tags": [
|
||||
"Hardware",
|
||||
"Joystick",
|
||||
"Pneumatics"
|
||||
],
|
||||
"foldername": "solenoid",
|
||||
"gradlebase": "java",
|
||||
"robotclass": "Robot"
|
||||
}
|
||||
]
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// 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.solenoid;
|
||||
package org.wpilib.snippets.solenoid;
|
||||
|
||||
import org.wpilib.driverstation.Joystick;
|
||||
import org.wpilib.framework.TimedRobot;
|
||||
Reference in New Issue
Block a user