Initial checkin of unified hierarchy of WPILib 2015

This commit is contained in:
Brad Miller
2013-12-15 18:30:16 -05:00
commit 3178911eef
1560 changed files with 410007 additions and 0 deletions

View File

@@ -0,0 +1,31 @@
#include "$classname.h"
$classname::$classname() {
// Use Requires() here to declare subsystem dependencies
// eg. Requires(chassis);
}
// Called just before this Command runs the first time
void $classname::Initialize() {
}
// Called repeatedly when this Command is scheduled to run
void $classname::Execute() {
}
// Make this return true when this Command no longer needs to run execute()
bool $classname::IsFinished() {
return false;
}
// Called once after isFinished returns true
void $classname::End() {
}
// Called when another command which requires one or more of the same
// subsystems is scheduled to run
void $classname::Interrupted() {
}

View File

@@ -0,0 +1,21 @@
#ifndef $classname_H
#define $classname_H
#include "../CommandBase.h"
/**
*
*
* @author ExampleAuthor
*/
class $classname: public CommandBase {
public:
$classname();
virtual void Initialize();
virtual void Execute();
virtual bool IsFinished();
virtual void End();
virtual void Interrupted();
};
#endif

View File

@@ -0,0 +1,21 @@
#include "CommandBase.h"
#include "Subsystems/ExampleSubsystem.h"
#include "Commands/Scheduler.h"
CommandBase::CommandBase(const char *name) : Command(name) {
}
CommandBase::CommandBase() : Command() {
}
// Initialize a single static instance of all of your subsystems to NULL
ExampleSubsystem* CommandBase::examplesubsystem = NULL;
OI* CommandBase::oi = NULL;
void CommandBase::init() {
// Create a single static instance of all of your subsystems. The following
// line should be repeated for each subsystem in the project.
examplesubsystem = new ExampleSubsystem();
oi = new OI();
}

View File

@@ -0,0 +1,24 @@
#ifndef COMMAND_BASE_H
#define COMMAND_BASE_H
#include "Commands/Command.h"
#include "Subsystems/ExampleSubsystem.h"
#include "OI.h"
/**
* The base for all commands. All atomic commands should subclass CommandBase.
* CommandBase stores creates and stores each control system. To access a
* subsystem elsewhere in your code in your code use CommandBase.examplesubsystem
*/
class CommandBase: public Command {
public:
CommandBase(const char *name);
CommandBase();
static void init();
// Create a single static instance of all of your subsystems
static ExampleSubsystem *examplesubsystem;
static OI *oi;
};
#endif

View File

@@ -0,0 +1,21 @@
#include "$classname.h"
$classname::$classname() {
// Add Commands here:
// e.g. AddSequential(new Command1());
// AddSequential(new Command2());
// these will run in order.
// To run multiple commands at the same time,
// use AddParallel()
// e.g. AddParallel(new Command1());
// AddSequential(new Command2());
// Command1 and Command2 will run in parallel.
// A command group will require all of the subsystems that each member
// would require.
// e.g. if Command1 requires chassis, and Command2 requires arm,
// a CommandGroup containing them would require both the chassis and the
// arm.
}

View File

@@ -0,0 +1,17 @@
#ifndef $classname_H
#define $classname_H
#include "Commands/CommandGroup.h"
/**
*
*
* @author ExampleAuthor
*/
class $classname: public CommandGroup {
public:
$classname();
};
#endif

View File

@@ -0,0 +1,31 @@
#include "ExampleCommand.h"
ExampleCommand::ExampleCommand() {
// Use Requires() here to declare subsystem dependencies
// eg. Requires(chassis);
}
// Called just before this Command runs the first time
void ExampleCommand::Initialize() {
}
// Called repeatedly when this Command is scheduled to run
void ExampleCommand::Execute() {
}
// Make this return true when this Command no longer needs to run execute()
bool ExampleCommand::IsFinished() {
return false;
}
// Called once after isFinished returns true
void ExampleCommand::End() {
}
// Called when another command which requires one or more of the same
// subsystems is scheduled to run
void ExampleCommand::Interrupted() {
}

View File

@@ -0,0 +1,21 @@
#ifndef EXAMPLE_COMMAND_H
#define EXAMPLE_COMMAND_H
#include "../CommandBase.h"
/**
*
*
* @author ExampleAuthor
*/
class ExampleCommand: public CommandBase {
public:
ExampleCommand();
virtual void Initialize();
virtual void Execute();
virtual bool IsFinished();
virtual void End();
virtual void Interrupted();
};
#endif

View File

@@ -0,0 +1,16 @@
#include "ExampleSubsystem.h"
#include "../Robotmap.h"
ExampleSubsystem::ExampleSubsystem() : Subsystem("ExampleSubsystem") {
}
void ExampleSubsystem::InitDefaultCommand() {
// Set the default command for a subsystem here.
//SetDefaultCommand(new MySpecialCommand());
}
// Put methods for controlling this subsystem
// here. Call these from Commands.

View File

@@ -0,0 +1,20 @@
#ifndef EXAMPLE_SUBSYSTEM_H
#define EXAMPLE_SUBSYSTEM_H
#include "Commands/Subsystem.h"
#include "WPILib.h"
/**
*
*
* @author ExampleAuthor
*/
class ExampleSubsystem: public Subsystem {
private:
// It's desirable that everything possible under private except
// for methods that implement subsystem capabilities
public:
ExampleSubsystem();
void InitDefaultCommand();
};
#endif

View File

@@ -0,0 +1,5 @@
#include "OI.h"
OI::OI() {
// Process operator interface input here.
}

View File

@@ -0,0 +1,13 @@
#ifndef OI_H
#define OI_H
#include "WPILib.h"
class OI {
private:
public:
OI();
};
#endif

View File

@@ -0,0 +1,31 @@
#include "$classname.h"
#include "../Robotmap.h"
#include "SmartDashboard/SmartDashboard.h"
#include "LiveWindow/LiveWindow.h"
#@autogenerated_code("pid", "")
#parse("${exporter-path}PIDSubsystem-pid.cpp")
#end
$classname::$classname() : PIDSubsystem("$classname", 1.0, 0.0, 0.0) {
// Use these to get going:
// SetSetpoint() - Sets where the PID controller should move the system
// to
// Enable() - Enables the PID controller.
}
double $classname::ReturnPIDInput() {
// Return your input value for the PID loop
// e.g. a sensor, like a potentiometer:
// yourPot->SetAverageVoltage() / kYourMaxVoltage;
}
void $classname::UsePIDOutput(double output) {
// Use output to drive your system, like a motor
// e.g. yourMotor->Set(output);
}
void $classname::InitDefaultCommand() {
// Set the default command for a subsystem here.
//setDefaultCommand(new MySpecialCommand());
}

View File

@@ -0,0 +1,21 @@
#ifndef $classname_H
#define $classname_H
#include "Commands/PIDSubsystem.h"
#include "WPILib.h"
/**
*
*
* @author ExampleAuthor
*/
class $classname: public PIDSubsystem {
public:
$classname();
double ReturnPIDInput();
void UsePIDOutput(double output);
void InitDefaultCommand();
};
#endif

View File

@@ -0,0 +1,51 @@
//============================================================================
// Name : Robot.cpp
// Author :
// Version :
// Copyright :
// Description : Hello World in C++, Ansi-style
//============================================================================
#include "WPILib.h"
#include "Commands/Command.h"
#include "Commands/ExampleCommand.h"
#include "CommandBase.h"
class Robot : public IterativeRobot {
private:
Command *autonomousCommand;
LiveWindow *lw;
virtual void RobotInit() {
CommandBase::init();
autonomousCommand = new ExampleCommand();
lw = LiveWindow::GetInstance();
}
virtual void AutonomousInit() {
autonomousCommand->Start();
}
virtual void AutonomousPeriodic() {
Scheduler::GetInstance()->Run();
}
virtual void TeleopInit() {
// This makes sure that the autonomous stops running when
// teleop starts running. If you want the autonomous to
// continue until interrupted by another command, remove
// this line or comment it out.
autonomousCommand->Cancel();
}
virtual void TeleopPeriodic() {
Scheduler::GetInstance()->Run();
}
virtual void TestPeriodic() {
lw->Run();
}
};
START_ROBOT_CLASS(Robot);

View File

@@ -0,0 +1,22 @@
#ifndef ROBOTMAP_H
#define ROBOTMAP_H
/**
* The RobotMap is a mapping from the ports sensors and actuators are wired into
* to a variable name. This provides flexibility changing wiring, makes checking
* the wiring easier and significantly reduces the number of magic numbers
* floating around.
*/
// For example to map the left and right motors, you could define the
// following variables to use with your drivetrain subsystem.
// #define LEFTMOTOR 1
// #define RIGHTMOTOR 2
// If you are using multiple modules, make sure to define both the port
// number and the module. For example you with a rangefinder:
// #define RANGE_FINDER_PORT 1
// #define RANGE_FINDER_MODULE 1
#endif

View File

@@ -0,0 +1,15 @@
#include "$classname.h"
#include "../Robotmap.h"
$classname::$classname() : Subsystem("ExampleSubsystem") {
}
void $classname::InitDefaultCommand() {
// Set the default command for a subsystem here.
//SetDefaultCommand(new MySpecialCommand());
}
// Put methods for controlling this subsystem
// here. Call these from Commands.

View File

@@ -0,0 +1,20 @@
#ifndef $classname_H
#define $classname_H
#include "Commands/Subsystem.h"
#include "WPILib.h"
/**
*
*
* @author ExampleAuthor
*/
class $classname: public Subsystem {
private:
// It's desirable that everything possible under private except
// for methods that implement subsystem capabilities
public:
$classname();
void InitDefaultCommand();
};
#endif

View File

@@ -0,0 +1,13 @@
// TODO: convert into C++ template
import edu.wpi.first.wpilibj.command.Trigger;
/**
* New and improved C++
*/
public class $classname extends Trigger {
public boolean get() {
return false;
}
}

View File

@@ -0,0 +1,13 @@
// TODO: convert into C++ template
import edu.wpi.first.wpilibj.command.Trigger;
/**
* New and improved C++
*/
public class $classname extends Trigger {
public boolean get() {
return false;
}
}