mirror of
https://github.com/team2059/Dent
synced 2024-12-18 20:52:29 -05:00
Merged with feature/command-based
This commit is contained in:
commit
e657226af5
15
.env
15
.env
@ -1,15 +0,0 @@
|
||||
function mb(){
|
||||
vagrant ssh -c "cd /vagrant/src;make clean 2>&1 >/dev/null;make"
|
||||
}
|
||||
function mc(){
|
||||
vagrant ssh -c "cd /vagrant/src;make clean 2>&1 >/dev/null"
|
||||
}
|
||||
function mk(){
|
||||
vagrant ssh -c "cd /vagrant/src;make"
|
||||
}
|
||||
function me(){
|
||||
vagrant ssh -c "cd /vagrant/src;make deploy"
|
||||
}
|
||||
function ma(){
|
||||
vagrant ssh -c "cd /vagrant/src;make clean 2>&1 >/dev/null;make;make deploy"
|
||||
}
|
3
.gitmodules
vendored
3
.gitmodules
vendored
@ -1,3 +0,0 @@
|
||||
[submodule "src/hhlib"]
|
||||
path = src/hhlib
|
||||
url = git@github.com:team2059/hhlib.git
|
@ -2,9 +2,11 @@
|
||||
#include "Subsystems/Drivetrain.h"
|
||||
#include "Subsystems/Collector.h"
|
||||
#include "Subsystems/Elevator.h"
|
||||
#include "Subsystems/BinElevator.h"
|
||||
Drivetrain* CommandBase::drivetrain = NULL;
|
||||
Collector* CommandBase::collector = NULL;
|
||||
Elevator* CommandBase::elevator = NULL;
|
||||
BinElevator* CommandBase::binElevator = NULL;
|
||||
OI* CommandBase::oi = NULL;
|
||||
CommandBase::CommandBase(char const *name) : Command(name) {
|
||||
}
|
||||
@ -14,6 +16,7 @@ void CommandBase::init(){
|
||||
drivetrain = new Drivetrain();
|
||||
collector = new Collector();
|
||||
elevator = new Elevator();
|
||||
binElevator = new BinElevator();
|
||||
oi = new OI();
|
||||
}
|
||||
// vim: ts2:sw=2:et
|
||||
// vim: ts=2:sw=2:et
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include "Subsystems/Drivetrain.h"
|
||||
#include "Subsystems/Collector.h"
|
||||
#include "Subsystems/Elevator.h"
|
||||
#include "Subsystems/BinElevator.h"
|
||||
#include "OI.h"
|
||||
#include "WPILib.h"
|
||||
|
||||
@ -16,7 +17,8 @@ class CommandBase: public Command {
|
||||
static Drivetrain *drivetrain;
|
||||
static Collector *collector;
|
||||
static Elevator *elevator;
|
||||
static BinElevator *binElevator;
|
||||
static OI *oi;
|
||||
};
|
||||
#endif
|
||||
// vim: ts2:sw=2:et
|
||||
// vim: ts=2:sw=2:et
|
||||
|
@ -1,16 +1,15 @@
|
||||
#include "AutoDrive.h"
|
||||
#include <cmath>
|
||||
#include "../../DentRobot.h"
|
||||
// Drive for a short while then stop. Just for testing
|
||||
AutoDrive::AutoDrive() : Command("AutoDrive"){
|
||||
Requires(DentRobot::drivetrain);
|
||||
SetTimeout(1.0);
|
||||
SetTimeout(0.5);
|
||||
}
|
||||
void AutoDrive::Initialize(){
|
||||
}
|
||||
void AutoDrive::Execute(){
|
||||
//X axis, Y axis, Z axis, sensitivity, speed threshold (usually throttle), gyro
|
||||
DentRobot::drivetrain->DriveMecanum(0.5,0,0,0.9,0);
|
||||
DentRobot::drivetrain->DriveMecanum(0.0,-.75,0.0,0.9,0.0);
|
||||
}
|
||||
bool AutoDrive::IsFinished(){
|
||||
return IsTimedOut();
|
||||
@ -20,4 +19,4 @@ void AutoDrive::End(){
|
||||
void AutoDrive::Interrupted(){
|
||||
End();
|
||||
}
|
||||
// vim: ts2:sw=2:et
|
||||
// vim: ts=2:sw=2:et
|
||||
|
@ -16,4 +16,4 @@ class AutoDrive: public Command{
|
||||
void Interrupted();
|
||||
};
|
||||
#endif
|
||||
// vim: ts2:sw=2:et
|
||||
// vim: ts=2:sw=2:et
|
||||
|
@ -1,11 +1,22 @@
|
||||
#include "Autonomous.h"
|
||||
#include "Commands/CommandGroup.h"
|
||||
#include "../../DentRobot.h"
|
||||
#include "AutoDrive.h"
|
||||
#include "../../DentRobot.h"
|
||||
#include "../Elevator/Raise.h"
|
||||
#include "../Elevator/Lower.h"
|
||||
#include "AutoDrive.h"
|
||||
#include "Turn.h"
|
||||
#include "../Collector/CloseCollector.h"
|
||||
#include "../Collector/OpenCollector.h"
|
||||
#include "../Collector/CollectTote.h"
|
||||
Autonomous::Autonomous(){
|
||||
AddSequential(new AutoDrive());
|
||||
AddSequential(new Raise());
|
||||
AddSequential(new Lower());
|
||||
AddParallel(new OpenCollector());
|
||||
AddParallel(new CloseCollector());
|
||||
AddSequential(new Turn());
|
||||
AddParallel(new AutoDrive());
|
||||
AddParallel(new CloseCollector());
|
||||
AddParallel(new CollectTote());
|
||||
AddSequential(new Turn());
|
||||
}
|
||||
// vim: ts2:sw=2:et
|
||||
// vim: ts=2:sw=2:et
|
||||
|
@ -11,4 +11,4 @@ class Autonomous: public CommandGroup{
|
||||
Autonomous();
|
||||
};
|
||||
#endif
|
||||
// vim: ts2:sw=2:et
|
||||
// vim: ts=2:sw=2:et
|
||||
|
22
Commands/Autonomous/Turn.cpp
Normal file
22
Commands/Autonomous/Turn.cpp
Normal file
@ -0,0 +1,22 @@
|
||||
#include "Turn.h"
|
||||
#include "../../DentRobot.h"
|
||||
// Drive for a short while then stop. Just for testing
|
||||
Turn::Turn() : Command("Turn"){
|
||||
Requires(DentRobot::drivetrain);
|
||||
SetTimeout(0.25);
|
||||
}
|
||||
void Turn::Initialize(){
|
||||
}
|
||||
void Turn::Execute(){
|
||||
//X axis, Y axis, Z axis, sensitivity, speed threshold (usually throttle), gyro
|
||||
DentRobot::drivetrain->DriveMecanum(0.0,0.0,0.5,0.9,0.0);
|
||||
}
|
||||
bool Turn::IsFinished(){
|
||||
return IsTimedOut();
|
||||
}
|
||||
void Turn::End(){
|
||||
}
|
||||
void Turn::Interrupted(){
|
||||
End();
|
||||
}
|
||||
// vim: ts=2:sw=2:et
|
19
Commands/Autonomous/Turn.h
Normal file
19
Commands/Autonomous/Turn.h
Normal file
@ -0,0 +1,19 @@
|
||||
#ifndef TURN_H
|
||||
#define TURN_H
|
||||
|
||||
#include "Commands/Command.h"
|
||||
#include "../../CommandBase.h"
|
||||
#include "../../DentRobot.h"
|
||||
#include "WPILib.h"
|
||||
|
||||
class Turn: public Command{
|
||||
public:
|
||||
Turn();
|
||||
void Initialize();
|
||||
void Execute();
|
||||
bool IsFinished();
|
||||
void End();
|
||||
void Interrupted();
|
||||
};
|
||||
#endif
|
||||
// vim: ts=2:sw=2:et
|
26
Commands/BinElevator/BinLower.cpp
Normal file
26
Commands/BinElevator/BinLower.cpp
Normal file
@ -0,0 +1,26 @@
|
||||
#include "BinLower.h"
|
||||
#include "../../DentRobot.h"
|
||||
#include "../../OI.h"
|
||||
BinLower::BinLower() : Command("BinLower"){
|
||||
}
|
||||
void BinLower::Initialize(){
|
||||
SetTimeout(2.5);
|
||||
}
|
||||
void BinLower::Execute(){
|
||||
DentRobot::binElevator->Run(-1.0);
|
||||
}
|
||||
bool BinLower::IsFinished(){
|
||||
if (!DentRobot::binElevator->GetElevatorBottom()||IsTimedOut()){
|
||||
printf("Robot stoped BinLowering. Sensor based? %d\n", !DentRobot::binElevator->GetElevatorBottom());
|
||||
return true;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
void BinLower::End(){
|
||||
DentRobot::binElevator->Run(0.0f);
|
||||
}
|
||||
void BinLower::Interrupted(){
|
||||
End();
|
||||
}
|
||||
// vim: ts=2:sw=2:et
|
@ -1,12 +1,12 @@
|
||||
#ifndef CALIBRATE_H
|
||||
#define CALIBRATE_H
|
||||
#ifndef BINLOWER_H
|
||||
#define BINLOWER_H
|
||||
|
||||
#include "Commands/Command.h"
|
||||
#include "WPILib.h"
|
||||
|
||||
class Calibrate: public Command{
|
||||
class BinLower: public Command{
|
||||
public:
|
||||
Calibrate();
|
||||
BinLower();
|
||||
void Initialize();
|
||||
void Execute();
|
||||
bool IsFinished();
|
||||
@ -14,4 +14,4 @@ class Calibrate: public Command{
|
||||
void Interrupted();
|
||||
};
|
||||
#endif
|
||||
// vim: ts2:sw=2:et
|
||||
// vim: ts=2:sw=2:et
|
26
Commands/BinElevator/BinRaise.cpp
Normal file
26
Commands/BinElevator/BinRaise.cpp
Normal file
@ -0,0 +1,26 @@
|
||||
#include "BinRaise.h"
|
||||
#include "../../DentRobot.h"
|
||||
#include "../../OI.h"
|
||||
BinRaise::BinRaise() : Command("BinRaise"){
|
||||
}
|
||||
void BinRaise::Initialize(){
|
||||
SetTimeout(3.0);
|
||||
}
|
||||
void BinRaise::Execute(){
|
||||
DentRobot::binElevator->Run(1.0);
|
||||
}
|
||||
bool BinRaise::IsFinished(){
|
||||
if (!DentRobot::binElevator->GetElevatorTop()||IsTimedOut()){
|
||||
printf("Robot stoped raising. Sensor based? %d\n", !DentRobot::binElevator->GetElevatorTop());
|
||||
return true;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
void BinRaise::End(){
|
||||
DentRobot::binElevator->Run(0.0f);
|
||||
}
|
||||
void BinRaise::Interrupted(){
|
||||
End();
|
||||
}
|
||||
// vim: ts=2:sw=2:et
|
18
Commands/BinElevator/BinRaise.h
Normal file
18
Commands/BinElevator/BinRaise.h
Normal file
@ -0,0 +1,18 @@
|
||||
#ifndef BINRAISE_H
|
||||
#define BINRAISE_H
|
||||
|
||||
#include "Commands/Command.h"
|
||||
#include "WPILib.h"
|
||||
|
||||
class BinRaise: public Command{
|
||||
public:
|
||||
BinRaise();
|
||||
void Initialize();
|
||||
void Execute();
|
||||
bool IsFinished();
|
||||
void End();
|
||||
void Interrupted();
|
||||
};
|
||||
|
||||
#endif
|
||||
// vim: ts=2:sw=2:et
|
@ -3,13 +3,21 @@ CloseCollector::CloseCollector() : Command("CloseCollector"){
|
||||
Requires(DentRobot::collector);
|
||||
}
|
||||
void CloseCollector::Initialize(){
|
||||
SetTimeout(0.5);
|
||||
printf("Initialized collector: 0.5\n");
|
||||
SetTimeout(2.5);
|
||||
}
|
||||
void CloseCollector::Execute(){
|
||||
DentRobot::collector->MoveArms(0.2f);
|
||||
//printf("Closing collector: -0.5f\n");
|
||||
DentRobot::collector->MoveArms(-0.5);
|
||||
//DentRobot::collector->MoveArms(-(-DentRobot::oi->GetRightStick()->GetRawAxis(3)+1)/2*.3/.5);
|
||||
}
|
||||
bool CloseCollector::IsFinished(){
|
||||
return DentRobot::collector->ArmSensor();
|
||||
if(DentRobot::collector->ArmSensor()||IsTimedOut()){
|
||||
printf("Stopped Closing: %d, %d\n",DentRobot::collector->ArmSensor(), IsTimedOut());
|
||||
return true;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
void CloseCollector::End(){
|
||||
DentRobot::collector->MoveArms(0.0f);
|
||||
@ -17,4 +25,4 @@ void CloseCollector::End(){
|
||||
void CloseCollector::Interrupted(){
|
||||
End();
|
||||
}
|
||||
// vim: ts2:sw=2:et
|
||||
// vim: ts=2:sw=2:et
|
||||
|
@ -17,4 +17,4 @@ class CloseCollector: public Command{
|
||||
};
|
||||
|
||||
#endif
|
||||
// vim: ts2:sw=2:et
|
||||
// vim: ts=2:sw=2:et
|
||||
|
@ -3,6 +3,7 @@ CollectTote::CollectTote() : Command("CollectTote"){
|
||||
Requires(DentRobot::collector);
|
||||
}
|
||||
void CollectTote::Initialize(){
|
||||
printf("Initialized CollectTote\n");
|
||||
SetTimeout(2.0);
|
||||
}
|
||||
void CollectTote::Execute(){
|
||||
@ -10,7 +11,7 @@ void CollectTote::Execute(){
|
||||
DentRobot::collector->MoveRollers(-(-DentRobot::oi->GetLeftStick()->GetRawAxis(3)+1.0)/2);
|
||||
}
|
||||
bool CollectTote::IsFinished(){
|
||||
return DentRobot::collector->BoxCollected();
|
||||
return DentRobot::collector->BoxCollected()||IsTimedOut();
|
||||
}
|
||||
void CollectTote::End(){
|
||||
DentRobot::collector->MoveRollers(0.0);
|
||||
@ -18,4 +19,4 @@ void CollectTote::End(){
|
||||
void CollectTote::Interrupted(){
|
||||
End();
|
||||
}
|
||||
// vim: ts2:sw=2:et
|
||||
// vim: ts=2:sw=2:et
|
||||
|
@ -17,4 +17,4 @@ class CollectTote: public Command{
|
||||
};
|
||||
|
||||
#endif
|
||||
// vim: ts2:sw=2:et
|
||||
// vim: ts=2:sw=2:et
|
||||
|
@ -6,11 +6,12 @@ void OpenCollector::Initialize(){
|
||||
SetTimeout(0.5);
|
||||
}
|
||||
void OpenCollector::Execute(){
|
||||
//TODO check this value to move the motors in the right direction
|
||||
DentRobot::collector->MoveArms(-0.2f);
|
||||
DentRobot::collector->MoveArms(0.35);
|
||||
//DentRobot::collector->MoveArms((-DentRobot::oi->GetRightStick()->GetRawAxis(3)+1)/2*.3/.5);
|
||||
}
|
||||
bool OpenCollector::IsFinished(){
|
||||
return DentRobot::collector->ArmSensor();
|
||||
//return DentRobot::collector->ArmSensor();
|
||||
return IsTimedOut();
|
||||
}
|
||||
void OpenCollector::End(){
|
||||
DentRobot::collector->MoveArms(0.0f);
|
||||
@ -18,4 +19,4 @@ void OpenCollector::End(){
|
||||
void OpenCollector::Interrupted(){
|
||||
End();
|
||||
}
|
||||
// vim: ts2:sw=2:et
|
||||
// vim: ts=2:sw=2:et
|
||||
|
@ -17,4 +17,4 @@ class OpenCollector: public Command{
|
||||
};
|
||||
|
||||
#endif
|
||||
// vim: ts2:sw=2:et
|
||||
// vim: ts=2:sw=2:et
|
||||
|
@ -19,4 +19,4 @@ void ReleaseTote::End(){
|
||||
void ReleaseTote::Interrupted(){
|
||||
End();
|
||||
}
|
||||
// vim: ts2:sw=2:et
|
||||
// vim: ts=2:sw=2:et
|
||||
|
@ -17,4 +17,4 @@ class ReleaseTote: public Command{
|
||||
};
|
||||
|
||||
#endif
|
||||
// vim: ts2:sw=2:et
|
||||
// vim: ts=2:sw=2:et
|
||||
|
@ -1,5 +1,4 @@
|
||||
#include "Drive.h"
|
||||
#include <cmath>
|
||||
#include "../../DentRobot.h"
|
||||
Drive::Drive() : Command("Drive"){
|
||||
Requires(DentRobot::drivetrain);
|
||||
@ -12,12 +11,12 @@ void Drive::Execute(){
|
||||
x = DentRobot::oi->GetLeftStick()->GetRawAxis(0);
|
||||
z = DentRobot::oi->GetLeftStick()->GetRawAxis(2);
|
||||
y = DentRobot::oi->GetLeftStick()->GetRawAxis(1);
|
||||
if (DentRobot::oi->GetLeftStick()->GetRawButton(1)){
|
||||
x=0;
|
||||
}
|
||||
if (DentRobot::oi->GetLeftStick()->GetRawButton(2)){
|
||||
y=0;
|
||||
}
|
||||
//if (DentRobot::oi->GetLeftStick()->GetRawButton(1)){
|
||||
// x=0;
|
||||
//}
|
||||
//if (DentRobot::oi->GetLeftStick()->GetRawButton(2)){
|
||||
// y=0;
|
||||
//}
|
||||
//X axis, Y axis, Z axis, sensitivity, speed threshold (usually throttle), gyro
|
||||
DentRobot::drivetrain->DriveMecanum(x,y,z,0.9,0);
|
||||
}
|
||||
@ -29,4 +28,4 @@ void Drive::End(){
|
||||
void Drive::Interrupted(){
|
||||
End();
|
||||
}
|
||||
// vim: ts2:sw=2:et
|
||||
// vim: ts=2:sw=2:et
|
||||
|
@ -16,4 +16,4 @@ class Drive: public Command{
|
||||
void Interrupted();
|
||||
};
|
||||
#endif
|
||||
// vim: ts2:sw=2:et
|
||||
// vim: ts=2:sw=2:et
|
||||
|
@ -1,26 +0,0 @@
|
||||
#include "Calibrate.h"
|
||||
#include "../../DentRobot.h"
|
||||
// Lowers elevator until it hits the limit switch then sets the height of the elevator to the height of the limit switches
|
||||
Calibrate::Calibrate() : Command("Calibrate"){
|
||||
}
|
||||
void Calibrate::Initialize(){
|
||||
}
|
||||
void Calibrate::Execute(){
|
||||
// Lower collector until End()
|
||||
DentRobot::elevator->Run(-0.4f);
|
||||
}
|
||||
bool Calibrate::IsFinished(){
|
||||
if(DentRobot::elevator->GetElevatorBottom()){
|
||||
DentRobot::elevator->ResetEncoder();
|
||||
DentRobot::elevator->SetOffset(0.99);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
void Calibrate::End(){
|
||||
DentRobot::elevator->Run(0.0f);
|
||||
}
|
||||
void Calibrate::Interrupted(){
|
||||
End();
|
||||
}
|
||||
// vim: ts2:sw=2:et
|
@ -4,7 +4,7 @@
|
||||
Lower::Lower() : Command("Lower"){
|
||||
}
|
||||
void Lower::Initialize(){
|
||||
SetTimeout(1.0);
|
||||
SetTimeout(2.5);
|
||||
}
|
||||
void Lower::Execute(){
|
||||
DentRobot::elevator->Run(-1.0);
|
||||
@ -23,4 +23,4 @@ void Lower::End(){
|
||||
void Lower::Interrupted(){
|
||||
End();
|
||||
}
|
||||
// vim: ts2:sw=2:et
|
||||
// vim: ts=2:sw=2:et
|
||||
|
@ -14,4 +14,4 @@ class Lower: public Command{
|
||||
void Interrupted();
|
||||
};
|
||||
#endif
|
||||
// vim: ts2:sw=2:et
|
||||
// vim: ts=2:sw=2:et
|
||||
|
@ -4,7 +4,7 @@
|
||||
Raise::Raise() : Command("Raise"){
|
||||
}
|
||||
void Raise::Initialize(){
|
||||
SetTimeout(2.5);
|
||||
SetTimeout(3.0);
|
||||
}
|
||||
void Raise::Execute(){
|
||||
DentRobot::elevator->Run(1.0);
|
||||
@ -18,9 +18,13 @@ bool Raise::IsFinished(){
|
||||
}
|
||||
}
|
||||
void Raise::End(){
|
||||
// If the elevator is at the top
|
||||
if(DentRobot::elevator->GetElevatorTop()){
|
||||
DentRobot::elevator->SetUseEncoder(true);
|
||||
}
|
||||
DentRobot::elevator->Run(0.0f);
|
||||
}
|
||||
void Raise::Interrupted(){
|
||||
End();
|
||||
}
|
||||
// vim: ts2:sw=2:et
|
||||
// vim: ts=2:sw=2:et
|
||||
|
@ -15,4 +15,4 @@ class Raise: public Command{
|
||||
};
|
||||
|
||||
#endif
|
||||
// vim: ts2:sw=2:et
|
||||
// vim: ts=2:sw=2:et
|
||||
|
@ -1,16 +1,21 @@
|
||||
#include "DentRobot.h"
|
||||
#include "OI.h"
|
||||
#include "Commands/Autonomous/Autonomous.h"
|
||||
OI* DentRobot::oi=NULL;
|
||||
Collector* DentRobot::collector=NULL;
|
||||
Drivetrain* DentRobot::drivetrain=NULL;
|
||||
Elevator* DentRobot::elevator=NULL;
|
||||
BinElevator* DentRobot::binElevator=NULL;
|
||||
CommandGroup* DentRobot::aut=NULL;
|
||||
DentRobot::DentRobot(){
|
||||
oi=new OI();
|
||||
collector=new Collector();
|
||||
drivetrain=new Drivetrain();
|
||||
elevator=new Elevator();
|
||||
binElevator=new BinElevator();
|
||||
aut=new Autonomous();
|
||||
CameraServer::GetInstance()->SetQuality(25);
|
||||
CameraServer::GetInstance()->StartAutomaticCapture("cam0");
|
||||
printf("Initialized");
|
||||
}
|
||||
void DentRobot::RobotInit(){
|
||||
@ -28,14 +33,19 @@ void DentRobot::AutonomousPeriodic(){
|
||||
Scheduler::GetInstance()->Run();
|
||||
}
|
||||
void DentRobot::TeleopInit(){
|
||||
//if (aut != NULL){
|
||||
// aut->Cancel();
|
||||
//}
|
||||
if (aut != NULL){
|
||||
aut->Cancel();
|
||||
}
|
||||
}
|
||||
void DentRobot::TeleopPeriodic(){
|
||||
Scheduler::GetInstance()->Run();
|
||||
// TODO: Calibrate 1.0 to the height we want the elevator to automatically raise
|
||||
if(elevator->GetUseEncoder()&&elevator->GetHeight()<=-1.0){
|
||||
// Raise the elevator if it dips below elevatorTop
|
||||
oi->raise->Start();
|
||||
}
|
||||
}
|
||||
void DentRobot::TestPeriodic(){
|
||||
}
|
||||
START_ROBOT_CLASS(DentRobot);
|
||||
// vim: ts2:sw=2:et
|
||||
// vim: ts=2:sw=2:et
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include "WPILib.h"
|
||||
#include "OI.h"
|
||||
#include "Subsystems/Elevator.h"
|
||||
#include "Subsystems/BinElevator.h"
|
||||
#include "Subsystems/Drivetrain.h"
|
||||
#include "Subsystems/Collector.h"
|
||||
#include "Commands/Autonomous/Autonomous.h"
|
||||
@ -15,6 +16,7 @@ class DentRobot: public IterativeRobot {
|
||||
static Collector* collector;
|
||||
static Drivetrain* drivetrain;
|
||||
static Elevator* elevator;
|
||||
static BinElevator* binElevator;
|
||||
static CommandGroup* aut;
|
||||
void RobotInit();
|
||||
void DisabledPeriodic();
|
||||
|
5
Makefile
5
Makefile
@ -9,6 +9,7 @@ EXEC=bin/FRCUserProgram
|
||||
CLEANSER=rm -r
|
||||
|
||||
all : $(OBJECTS)
|
||||
if [ ! -d bin ];then mkdir bin; fi
|
||||
$(CC) -L$(WPILIB)/lib $(LDFLAGS) -o $(EXEC) $(OBJECTS) -lwpi
|
||||
|
||||
%.o : %.cpp
|
||||
@ -17,10 +18,10 @@ all : $(OBJECTS)
|
||||
clean:
|
||||
$(CLEANSER) $(OBJECTS) bin/FRCUserProgram
|
||||
|
||||
deploy:
|
||||
deploy: all
|
||||
@cat bin/FRCUserProgram | ssh admin@$(REMOTEIP) 'cat > /home/lvuser/FRCUserProgram2&&rm /home/lvuser/FRCUserProgram;mv /home/lvuser/FRCUserProgram2 /home/lvuser/FRCUserProgram&&. /etc/profile.d/natinst-path.sh;chmod a+x /home/lvuser/FRCUserProgram'
|
||||
|
||||
debug:
|
||||
debug: all
|
||||
@cat bin/FRCUserProgram | ssh admin@$(REMOTEIP) 'cat > /home/lvuser/FRCUserProgram2&&rm /home/lvuser/FRCUserProgram;mv /home/lvuser/FRCUserProgram2 /home/lvuser/FRCUserProgram&&. /etc/profile.d/natinst-path.sh;chmod a+x /home/lvuser/FRCUserProgram;/home/lvuser/run.sh'
|
||||
|
||||
putkey:
|
||||
|
18
OI.cpp
18
OI.cpp
@ -14,15 +14,15 @@ OI::OI() {
|
||||
// Collector
|
||||
JoystickButton *right1=new JoystickButton(rightStick, 1);
|
||||
JoystickButton *right2=new JoystickButton(rightStick, 2);
|
||||
JoystickButton *left3=new JoystickButton(leftStick, 3);
|
||||
JoystickButton *left4=new JoystickButton(leftStick, 4);
|
||||
right1->WhileHeld(new OpenCollector());
|
||||
right2->WhileHeld(new CloseCollector());
|
||||
left3->WhileHeld(new CollectTote());
|
||||
left4->WhileHeld(new ReleaseTote());
|
||||
JoystickButton *left1=new JoystickButton(leftStick, 1);
|
||||
JoystickButton *left2=new JoystickButton(leftStick, 2);
|
||||
right1->WhileHeld(new CloseCollector());
|
||||
right2->WhileHeld(new OpenCollector());
|
||||
left1->WhileHeld(new CollectTote());
|
||||
left2->WhileHeld(new ReleaseTote());
|
||||
// Elevator
|
||||
Raise* raise=new Raise();
|
||||
Lower* lower=new Lower();
|
||||
raise=new Raise();
|
||||
lower=new Lower();
|
||||
JoystickButton *right3=new JoystickButton(rightStick, 3);
|
||||
JoystickButton *right4=new JoystickButton(rightStick, 4);
|
||||
JoystickButton *right5=new JoystickButton(rightStick, 5);
|
||||
@ -50,4 +50,4 @@ Joystick* OI::GetRightStick(){
|
||||
Joystick* OI::GetLeftStick(){
|
||||
return leftStick;
|
||||
}
|
||||
// vim: ts2:sw=2:et
|
||||
// vim: ts=2:sw=2:et
|
||||
|
4
OI.h
4
OI.h
@ -2,6 +2,7 @@
|
||||
#define OI_H
|
||||
|
||||
#include "WPILib.h"
|
||||
#include "Commands/Command.h"
|
||||
|
||||
class OI
|
||||
{
|
||||
@ -11,6 +12,7 @@ class OI
|
||||
OI();
|
||||
Joystick* GetRightStick();
|
||||
Joystick* GetLeftStick();
|
||||
Command *raise, *lower;
|
||||
};
|
||||
#endif
|
||||
// vim: ts2:sw=2:et
|
||||
// vim: ts=2:sw=2:et
|
||||
|
15
RobotMap.h
15
RobotMap.h
@ -8,9 +8,17 @@
|
||||
#define ELEVATOR_BOTTOM_DIO 0
|
||||
#define ELEVATOR_COLELCT_TOTE_DIO 1
|
||||
#define ELEVATOR_READY_TOTE_DIO 2
|
||||
#define ELEVATOR_COLELCT_CAN_DIO 3
|
||||
#define ELEVATOR_READY_CAN_DIO 4
|
||||
#define ELEVATOR_TOP_DIO 5
|
||||
#define ELEVATOR_ENCODERA 0
|
||||
#define ELEVATOR_ENCODERB 1
|
||||
|
||||
// BinElevator
|
||||
#define BINELEVATOR_CAN 11
|
||||
#define BINELEVATOR_BOTTOM_DIO 6
|
||||
#define BINELEVATOR_COLELCT_BIN_DIO 7
|
||||
#define BINELEVATOR_TOP_DIO 8
|
||||
#define BINELEVATOR_ENCODERA 2
|
||||
#define BINELEVATOR_ENCODERB 3
|
||||
|
||||
// Drivetrain
|
||||
#define DRIVE_FRONT_LEFT_CAN 2
|
||||
@ -22,7 +30,8 @@
|
||||
#define COLLECTOR_WINDOW_LEFT_CAN 6
|
||||
#define COLLECTOR_WINDOW_RIGHT_CAN 7
|
||||
#define COLLECTOR_LEFT_CAN 8
|
||||
#define COLLECTOR_BOTTOM_CAN 10
|
||||
#define COLLECTOR_RIGHT_CAN 9
|
||||
|
||||
#endif
|
||||
// vim: ts2:sw=2:et
|
||||
// vim: ts=2:sw=2:et
|
||||
|
26
Subsystems/BinElevator.cpp
Normal file
26
Subsystems/BinElevator.cpp
Normal file
@ -0,0 +1,26 @@
|
||||
#include "BinElevator.h"
|
||||
#include "../RobotMap.h"
|
||||
BinElevator::BinElevator(){
|
||||
motor=new CANTalon(BINELEVATOR_CAN);
|
||||
elevatorEncoder=new Encoder(BINELEVATOR_ENCODERA,BINELEVATOR_ENCODERB,false);
|
||||
elevatorBottom=new DigitalInput(BINELEVATOR_BOTTOM_DIO);
|
||||
elevatorTop=new DigitalInput(BINELEVATOR_TOP_DIO);
|
||||
}
|
||||
void BinElevator::InitDefaultCommand(){
|
||||
}
|
||||
void BinElevator::Run(double power){
|
||||
motor->Set(power);
|
||||
}
|
||||
void BinElevator::ResetEncoder(){
|
||||
elevatorEncoder->Reset();
|
||||
}
|
||||
double BinElevator::GetHeight(){
|
||||
return elevatorEncoder->Get();
|
||||
}
|
||||
bool BinElevator::GetElevatorBottom(){
|
||||
return elevatorBottom->Get();
|
||||
}
|
||||
bool BinElevator::GetElevatorTop(){
|
||||
return elevatorTop->Get();
|
||||
}
|
||||
// vim: ts=2:sw=2:et
|
22
Subsystems/BinElevator.h
Normal file
22
Subsystems/BinElevator.h
Normal file
@ -0,0 +1,22 @@
|
||||
#ifndef BINELEVATOR_H
|
||||
#define BINELEVATOR_H
|
||||
|
||||
#include "WPILib.h"
|
||||
#include "Commands/PIDSubsystem.h"
|
||||
class BinElevator{
|
||||
private:
|
||||
CANTalon *motor;
|
||||
Encoder *elevatorEncoder;
|
||||
static constexpr double kP_real=4, kI_real=.0f, kP_simulation=18, kI_simulation=.2;
|
||||
DigitalInput *elevatorBottom, *elevatorTop;
|
||||
public:
|
||||
BinElevator();
|
||||
void InitDefaultCommand();
|
||||
void Run(double);
|
||||
void ResetEncoder();
|
||||
double GetHeight();
|
||||
bool GetElevatorTop();
|
||||
bool GetElevatorBottom();
|
||||
};
|
||||
#endif
|
||||
// vim: ts=2:sw=2:et
|
@ -5,6 +5,7 @@ Collector::Collector() : Subsystem("Collector") {
|
||||
windowMotorLeft=new CANTalon(COLLECTOR_WINDOW_LEFT_CAN);
|
||||
windowMotorRight=new CANTalon(COLLECTOR_WINDOW_RIGHT_CAN);
|
||||
collectorMotorLeft=new CANTalon(COLLECTOR_LEFT_CAN);
|
||||
collectorMotorBottom=new CANTalon(COLLECTOR_BOTTOM_CAN);
|
||||
collectorMotorRight=new CANTalon(COLLECTOR_RIGHT_CAN);
|
||||
}
|
||||
void Collector::InitDefaultCommand() {
|
||||
@ -15,6 +16,7 @@ void Collector::MoveArms(double a){
|
||||
}
|
||||
void Collector::MoveRollers(double a){
|
||||
collectorMotorLeft->Set(a);
|
||||
collectorMotorBottom->Set(a);
|
||||
collectorMotorRight->Set(-a);
|
||||
}
|
||||
bool Collector::ArmSensor(){
|
||||
@ -25,4 +27,4 @@ bool Collector::BoxCollected(){
|
||||
return false;
|
||||
//return boxSwitch->Get();
|
||||
}
|
||||
// vim: ts2:sw=2:et
|
||||
// vim: ts=2:sw=2:et
|
||||
|
@ -5,7 +5,7 @@
|
||||
class Collector: public Subsystem
|
||||
{
|
||||
private:
|
||||
CANTalon *windowMotorLeft, *windowMotorRight, *collectorMotorLeft, *collectorMotorRight;
|
||||
CANTalon *windowMotorLeft, *windowMotorRight, *collectorMotorLeft, *collectorMotorBottom, *collectorMotorRight;
|
||||
public:
|
||||
Collector();
|
||||
void InitDefaultCommand();
|
||||
@ -15,4 +15,4 @@ class Collector: public Subsystem
|
||||
bool BoxCollected();
|
||||
};
|
||||
#endif
|
||||
// vim: ts2:sw=2:et
|
||||
// vim: ts=2:sw=2:et
|
||||
|
@ -40,4 +40,4 @@ void Drivetrain::TestMotor(e_motors motor, float power){
|
||||
break;
|
||||
}
|
||||
}
|
||||
// vim: ts2:sw=2:et
|
||||
// vim: ts=2:sw=2:et
|
||||
|
@ -20,4 +20,4 @@ class Drivetrain: public Subsystem{
|
||||
void TestMotor(e_motors,float);
|
||||
};
|
||||
#endif
|
||||
// vim: ts2:sw=2:et
|
||||
// vim: ts=2:sw=2:et
|
||||
|
@ -2,26 +2,26 @@
|
||||
#include "../RobotMap.h"
|
||||
Elevator::Elevator(){
|
||||
motor=new CANTalon(ELEVATOR_CAN);
|
||||
elevatorEncoder=new Encoder(0,1,false);
|
||||
offset=0;
|
||||
height=0;
|
||||
elevatorEncoder=new Encoder(ELEVATOR_ENCODERA,ELEVATOR_ENCODERB,false);
|
||||
elevatorBottom=new DigitalInput(ELEVATOR_BOTTOM_DIO);
|
||||
elevatorTop=new DigitalInput(ELEVATOR_TOP_DIO);
|
||||
//SetAbsoluteTolerance(0.004);
|
||||
// Checks if the elevator is drifting
|
||||
useEncoder=false;
|
||||
}
|
||||
void Elevator::InitDefaultCommand(){
|
||||
}
|
||||
void Elevator::Run(double power){
|
||||
motor->Set(power);
|
||||
// If we're not telling it to stop
|
||||
if(power != 0.0){
|
||||
SetUseEncoder(false);
|
||||
}
|
||||
void Elevator::SetOffset(double ht){
|
||||
offset=ht;
|
||||
motor->Set(power);
|
||||
}
|
||||
void Elevator::ResetEncoder(){
|
||||
elevatorEncoder->Reset();
|
||||
}
|
||||
double Elevator::GetHeight(){
|
||||
return elevatorEncoder->Get()+offset;
|
||||
return elevatorEncoder->Get();
|
||||
}
|
||||
bool Elevator::GetElevatorBottom(){
|
||||
return elevatorBottom->Get();
|
||||
@ -29,4 +29,10 @@ bool Elevator::GetElevatorBottom(){
|
||||
bool Elevator::GetElevatorTop(){
|
||||
return elevatorTop->Get();
|
||||
}
|
||||
// vim: ts2:sw=2:et
|
||||
void Elevator::SetUseEncoder(bool param){
|
||||
useEncoder=param;
|
||||
}
|
||||
bool Elevator::GetUseEncoder(){
|
||||
return useEncoder;
|
||||
}
|
||||
// vim: ts=2:sw=2:et
|
||||
|
@ -8,17 +8,18 @@ class Elevator{
|
||||
CANTalon *motor;
|
||||
Encoder *elevatorEncoder;
|
||||
static constexpr double kP_real=4, kI_real=.0f, kP_simulation=18, kI_simulation=.2;
|
||||
double offset, height;
|
||||
DigitalInput *elevatorBottom, *elevatorTop;
|
||||
bool useEncoder;
|
||||
public:
|
||||
Elevator();
|
||||
void InitDefaultCommand();
|
||||
void Run(double);
|
||||
void SetOffset(double);
|
||||
void ResetEncoder();
|
||||
double GetHeight();
|
||||
bool GetElevatorTop();
|
||||
bool GetElevatorBottom();
|
||||
void SetUseEncoder(bool);
|
||||
bool GetUseEncoder();
|
||||
};
|
||||
#endif
|
||||
// vim: ts2:sw=2:et
|
||||
// vim: ts=2:sw=2:et
|
||||
|
1
hhlib
1
hhlib
@ -1 +0,0 @@
|
||||
Subproject commit 787733b3d4204d061620c7906af0cf4777c47e34
|
Loading…
Reference in New Issue
Block a user