mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
Replace IterativeRobot in examples with TimedRobot (#1310)
Fixes #1309.
This commit is contained in:
committed by
Peter Johnson
parent
59386635e7
commit
bedef476fd
@@ -16,7 +16,7 @@ import edu.wpi.cscore.AxisCamera;
|
||||
import edu.wpi.cscore.CvSink;
|
||||
import edu.wpi.cscore.CvSource;
|
||||
import edu.wpi.first.wpilibj.CameraServer;
|
||||
import edu.wpi.first.wpilibj.IterativeRobot;
|
||||
import edu.wpi.first.wpilibj.TimedRobot;
|
||||
|
||||
/**
|
||||
* This is a demo program showing the use of OpenCV to do vision processing. The
|
||||
@@ -24,7 +24,7 @@ import edu.wpi.first.wpilibj.IterativeRobot;
|
||||
* and sent to the dashboard. OpenCV has many methods for different types of
|
||||
* processing.
|
||||
*/
|
||||
public class Robot extends IterativeRobot {
|
||||
public class Robot extends TimedRobot {
|
||||
Thread m_visionThread;
|
||||
|
||||
@Override
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
package edu.wpi.first.wpilibj.examples.gearsbot;
|
||||
|
||||
import edu.wpi.first.wpilibj.IterativeRobot;
|
||||
import edu.wpi.first.wpilibj.TimedRobot;
|
||||
import edu.wpi.first.wpilibj.command.Command;
|
||||
import edu.wpi.first.wpilibj.command.Scheduler;
|
||||
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
|
||||
@@ -20,12 +20,12 @@ import edu.wpi.first.wpilibj.examples.gearsbot.subsystems.Wrist;
|
||||
|
||||
/**
|
||||
* The VM is configured to automatically run this class, and to call the
|
||||
* functions corresponding to each mode, as described in the IterativeRobot
|
||||
* functions corresponding to each mode, as described in the TimedRobot
|
||||
* documentation. If you change the name of this class or the package after
|
||||
* creating this project, you must also update the manifest file in the resource
|
||||
* directory.
|
||||
*/
|
||||
public class Robot extends IterativeRobot {
|
||||
public class Robot extends TimedRobot {
|
||||
Command m_autonomousCommand;
|
||||
|
||||
public static DriveTrain m_drivetrain;
|
||||
|
||||
@@ -7,20 +7,20 @@
|
||||
|
||||
package edu.wpi.first.wpilibj.examples.gettingstarted;
|
||||
|
||||
import edu.wpi.first.wpilibj.IterativeRobot;
|
||||
import edu.wpi.first.wpilibj.Joystick;
|
||||
import edu.wpi.first.wpilibj.Spark;
|
||||
import edu.wpi.first.wpilibj.TimedRobot;
|
||||
import edu.wpi.first.wpilibj.Timer;
|
||||
import edu.wpi.first.wpilibj.drive.DifferentialDrive;
|
||||
|
||||
/**
|
||||
* The VM is configured to automatically run this class, and to call the
|
||||
* functions corresponding to each mode, as described in the IterativeRobot
|
||||
* functions corresponding to each mode, as described in the TimedRobot
|
||||
* documentation. If you change the name of this class or the package after
|
||||
* creating this project, you must also update the manifest file in the resource
|
||||
* directory.
|
||||
*/
|
||||
public class Robot extends IterativeRobot {
|
||||
public class Robot extends TimedRobot {
|
||||
private final DifferentialDrive m_robotDrive
|
||||
= new DifferentialDrive(new Spark(0), new Spark(1));
|
||||
private final Joystick m_stick = new Joystick(0);
|
||||
|
||||
@@ -8,9 +8,9 @@
|
||||
package edu.wpi.first.wpilibj.examples.gyro;
|
||||
|
||||
import edu.wpi.first.wpilibj.AnalogGyro;
|
||||
import edu.wpi.first.wpilibj.IterativeRobot;
|
||||
import edu.wpi.first.wpilibj.Joystick;
|
||||
import edu.wpi.first.wpilibj.Spark;
|
||||
import edu.wpi.first.wpilibj.TimedRobot;
|
||||
import edu.wpi.first.wpilibj.drive.DifferentialDrive;
|
||||
|
||||
/**
|
||||
@@ -18,7 +18,7 @@ import edu.wpi.first.wpilibj.drive.DifferentialDrive;
|
||||
* robot drive straight. This program uses a joystick to drive forwards and
|
||||
* backwards while the gyro is used for direction keeping.
|
||||
*/
|
||||
public class Robot extends IterativeRobot {
|
||||
public class Robot extends TimedRobot {
|
||||
private static final double kAngleSetpoint = 0.0;
|
||||
private static final double kP = 0.005; // propotional turning constant
|
||||
|
||||
|
||||
@@ -8,9 +8,9 @@
|
||||
package edu.wpi.first.wpilibj.examples.gyromecanum;
|
||||
|
||||
import edu.wpi.first.wpilibj.AnalogGyro;
|
||||
import edu.wpi.first.wpilibj.IterativeRobot;
|
||||
import edu.wpi.first.wpilibj.Joystick;
|
||||
import edu.wpi.first.wpilibj.Spark;
|
||||
import edu.wpi.first.wpilibj.TimedRobot;
|
||||
import edu.wpi.first.wpilibj.drive.MecanumDrive;
|
||||
|
||||
/**
|
||||
@@ -18,7 +18,7 @@ import edu.wpi.first.wpilibj.drive.MecanumDrive;
|
||||
* maintian rotation vectorsin relation to the starting orientation of the robot
|
||||
* (field-oriented controls).
|
||||
*/
|
||||
public class Robot extends IterativeRobot {
|
||||
public class Robot extends TimedRobot {
|
||||
// gyro calibration constant, may need to be adjusted;
|
||||
// gyro value of 360 is set to correspond to one full revolution
|
||||
private static final double kVoltsPerDegreePerSecond = 0.0128;
|
||||
|
||||
@@ -16,7 +16,7 @@ import edu.wpi.cscore.CvSink;
|
||||
import edu.wpi.cscore.CvSource;
|
||||
import edu.wpi.cscore.UsbCamera;
|
||||
import edu.wpi.first.wpilibj.CameraServer;
|
||||
import edu.wpi.first.wpilibj.IterativeRobot;
|
||||
import edu.wpi.first.wpilibj.TimedRobot;
|
||||
|
||||
/**
|
||||
* This is a demo program showing the use of OpenCV to do vision processing. The
|
||||
@@ -24,7 +24,7 @@ import edu.wpi.first.wpilibj.IterativeRobot;
|
||||
* and sent to the dashboard. OpenCV has many methods for different types of
|
||||
* processing.
|
||||
*/
|
||||
public class Robot extends IterativeRobot {
|
||||
public class Robot extends TimedRobot {
|
||||
Thread m_visionThread;
|
||||
|
||||
@Override
|
||||
|
||||
@@ -7,16 +7,16 @@
|
||||
|
||||
package edu.wpi.first.wpilibj.examples.mecanumdrive;
|
||||
|
||||
import edu.wpi.first.wpilibj.IterativeRobot;
|
||||
import edu.wpi.first.wpilibj.Joystick;
|
||||
import edu.wpi.first.wpilibj.Spark;
|
||||
import edu.wpi.first.wpilibj.TimedRobot;
|
||||
import edu.wpi.first.wpilibj.drive.MecanumDrive;
|
||||
|
||||
/**
|
||||
* This is a demo program showing how to use Mecanum control with the RobotDrive
|
||||
* class.
|
||||
*/
|
||||
public class Robot extends IterativeRobot {
|
||||
public class Robot extends TimedRobot {
|
||||
private static final int kFrontLeftChannel = 2;
|
||||
private static final int kRearLeftChannel = 3;
|
||||
private static final int kFrontRightChannel = 1;
|
||||
|
||||
@@ -7,10 +7,10 @@
|
||||
|
||||
package edu.wpi.first.wpilibj.examples.motorcontrol;
|
||||
|
||||
import edu.wpi.first.wpilibj.IterativeRobot;
|
||||
import edu.wpi.first.wpilibj.Joystick;
|
||||
import edu.wpi.first.wpilibj.Spark;
|
||||
import edu.wpi.first.wpilibj.SpeedController;
|
||||
import edu.wpi.first.wpilibj.TimedRobot;
|
||||
|
||||
/**
|
||||
* This sample program shows how to control a motor using a joystick. In the
|
||||
@@ -20,7 +20,7 @@ import edu.wpi.first.wpilibj.SpeedController;
|
||||
* <p>Joystick analog values range from -1 to 1 and speed controller inputs also
|
||||
* range from -1 to 1 making it easy to work together.
|
||||
*/
|
||||
public class Robot extends IterativeRobot {
|
||||
public class Robot extends TimedRobot {
|
||||
private static final int kMotorPort = 0;
|
||||
private static final int kJoystickPort = 0;
|
||||
|
||||
|
||||
@@ -8,10 +8,10 @@
|
||||
package edu.wpi.first.wpilibj.examples.motorcontrolencoder;
|
||||
|
||||
import edu.wpi.first.wpilibj.Encoder;
|
||||
import edu.wpi.first.wpilibj.IterativeRobot;
|
||||
import edu.wpi.first.wpilibj.Joystick;
|
||||
import edu.wpi.first.wpilibj.Spark;
|
||||
import edu.wpi.first.wpilibj.SpeedController;
|
||||
import edu.wpi.first.wpilibj.TimedRobot;
|
||||
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
|
||||
|
||||
/**
|
||||
@@ -25,7 +25,7 @@ import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
|
||||
* <p>In addition, the encoder value of an encoder connected to ports 0 and 1 is
|
||||
* consistently sent to the Dashboard.
|
||||
*/
|
||||
public class Robot extends IterativeRobot {
|
||||
public class Robot extends TimedRobot {
|
||||
private static final int kMotorPort = 0;
|
||||
private static final int kJoystickPort = 0;
|
||||
private static final int kEncoderPortA = 0;
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
package edu.wpi.first.wpilibj.examples.pacgoat;
|
||||
|
||||
import edu.wpi.first.wpilibj.IterativeRobot;
|
||||
import edu.wpi.first.wpilibj.TimedRobot;
|
||||
import edu.wpi.first.wpilibj.command.Command;
|
||||
import edu.wpi.first.wpilibj.command.Scheduler;
|
||||
import edu.wpi.first.wpilibj.smartdashboard.SendableChooser;
|
||||
@@ -25,12 +25,12 @@ import edu.wpi.first.wpilibj.examples.pacgoat.subsystems.Shooter;
|
||||
* This is the main class for running the PacGoat code.
|
||||
*
|
||||
* <p>The VM is configured to automatically run this class, and to call the
|
||||
* functions corresponding to each mode, as described in the IterativeRobot
|
||||
* functions corresponding to each mode, as described in the TimedRobot
|
||||
* documentation. If you change the name of this class or the package after
|
||||
* creating this project, you must also update the manifest file in the resource
|
||||
* directory.
|
||||
*/
|
||||
public class Robot extends IterativeRobot {
|
||||
public class Robot extends TimedRobot {
|
||||
Command m_autonomousCommand;
|
||||
public static OI oi;
|
||||
|
||||
|
||||
@@ -8,18 +8,18 @@
|
||||
package edu.wpi.first.wpilibj.examples.potentiometerpid;
|
||||
|
||||
import edu.wpi.first.wpilibj.AnalogInput;
|
||||
import edu.wpi.first.wpilibj.IterativeRobot;
|
||||
import edu.wpi.first.wpilibj.Joystick;
|
||||
import edu.wpi.first.wpilibj.PIDController;
|
||||
import edu.wpi.first.wpilibj.Spark;
|
||||
import edu.wpi.first.wpilibj.SpeedController;
|
||||
import edu.wpi.first.wpilibj.TimedRobot;
|
||||
|
||||
/**
|
||||
* 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 IterativeRobot {
|
||||
public class Robot extends TimedRobot {
|
||||
private static final int kPotChannel = 1;
|
||||
private static final int kMotorChannel = 7;
|
||||
private static final int kJoystickChannel = 0;
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
package edu.wpi.first.wpilibj.examples.quickvision;
|
||||
|
||||
import edu.wpi.first.wpilibj.CameraServer;
|
||||
import edu.wpi.first.wpilibj.IterativeRobot;
|
||||
import edu.wpi.first.wpilibj.TimedRobot;
|
||||
|
||||
/**
|
||||
* Uses the CameraServer class to automatically capture video from a USB webcam
|
||||
@@ -16,7 +16,7 @@ import edu.wpi.first.wpilibj.IterativeRobot;
|
||||
* is the easiest way to get camera images to the dashboard. Just add this to
|
||||
* the robotInit() method in your program.
|
||||
*/
|
||||
public class Robot extends IterativeRobot {
|
||||
public class Robot extends TimedRobot {
|
||||
@Override
|
||||
public void robotInit() {
|
||||
CameraServer.getInstance().startAutomaticCapture();
|
||||
|
||||
@@ -7,16 +7,16 @@
|
||||
|
||||
package edu.wpi.first.wpilibj.examples.tankdrive;
|
||||
|
||||
import edu.wpi.first.wpilibj.IterativeRobot;
|
||||
import edu.wpi.first.wpilibj.Joystick;
|
||||
import edu.wpi.first.wpilibj.Spark;
|
||||
import edu.wpi.first.wpilibj.TimedRobot;
|
||||
import edu.wpi.first.wpilibj.drive.DifferentialDrive;
|
||||
|
||||
/**
|
||||
* This is a demo program showing the use of the RobotDrive class, specifically
|
||||
* it contains the code necessary to operate a robot with tank drive.
|
||||
*/
|
||||
public class Robot extends IterativeRobot {
|
||||
public class Robot extends TimedRobot {
|
||||
private DifferentialDrive m_myRobot;
|
||||
private Joystick m_leftStick;
|
||||
private Joystick m_rightStick;
|
||||
|
||||
@@ -8,8 +8,8 @@
|
||||
package edu.wpi.first.wpilibj.examples.ultrasonic;
|
||||
|
||||
import edu.wpi.first.wpilibj.AnalogInput;
|
||||
import edu.wpi.first.wpilibj.IterativeRobot;
|
||||
import edu.wpi.first.wpilibj.Spark;
|
||||
import edu.wpi.first.wpilibj.TimedRobot;
|
||||
import edu.wpi.first.wpilibj.drive.DifferentialDrive;
|
||||
|
||||
/**
|
||||
@@ -17,7 +17,7 @@ import edu.wpi.first.wpilibj.drive.DifferentialDrive;
|
||||
* proportional control to maintain a set distance from an object.
|
||||
*/
|
||||
|
||||
public class Robot extends IterativeRobot {
|
||||
public class Robot extends TimedRobot {
|
||||
// distance in inches the robot wants to stay from an object
|
||||
private static final double kHoldDistance = 12.0;
|
||||
|
||||
|
||||
@@ -8,17 +8,17 @@
|
||||
package edu.wpi.first.wpilibj.examples.ultrasonicpid;
|
||||
|
||||
import edu.wpi.first.wpilibj.AnalogInput;
|
||||
import edu.wpi.first.wpilibj.IterativeRobot;
|
||||
import edu.wpi.first.wpilibj.PIDController;
|
||||
import edu.wpi.first.wpilibj.PIDOutput;
|
||||
import edu.wpi.first.wpilibj.Spark;
|
||||
import edu.wpi.first.wpilibj.TimedRobot;
|
||||
import edu.wpi.first.wpilibj.drive.DifferentialDrive;
|
||||
|
||||
/**
|
||||
* This is a sample program to demonstrate the use of a PIDController with an
|
||||
* ultrasonic sensor to reach and maintain a set distance from an object.
|
||||
*/
|
||||
public class Robot extends IterativeRobot {
|
||||
public class Robot extends TimedRobot {
|
||||
// distance in inches the robot wants to stay from an object
|
||||
private static final double kHoldDistance = 12.0;
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
|
||||
*
|
||||
* <p>WARNING: While it may look like a good choice to use for your code if
|
||||
* you're inexperienced, don't. Unless you know what you are doing, complex code
|
||||
* will be much more difficult under this system. Use IterativeRobot or
|
||||
* will be much more difficult under this system. Use TimedRobot or
|
||||
* Command-Based instead if you're new.
|
||||
*/
|
||||
public class Robot extends SampleRobot {
|
||||
@@ -63,7 +63,7 @@ public class Robot extends SampleRobot {
|
||||
* the if-else structure below with additional strings. If using the
|
||||
* SendableChooser make sure to add them to the chooser code above as well.
|
||||
*
|
||||
* <p>If you wanted to run a similar autonomous mode with an IterativeRobot
|
||||
* <p>If you wanted to run a similar autonomous mode with an TimedRobot
|
||||
* you would write:
|
||||
*
|
||||
* <blockquote><pre>{@code
|
||||
@@ -124,7 +124,7 @@ public class Robot extends SampleRobot {
|
||||
/**
|
||||
* Runs the motors with arcade steering.
|
||||
*
|
||||
* <p>If you wanted to run a similar teleoperated mode with an IterativeRobot
|
||||
* <p>If you wanted to run a similar teleoperated mode with an TimedRobot
|
||||
* you would write:
|
||||
*
|
||||
* <blockquote><pre>{@code
|
||||
|
||||
Reference in New Issue
Block a user