Merge "Completed artf2675 - rename SimpleRobot -> SampleRobot."

This commit is contained in:
Thomas Clark (WPI)
2014-08-08 12:39:14 -07:00
committed by Gerrit Code Review
12 changed files with 100 additions and 79 deletions

View File

@@ -1,12 +1,16 @@
#include "WPILib.h"
/**
* This is a demo program showing the use of the RobotBase class.
* The SimpleRobot class is the base of a robot application that will automatically call your
* This is a demo program showing the use of the RobotDrive class.
* The SampleRobot class is the base of a robot application that will automatically call your
* Autonomous and OperatorControl methods at the right time as controlled by the switches on
* the driver station or the field controls.
*
* 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 Command-Based instead if you're new.
*/
class Robot: public SimpleRobot
class Robot: public SampleRobot
{
RobotDrive myRobot; // robot drive system
Joystick stick; // only joystick
@@ -31,7 +35,7 @@ public:
}
/**
* Runs the motors with arcade steering.
* Runs the motors with arcade steering.
*/
void OperatorControl()
{
@@ -48,7 +52,6 @@ public:
*/
void Test()
{
}
};

View File

@@ -0,0 +1,59 @@
package $package;
import edu.wpi.first.wpilibj.SampleRobot;
/**
* This is a demo program showing the use of the RobotDrive class.
* The SampleRobot class is the base of a robot application that will automatically call your
* Autonomous and OperatorControl methods at the right time as controlled by the switches on
* the driver station or the field controls.
*
* The VM is configured to automatically run this class, and to call the
* functions corresponding to each mode, as described in the SampleRobot
* 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.
*
* 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 Command-Based instead if you're new.
*/
public class Robot extends SampleRobot {
RobotDrive myRobot;
Joystick stick;
public Robot() {
myRobot = new RobotDrive(1, 2);
myRobot.setExpiration(0.1);
stick = new Joystick(1);
}
/**
* Drive left & right motors for 2 seconds then stop
*/
public void autonomous() {
myRobot.setSafetyEnabled(false);
myRobot.drive(-0.5, 0.0); // drive forwards half speed
Timer.delay(2.0); // for 2 seconds
myRobot.drive(0.0, 0.0); // stop robot
}
/**
* Runs the motors with arcade steering.
*/
public void operatorControl() {
myRobot.setSafetyEnabled(true);
while (isOperatorControl()) {
myRobot.arcadeDrive(stick); // drive with arcade style (use right stick)
Timer.delay(0.005); // wait for a motor update time
}
}
/**
* Runs during test mode
*/
public void test() {
}
}

View File

@@ -1,35 +0,0 @@
package $package;
import edu.wpi.first.wpilibj.SimpleRobot;
/**
* The VM is configured to automatically run this class, and to call the
* functions corresponding to each mode, as described in the SimpleRobot
* 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 SimpleRobot {
/**
* This function is called once each time the robot enters autonomous mode.
*/
public void autonomous() {
}
/**
* This function is called once each time the robot enters operator control.
*/
public void operatorControl() {
}
/**
* This function is called once each time the robot enters test mode.
*/
public void test() {
}
}

View File

@@ -7,14 +7,11 @@
#include "RobotBase.h"
/**
* @todo If this is going to last until release, it needs a better name.
*/
class SimpleRobot : public RobotBase
class SampleRobot : public RobotBase
{
public:
SimpleRobot();
virtual ~SimpleRobot() {}
SampleRobot();
virtual ~SampleRobot() {}
virtual void RobotInit();
virtual void Disabled();
virtual void Autonomous();

View File

@@ -67,7 +67,7 @@
#include "SensorBase.h"
#include "SerialPort.h"
#include "Servo.h"
#include "SimpleRobot.h"
#include "SampleRobot.h"
#include "SmartDashboard/SendableChooser.h"
#include "SmartDashboard/SmartDashboard.h"
#include "Solenoid.h"

View File

@@ -4,7 +4,7 @@
/* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib. */
/*----------------------------------------------------------------------------*/
#include "SimpleRobot.h"
#include "SampleRobot.h"
#include "DriverStation.h"
//#include "NetworkCommunication/UsageReporting.h"
@@ -13,7 +13,7 @@
#include "LiveWindow/LiveWindow.h"
#include "networktables/NetworkTable.h"
SimpleRobot::SimpleRobot()
SampleRobot::SampleRobot()
: m_robotMainOverridden (true)
{
}
@@ -24,7 +24,7 @@ SimpleRobot::SimpleRobot()
* Programmers should override this method for default Robot-wide initialization which will
* be called each time the robot enters the disabled state.
*/
void SimpleRobot::RobotInit()
void SampleRobot::RobotInit()
{
printf("Default %s() method... Override me!\n", __FUNCTION__);
}
@@ -34,7 +34,7 @@ void SimpleRobot::RobotInit()
* Programmers should override this method to run code that should run while the field is
* disabled.
*/
void SimpleRobot::Disabled()
void SampleRobot::Disabled()
{
printf("Default %s() method... Override me!\n", __FUNCTION__);
}
@@ -45,7 +45,7 @@ void SimpleRobot::Disabled()
* in the autonomous period. This will be called once each time the robot enters the
* autonomous state.
*/
void SimpleRobot::Autonomous()
void SampleRobot::Autonomous()
{
printf("Default %s() method... Override me!\n", __FUNCTION__);
}
@@ -56,7 +56,7 @@ void SimpleRobot::Autonomous()
* in the Operator Control (tele-operated) period. This is called once each time the robot
* enters the teleop state.
*/
void SimpleRobot::OperatorControl()
void SampleRobot::OperatorControl()
{
printf("Default %s() method... Override me!\n", __FUNCTION__);
}
@@ -66,7 +66,7 @@ void SimpleRobot::OperatorControl()
* Programmers should override this method to run code that executes while the robot is
* in test mode. This will be called once whenever the robot enters test mode
*/
void SimpleRobot::Test()
void SampleRobot::Test()
{
printf("Default %s() method... Override me!\n", __FUNCTION__);
}
@@ -82,7 +82,7 @@ void SimpleRobot::Test()
* overridden by a user subclass (i.e. the default version runs), then the Autonomous() and
* OperatorControl() methods will be called.
*/
void SimpleRobot::RobotMain()
void SampleRobot::RobotMain()
{
m_robotMainOverridden = false;
}
@@ -95,7 +95,7 @@ void SimpleRobot::RobotMain()
* change, either the other mode starts or the robot is disabled. Then go back and wait for the
* robot to be enabled again.
*/
void SimpleRobot::StartCompetition()
void SampleRobot::StartCompetition()
{
LiveWindow *lw = LiveWindow::GetInstance();

View File

@@ -7,14 +7,11 @@
#include "RobotBase.h"
/**
* @todo If this is going to last until release, it needs a better name.
*/
class SimpleRobot : public RobotBase
class SampleRobot : public RobotBase
{
public:
SimpleRobot();
virtual ~SimpleRobot() {}
SampleRobot();
virtual ~SampleRobot() {}
virtual void RobotInit();
virtual void Disabled();
virtual void Autonomous();

View File

@@ -33,7 +33,7 @@
#include "SmartDashboard/SmartDashboard.h"
#include "RobotBase.h"
#include "SimpleRobot.h"
#include "SampleRobot.h"
#include "IterativeRobot.h"
#include "SpeedController.h"
#include "Talon.h"

View File

@@ -4,7 +4,7 @@
/* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib. */
/*----------------------------------------------------------------------------*/
#include "SimpleRobot.h"
#include "SampleRobot.h"
#include <stdio.h>
#include <unistd.h>
@@ -13,7 +13,7 @@
#include "LiveWindow/LiveWindow.h"
#include "networktables/NetworkTable.h"
SimpleRobot::SimpleRobot()
SampleRobot::SampleRobot()
: m_robotMainOverridden (true)
{
}
@@ -24,7 +24,7 @@ SimpleRobot::SimpleRobot()
* Programmers should override this method for default Robot-wide initialization which will
* be called each time the robot enters the disabled state.
*/
void SimpleRobot::RobotInit()
void SampleRobot::RobotInit()
{
printf("Default %s() method... Override me!\n", __FUNCTION__);
}
@@ -34,7 +34,7 @@ void SimpleRobot::RobotInit()
* Programmers should override this method to run code that should run while the field is
* disabled.
*/
void SimpleRobot::Disabled()
void SampleRobot::Disabled()
{
printf("Default %s() method... Override me!\n", __FUNCTION__);
}
@@ -45,7 +45,7 @@ void SimpleRobot::Disabled()
* in the autonomous period. This will be called once each time the robot enters the
* autonomous state.
*/
void SimpleRobot::Autonomous()
void SampleRobot::Autonomous()
{
printf("Default %s() method... Override me!\n", __FUNCTION__);
}
@@ -56,7 +56,7 @@ void SimpleRobot::Autonomous()
* in the Operator Control (tele-operated) period. This is called once each time the robot
* enters the teleop state.
*/
void SimpleRobot::OperatorControl()
void SampleRobot::OperatorControl()
{
printf("Default %s() method... Override me!\n", __FUNCTION__);
}
@@ -66,7 +66,7 @@ void SimpleRobot::OperatorControl()
* Programmers should override this method to run code that executes while the robot is
* in test mode. This will be called once whenever the robot enters test mode
*/
void SimpleRobot::Test()
void SampleRobot::Test()
{
printf("Default %s() method... Override me!\n", __FUNCTION__);
}
@@ -82,7 +82,7 @@ void SimpleRobot::Test()
* overridden by a user subclass (i.e. the default version runs), then the Autonomous() and
* OperatorControl() methods will be called.
*/
void SimpleRobot::RobotMain()
void SampleRobot::RobotMain()
{
m_robotMainOverridden = false;
}
@@ -95,7 +95,7 @@ void SimpleRobot::RobotMain()
* change, either the other mode starts or the robot is disabled. Then go back and wait for the
* robot to be enabled again.
*/
void SimpleRobot::StartCompetition()
void SampleRobot::StartCompetition()
{
LiveWindow *lw = LiveWindow::GetInstance();

View File

@@ -23,14 +23,14 @@ import edu.wpi.first.wpilibj.livewindow.LiveWindow;
*
* Alternatively you can override the robotMain() method and manage all aspects of the robot yourself.
*/
public class SimpleRobot extends RobotBase {
public class SampleRobot extends RobotBase {
private boolean m_robotMainOverridden;
/**
* Create a new SimpleRobot
* Create a new SampleRobot
*/
public SimpleRobot() {
public SampleRobot() {
super();
m_robotMainOverridden = true;
}

View File

@@ -1,7 +1,7 @@
Specific Issues
===============
- SimpleRobot.java (support for telling the DriverStation the current mode)
- SampleRobot.java (support for telling the DriverStation the current mode)
- Iterative.java (support for telling the DriverStation the current mode and nextPeriodReady())
- command/WaitUntilCommand.java (Needs DriverStation)
- command/Command.java (XXX Issue with DriverStation)

View File

@@ -20,14 +20,14 @@ import edu.wpi.first.wpilibj.livewindow.LiveWindow;
*
* Alternatively you can override the robotMain() method and manage all aspects of the robot yourself.
*/
public class SimpleRobot extends RobotBase {
public class SampleRobot extends RobotBase {
private boolean m_robotMainOverridden;
/**
* Create a new SimpleRobot
* Create a new SampleRobot
*/
public SimpleRobot() {
public SampleRobot() {
super();
m_robotMainOverridden = true;
}