mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
Version 4 Image
Updated the HAL library to work with the new version 3 headers from NI. There were multiple changes in this verison: more PWM generators were added, so the functions for setting PWM signals have been updated. UserWatchdog has been removed, and Watchdog has been removed from WPILib to accomodate for this. Digital selection has been consolidated to one function in the NI headers, so this has been updated in the HAL. New SPI and I2C libraries have been added, but need to be implemented in the HAL before they will work.
This commit is contained in:
committed by
Brad Miller
parent
b1ef116104
commit
4546abc8c5
@@ -1,31 +1,38 @@
|
||||
#include "$classname.h"
|
||||
|
||||
$classname::$classname() {
|
||||
$classname::$classname()
|
||||
{
|
||||
// Use Requires() here to declare subsystem dependencies
|
||||
// eg. Requires(chassis);
|
||||
}
|
||||
|
||||
// Called just before this Command runs the first time
|
||||
void $classname::Initialize() {
|
||||
|
||||
void $classname::Initialize()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Called repeatedly when this Command is scheduled to run
|
||||
void $classname::Execute() {
|
||||
|
||||
void $classname::Execute()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Make this return true when this Command no longer needs to run execute()
|
||||
bool $classname::IsFinished() {
|
||||
bool $classname::IsFinished()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Called once after isFinished returns true
|
||||
void $classname::End() {
|
||||
|
||||
void $classname::End()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Called when another command which requires one or more of the same
|
||||
// subsystems is scheduled to run
|
||||
void $classname::Interrupted() {
|
||||
void $classname::Interrupted()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@@ -3,19 +3,15 @@
|
||||
|
||||
#include "../CommandBase.h"
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author ExampleAuthor
|
||||
*/
|
||||
class $classname: public CommandBase {
|
||||
class $classname: public CommandBase
|
||||
{
|
||||
public:
|
||||
$classname();
|
||||
virtual void Initialize();
|
||||
virtual void Execute();
|
||||
virtual bool IsFinished();
|
||||
virtual void End();
|
||||
virtual void Interrupted();
|
||||
void Initialize();
|
||||
void Execute();
|
||||
bool IsFinished();
|
||||
void End();
|
||||
void Interrupted();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -2,20 +2,26 @@
|
||||
#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
|
||||
CommandBase::CommandBase(std::string name) :
|
||||
Command(name)
|
||||
{
|
||||
}
|
||||
|
||||
CommandBase::CommandBase() :
|
||||
Command()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
@@ -1,19 +1,20 @@
|
||||
#ifndef COMMAND_BASE_H
|
||||
#define COMMAND_BASE_H
|
||||
|
||||
#include <string>
|
||||
#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 {
|
||||
class CommandBase: public Command
|
||||
{
|
||||
public:
|
||||
CommandBase(const char *name);
|
||||
CommandBase(std::string name);
|
||||
CommandBase();
|
||||
static void init();
|
||||
// Create a single static instance of all of your subsystems
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
|
||||
#include "$classname.h"
|
||||
|
||||
$classname::$classname() {
|
||||
$classname::$classname()
|
||||
{
|
||||
// Add Commands here:
|
||||
// e.g. AddSequential(new Command1());
|
||||
// AddSequential(new Command2());
|
||||
|
||||
@@ -1,16 +1,11 @@
|
||||
|
||||
#ifndef $classname_H
|
||||
#define $classname_H
|
||||
|
||||
#include "Commands/CommandGroup.h"
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author ExampleAuthor
|
||||
*/
|
||||
class $classname: public CommandGroup {
|
||||
public:
|
||||
class $classname: public CommandGroup
|
||||
{
|
||||
public:
|
||||
$classname();
|
||||
};
|
||||
|
||||
|
||||
@@ -1,31 +1,38 @@
|
||||
#include "ExampleCommand.h"
|
||||
|
||||
ExampleCommand::ExampleCommand() {
|
||||
ExampleCommand::ExampleCommand()
|
||||
{
|
||||
// Use Requires() here to declare subsystem dependencies
|
||||
// eg. Requires(chassis);
|
||||
}
|
||||
|
||||
// Called just before this Command runs the first time
|
||||
void ExampleCommand::Initialize() {
|
||||
|
||||
void ExampleCommand::Initialize()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Called repeatedly when this Command is scheduled to run
|
||||
void ExampleCommand::Execute() {
|
||||
|
||||
void ExampleCommand::Execute()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Make this return true when this Command no longer needs to run execute()
|
||||
bool ExampleCommand::IsFinished() {
|
||||
bool ExampleCommand::IsFinished()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Called once after isFinished returns true
|
||||
void ExampleCommand::End() {
|
||||
|
||||
void ExampleCommand::End()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Called when another command which requires one or more of the same
|
||||
// subsystems is scheduled to run
|
||||
void ExampleCommand::Interrupted() {
|
||||
void ExampleCommand::Interrupted()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@@ -3,19 +3,15 @@
|
||||
|
||||
#include "../CommandBase.h"
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author ExampleAuthor
|
||||
*/
|
||||
class ExampleCommand: public CommandBase {
|
||||
class ExampleCommand: public CommandBase
|
||||
{
|
||||
public:
|
||||
ExampleCommand();
|
||||
virtual void Initialize();
|
||||
virtual void Execute();
|
||||
virtual bool IsFinished();
|
||||
virtual void End();
|
||||
virtual void Interrupted();
|
||||
void Initialize();
|
||||
void Execute();
|
||||
bool IsFinished();
|
||||
void End();
|
||||
void Interrupted();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,16 +1,17 @@
|
||||
#include "ExampleSubsystem.h"
|
||||
#include "../Robotmap.h"
|
||||
#include "../RobotMap.h"
|
||||
ExampleSubsystem::ExampleSubsystem() :
|
||||
Subsystem("ExampleSubsystem")
|
||||
{
|
||||
|
||||
ExampleSubsystem::ExampleSubsystem() : Subsystem("ExampleSubsystem") {
|
||||
|
||||
}
|
||||
|
||||
void ExampleSubsystem::InitDefaultCommand() {
|
||||
|
||||
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.
|
||||
|
||||
|
||||
@@ -1,14 +1,11 @@
|
||||
#ifndef EXAMPLE_SUBSYSTEM_H
|
||||
#define EXAMPLE_SUBSYSTEM_H
|
||||
|
||||
#include "Commands/Subsystem.h"
|
||||
#include "WPILib.h"
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author ExampleAuthor
|
||||
*/
|
||||
class ExampleSubsystem: public Subsystem {
|
||||
class ExampleSubsystem: public Subsystem
|
||||
{
|
||||
private:
|
||||
// It's desirable that everything possible under private except
|
||||
// for methods that implement subsystem capabilities
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "OI.h"
|
||||
|
||||
OI::OI() {
|
||||
OI::OI()
|
||||
{
|
||||
// Process operator interface input here.
|
||||
}
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
|
||||
#include "WPILib.h"
|
||||
|
||||
class OI {
|
||||
class OI
|
||||
{
|
||||
private:
|
||||
|
||||
public:
|
||||
|
||||
@@ -1,31 +1,35 @@
|
||||
|
||||
#include "$classname.h"
|
||||
#include "../Robotmap.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) {
|
||||
$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() {
|
||||
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) {
|
||||
void $classname::UsePIDOutput(double output)
|
||||
{
|
||||
// Use output to drive your system, like a motor
|
||||
// e.g. yourMotor->Set(output);
|
||||
}
|
||||
|
||||
void $classname::InitDefaultCommand() {
|
||||
void $classname::InitDefaultCommand()
|
||||
{
|
||||
// Set the default command for a subsystem here.
|
||||
//setDefaultCommand(new MySpecialCommand());
|
||||
}
|
||||
|
||||
@@ -1,17 +1,12 @@
|
||||
|
||||
#ifndef $classname_H
|
||||
#define $classname_H
|
||||
|
||||
#include "Commands/PIDSubsystem.h"
|
||||
#include "WPILib.h"
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author ExampleAuthor
|
||||
*/
|
||||
class $classname: public PIDSubsystem {
|
||||
public:
|
||||
class $classname: public PIDSubsystem
|
||||
{
|
||||
public:
|
||||
$classname();
|
||||
double ReturnPIDInput();
|
||||
void UsePIDOutput(double output);
|
||||
|
||||
@@ -1,48 +1,47 @@
|
||||
//============================================================================
|
||||
// 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 {
|
||||
class Robot: public IterativeRobot
|
||||
{
|
||||
private:
|
||||
Command *autonomousCommand;
|
||||
LiveWindow *lw;
|
||||
|
||||
virtual void RobotInit() {
|
||||
|
||||
void RobotInit()
|
||||
{
|
||||
CommandBase::init();
|
||||
autonomousCommand = new ExampleCommand();
|
||||
lw = LiveWindow::GetInstance();
|
||||
}
|
||||
|
||||
virtual void AutonomousInit() {
|
||||
|
||||
void AutonomousInit()
|
||||
{
|
||||
autonomousCommand->Start();
|
||||
}
|
||||
|
||||
virtual void AutonomousPeriodic() {
|
||||
|
||||
void AutonomousPeriodic()
|
||||
{
|
||||
Scheduler::GetInstance()->Run();
|
||||
}
|
||||
|
||||
virtual void TeleopInit() {
|
||||
|
||||
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() {
|
||||
|
||||
void TeleopPeriodic()
|
||||
{
|
||||
Scheduler::GetInstance()->Run();
|
||||
}
|
||||
|
||||
virtual void TestPeriodic() {
|
||||
|
||||
void TestPeriodic()
|
||||
{
|
||||
lw->Run();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -11,12 +11,12 @@
|
||||
|
||||
// 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
|
||||
//const int LEFTMOTOR = 1;
|
||||
//const int 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
|
||||
//const int RANGE_FINDER_PORT = 1;
|
||||
//const int RANGE_FINDER_MODULE = 1;
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,15 +1,17 @@
|
||||
#include "$classname.h"
|
||||
#include "../Robotmap.h"
|
||||
#include "../RobotMap.h"
|
||||
|
||||
$classname::$classname() :
|
||||
Subsystem("ExampleSubsystem")
|
||||
{
|
||||
|
||||
$classname::$classname() : Subsystem("ExampleSubsystem") {
|
||||
|
||||
}
|
||||
|
||||
void $classname::InitDefaultCommand() {
|
||||
|
||||
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.
|
||||
|
||||
@@ -1,14 +1,11 @@
|
||||
#ifndef $classname_H
|
||||
#define $classname_H
|
||||
|
||||
#include "Commands/Subsystem.h"
|
||||
#include "WPILib.h"
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author ExampleAuthor
|
||||
*/
|
||||
class $classname: public Subsystem {
|
||||
class $classname: public Subsystem
|
||||
{
|
||||
private:
|
||||
// It's desirable that everything possible under private except
|
||||
// for methods that implement subsystem capabilities
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
// TODO: convert into C++ template
|
||||
|
||||
#error "This is not a C++ file. I have no idea what this is doing here, so I'm leaving this message here to let someone else clean this up"
|
||||
import edu.wpi.first.wpilibj.command.Trigger;
|
||||
|
||||
/**
|
||||
* New and improved C++
|
||||
*/
|
||||
public class $classname extends Trigger {
|
||||
|
||||
public boolean get() {
|
||||
return false;
|
||||
}
|
||||
public class $classname extends Trigger
|
||||
{
|
||||
public:
|
||||
bool get()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,9 @@
|
||||
// TODO: convert into C++ template
|
||||
|
||||
#error "This is not a C++ file. I have no idea what this is doing here, so I'm leaving this message here to let someone else clean this up"
|
||||
import edu.wpi.first.wpilibj.command.Trigger;
|
||||
|
||||
/**
|
||||
* New and improved C++
|
||||
*/
|
||||
public class $classname extends Trigger {
|
||||
|
||||
public boolean get() {
|
||||
return false;
|
||||
}
|
||||
public class $classname extends Trigger
|
||||
{
|
||||
public:
|
||||
bool get();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user