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/Drivetrain.h"
|
||||||
#include "Subsystems/Collector.h"
|
#include "Subsystems/Collector.h"
|
||||||
#include "Subsystems/Elevator.h"
|
#include "Subsystems/Elevator.h"
|
||||||
|
#include "Subsystems/BinElevator.h"
|
||||||
Drivetrain* CommandBase::drivetrain = NULL;
|
Drivetrain* CommandBase::drivetrain = NULL;
|
||||||
Collector* CommandBase::collector = NULL;
|
Collector* CommandBase::collector = NULL;
|
||||||
Elevator* CommandBase::elevator = NULL;
|
Elevator* CommandBase::elevator = NULL;
|
||||||
|
BinElevator* CommandBase::binElevator = NULL;
|
||||||
OI* CommandBase::oi = NULL;
|
OI* CommandBase::oi = NULL;
|
||||||
CommandBase::CommandBase(char const *name) : Command(name) {
|
CommandBase::CommandBase(char const *name) : Command(name) {
|
||||||
}
|
}
|
||||||
@ -14,6 +16,7 @@ void CommandBase::init(){
|
|||||||
drivetrain = new Drivetrain();
|
drivetrain = new Drivetrain();
|
||||||
collector = new Collector();
|
collector = new Collector();
|
||||||
elevator = new Elevator();
|
elevator = new Elevator();
|
||||||
|
binElevator = new BinElevator();
|
||||||
oi = new OI();
|
oi = new OI();
|
||||||
}
|
}
|
||||||
// vim: ts2:sw=2:et
|
// vim: ts=2:sw=2:et
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
#include "Subsystems/Drivetrain.h"
|
#include "Subsystems/Drivetrain.h"
|
||||||
#include "Subsystems/Collector.h"
|
#include "Subsystems/Collector.h"
|
||||||
#include "Subsystems/Elevator.h"
|
#include "Subsystems/Elevator.h"
|
||||||
|
#include "Subsystems/BinElevator.h"
|
||||||
#include "OI.h"
|
#include "OI.h"
|
||||||
#include "WPILib.h"
|
#include "WPILib.h"
|
||||||
|
|
||||||
@ -16,7 +17,8 @@ class CommandBase: public Command {
|
|||||||
static Drivetrain *drivetrain;
|
static Drivetrain *drivetrain;
|
||||||
static Collector *collector;
|
static Collector *collector;
|
||||||
static Elevator *elevator;
|
static Elevator *elevator;
|
||||||
|
static BinElevator *binElevator;
|
||||||
static OI *oi;
|
static OI *oi;
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
// vim: ts2:sw=2:et
|
// vim: ts=2:sw=2:et
|
||||||
|
@ -1,16 +1,15 @@
|
|||||||
#include "AutoDrive.h"
|
#include "AutoDrive.h"
|
||||||
#include <cmath>
|
|
||||||
#include "../../DentRobot.h"
|
#include "../../DentRobot.h"
|
||||||
// Drive for a short while then stop. Just for testing
|
// Drive for a short while then stop. Just for testing
|
||||||
AutoDrive::AutoDrive() : Command("AutoDrive"){
|
AutoDrive::AutoDrive() : Command("AutoDrive"){
|
||||||
Requires(DentRobot::drivetrain);
|
Requires(DentRobot::drivetrain);
|
||||||
SetTimeout(1.0);
|
SetTimeout(0.5);
|
||||||
}
|
}
|
||||||
void AutoDrive::Initialize(){
|
void AutoDrive::Initialize(){
|
||||||
}
|
}
|
||||||
void AutoDrive::Execute(){
|
void AutoDrive::Execute(){
|
||||||
//X axis, Y axis, Z axis, sensitivity, speed threshold (usually throttle), gyro
|
//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(){
|
bool AutoDrive::IsFinished(){
|
||||||
return IsTimedOut();
|
return IsTimedOut();
|
||||||
@ -20,4 +19,4 @@ void AutoDrive::End(){
|
|||||||
void AutoDrive::Interrupted(){
|
void AutoDrive::Interrupted(){
|
||||||
End();
|
End();
|
||||||
}
|
}
|
||||||
// vim: ts2:sw=2:et
|
// vim: ts=2:sw=2:et
|
||||||
|
@ -16,4 +16,4 @@ class AutoDrive: public Command{
|
|||||||
void Interrupted();
|
void Interrupted();
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
// vim: ts2:sw=2:et
|
// vim: ts=2:sw=2:et
|
||||||
|
@ -1,11 +1,22 @@
|
|||||||
#include "Autonomous.h"
|
#include "Autonomous.h"
|
||||||
#include "Commands/CommandGroup.h"
|
#include "Commands/CommandGroup.h"
|
||||||
#include "../../DentRobot.h"
|
#include "../../DentRobot.h"
|
||||||
#include "AutoDrive.h"
|
|
||||||
#include "../../DentRobot.h"
|
|
||||||
#include "../Elevator/Raise.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(){
|
Autonomous::Autonomous(){
|
||||||
AddSequential(new AutoDrive());
|
|
||||||
AddSequential(new Raise());
|
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();
|
Autonomous();
|
||||||
};
|
};
|
||||||
#endif
|
#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
|
#ifndef BINLOWER_H
|
||||||
#define CALIBRATE_H
|
#define BINLOWER_H
|
||||||
|
|
||||||
#include "Commands/Command.h"
|
#include "Commands/Command.h"
|
||||||
#include "WPILib.h"
|
#include "WPILib.h"
|
||||||
|
|
||||||
class Calibrate: public Command{
|
class BinLower: public Command{
|
||||||
public:
|
public:
|
||||||
Calibrate();
|
BinLower();
|
||||||
void Initialize();
|
void Initialize();
|
||||||
void Execute();
|
void Execute();
|
||||||
bool IsFinished();
|
bool IsFinished();
|
||||||
@ -14,4 +14,4 @@ class Calibrate: public Command{
|
|||||||
void Interrupted();
|
void Interrupted();
|
||||||
};
|
};
|
||||||
#endif
|
#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);
|
Requires(DentRobot::collector);
|
||||||
}
|
}
|
||||||
void CloseCollector::Initialize(){
|
void CloseCollector::Initialize(){
|
||||||
SetTimeout(0.5);
|
printf("Initialized collector: 0.5\n");
|
||||||
|
SetTimeout(2.5);
|
||||||
}
|
}
|
||||||
void CloseCollector::Execute(){
|
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(){
|
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(){
|
void CloseCollector::End(){
|
||||||
DentRobot::collector->MoveArms(0.0f);
|
DentRobot::collector->MoveArms(0.0f);
|
||||||
@ -17,4 +25,4 @@ void CloseCollector::End(){
|
|||||||
void CloseCollector::Interrupted(){
|
void CloseCollector::Interrupted(){
|
||||||
End();
|
End();
|
||||||
}
|
}
|
||||||
// vim: ts2:sw=2:et
|
// vim: ts=2:sw=2:et
|
||||||
|
@ -17,4 +17,4 @@ class CloseCollector: public Command{
|
|||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
// vim: ts2:sw=2:et
|
// vim: ts=2:sw=2:et
|
||||||
|
@ -3,6 +3,7 @@ CollectTote::CollectTote() : Command("CollectTote"){
|
|||||||
Requires(DentRobot::collector);
|
Requires(DentRobot::collector);
|
||||||
}
|
}
|
||||||
void CollectTote::Initialize(){
|
void CollectTote::Initialize(){
|
||||||
|
printf("Initialized CollectTote\n");
|
||||||
SetTimeout(2.0);
|
SetTimeout(2.0);
|
||||||
}
|
}
|
||||||
void CollectTote::Execute(){
|
void CollectTote::Execute(){
|
||||||
@ -10,7 +11,7 @@ void CollectTote::Execute(){
|
|||||||
DentRobot::collector->MoveRollers(-(-DentRobot::oi->GetLeftStick()->GetRawAxis(3)+1.0)/2);
|
DentRobot::collector->MoveRollers(-(-DentRobot::oi->GetLeftStick()->GetRawAxis(3)+1.0)/2);
|
||||||
}
|
}
|
||||||
bool CollectTote::IsFinished(){
|
bool CollectTote::IsFinished(){
|
||||||
return DentRobot::collector->BoxCollected();
|
return DentRobot::collector->BoxCollected()||IsTimedOut();
|
||||||
}
|
}
|
||||||
void CollectTote::End(){
|
void CollectTote::End(){
|
||||||
DentRobot::collector->MoveRollers(0.0);
|
DentRobot::collector->MoveRollers(0.0);
|
||||||
@ -18,4 +19,4 @@ void CollectTote::End(){
|
|||||||
void CollectTote::Interrupted(){
|
void CollectTote::Interrupted(){
|
||||||
End();
|
End();
|
||||||
}
|
}
|
||||||
// vim: ts2:sw=2:et
|
// vim: ts=2:sw=2:et
|
||||||
|
@ -17,4 +17,4 @@ class CollectTote: public Command{
|
|||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
// vim: ts2:sw=2:et
|
// vim: ts=2:sw=2:et
|
||||||
|
@ -6,11 +6,12 @@ void OpenCollector::Initialize(){
|
|||||||
SetTimeout(0.5);
|
SetTimeout(0.5);
|
||||||
}
|
}
|
||||||
void OpenCollector::Execute(){
|
void OpenCollector::Execute(){
|
||||||
//TODO check this value to move the motors in the right direction
|
DentRobot::collector->MoveArms(0.35);
|
||||||
DentRobot::collector->MoveArms(-0.2f);
|
//DentRobot::collector->MoveArms((-DentRobot::oi->GetRightStick()->GetRawAxis(3)+1)/2*.3/.5);
|
||||||
}
|
}
|
||||||
bool OpenCollector::IsFinished(){
|
bool OpenCollector::IsFinished(){
|
||||||
return DentRobot::collector->ArmSensor();
|
//return DentRobot::collector->ArmSensor();
|
||||||
|
return IsTimedOut();
|
||||||
}
|
}
|
||||||
void OpenCollector::End(){
|
void OpenCollector::End(){
|
||||||
DentRobot::collector->MoveArms(0.0f);
|
DentRobot::collector->MoveArms(0.0f);
|
||||||
@ -18,4 +19,4 @@ void OpenCollector::End(){
|
|||||||
void OpenCollector::Interrupted(){
|
void OpenCollector::Interrupted(){
|
||||||
End();
|
End();
|
||||||
}
|
}
|
||||||
// vim: ts2:sw=2:et
|
// vim: ts=2:sw=2:et
|
||||||
|
@ -17,4 +17,4 @@ class OpenCollector: public Command{
|
|||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
// vim: ts2:sw=2:et
|
// vim: ts=2:sw=2:et
|
||||||
|
@ -19,4 +19,4 @@ void ReleaseTote::End(){
|
|||||||
void ReleaseTote::Interrupted(){
|
void ReleaseTote::Interrupted(){
|
||||||
End();
|
End();
|
||||||
}
|
}
|
||||||
// vim: ts2:sw=2:et
|
// vim: ts=2:sw=2:et
|
||||||
|
@ -17,4 +17,4 @@ class ReleaseTote: public Command{
|
|||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
// vim: ts2:sw=2:et
|
// vim: ts=2:sw=2:et
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#include "Drive.h"
|
#include "Drive.h"
|
||||||
#include <cmath>
|
|
||||||
#include "../../DentRobot.h"
|
#include "../../DentRobot.h"
|
||||||
Drive::Drive() : Command("Drive"){
|
Drive::Drive() : Command("Drive"){
|
||||||
Requires(DentRobot::drivetrain);
|
Requires(DentRobot::drivetrain);
|
||||||
@ -12,12 +11,12 @@ void Drive::Execute(){
|
|||||||
x = DentRobot::oi->GetLeftStick()->GetRawAxis(0);
|
x = DentRobot::oi->GetLeftStick()->GetRawAxis(0);
|
||||||
z = DentRobot::oi->GetLeftStick()->GetRawAxis(2);
|
z = DentRobot::oi->GetLeftStick()->GetRawAxis(2);
|
||||||
y = DentRobot::oi->GetLeftStick()->GetRawAxis(1);
|
y = DentRobot::oi->GetLeftStick()->GetRawAxis(1);
|
||||||
if (DentRobot::oi->GetLeftStick()->GetRawButton(1)){
|
//if (DentRobot::oi->GetLeftStick()->GetRawButton(1)){
|
||||||
x=0;
|
// x=0;
|
||||||
}
|
//}
|
||||||
if (DentRobot::oi->GetLeftStick()->GetRawButton(2)){
|
//if (DentRobot::oi->GetLeftStick()->GetRawButton(2)){
|
||||||
y=0;
|
// y=0;
|
||||||
}
|
//}
|
||||||
//X axis, Y axis, Z axis, sensitivity, speed threshold (usually throttle), gyro
|
//X axis, Y axis, Z axis, sensitivity, speed threshold (usually throttle), gyro
|
||||||
DentRobot::drivetrain->DriveMecanum(x,y,z,0.9,0);
|
DentRobot::drivetrain->DriveMecanum(x,y,z,0.9,0);
|
||||||
}
|
}
|
||||||
@ -29,4 +28,4 @@ void Drive::End(){
|
|||||||
void Drive::Interrupted(){
|
void Drive::Interrupted(){
|
||||||
End();
|
End();
|
||||||
}
|
}
|
||||||
// vim: ts2:sw=2:et
|
// vim: ts=2:sw=2:et
|
||||||
|
@ -16,4 +16,4 @@ class Drive: public Command{
|
|||||||
void Interrupted();
|
void Interrupted();
|
||||||
};
|
};
|
||||||
#endif
|
#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"){
|
Lower::Lower() : Command("Lower"){
|
||||||
}
|
}
|
||||||
void Lower::Initialize(){
|
void Lower::Initialize(){
|
||||||
SetTimeout(1.0);
|
SetTimeout(2.5);
|
||||||
}
|
}
|
||||||
void Lower::Execute(){
|
void Lower::Execute(){
|
||||||
DentRobot::elevator->Run(-1.0);
|
DentRobot::elevator->Run(-1.0);
|
||||||
@ -23,4 +23,4 @@ void Lower::End(){
|
|||||||
void Lower::Interrupted(){
|
void Lower::Interrupted(){
|
||||||
End();
|
End();
|
||||||
}
|
}
|
||||||
// vim: ts2:sw=2:et
|
// vim: ts=2:sw=2:et
|
||||||
|
@ -14,4 +14,4 @@ class Lower: public Command{
|
|||||||
void Interrupted();
|
void Interrupted();
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
// vim: ts2:sw=2:et
|
// vim: ts=2:sw=2:et
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
Raise::Raise() : Command("Raise"){
|
Raise::Raise() : Command("Raise"){
|
||||||
}
|
}
|
||||||
void Raise::Initialize(){
|
void Raise::Initialize(){
|
||||||
SetTimeout(2.5);
|
SetTimeout(3.0);
|
||||||
}
|
}
|
||||||
void Raise::Execute(){
|
void Raise::Execute(){
|
||||||
DentRobot::elevator->Run(1.0);
|
DentRobot::elevator->Run(1.0);
|
||||||
@ -18,9 +18,13 @@ bool Raise::IsFinished(){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
void Raise::End(){
|
void Raise::End(){
|
||||||
|
// If the elevator is at the top
|
||||||
|
if(DentRobot::elevator->GetElevatorTop()){
|
||||||
|
DentRobot::elevator->SetUseEncoder(true);
|
||||||
|
}
|
||||||
DentRobot::elevator->Run(0.0f);
|
DentRobot::elevator->Run(0.0f);
|
||||||
}
|
}
|
||||||
void Raise::Interrupted(){
|
void Raise::Interrupted(){
|
||||||
End();
|
End();
|
||||||
}
|
}
|
||||||
// vim: ts2:sw=2:et
|
// vim: ts=2:sw=2:et
|
||||||
|
@ -15,4 +15,4 @@ class Raise: public Command{
|
|||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
// vim: ts2:sw=2:et
|
// vim: ts=2:sw=2:et
|
||||||
|
@ -1,16 +1,21 @@
|
|||||||
#include "DentRobot.h"
|
#include "DentRobot.h"
|
||||||
|
#include "OI.h"
|
||||||
#include "Commands/Autonomous/Autonomous.h"
|
#include "Commands/Autonomous/Autonomous.h"
|
||||||
OI* DentRobot::oi=NULL;
|
OI* DentRobot::oi=NULL;
|
||||||
Collector* DentRobot::collector=NULL;
|
Collector* DentRobot::collector=NULL;
|
||||||
Drivetrain* DentRobot::drivetrain=NULL;
|
Drivetrain* DentRobot::drivetrain=NULL;
|
||||||
Elevator* DentRobot::elevator=NULL;
|
Elevator* DentRobot::elevator=NULL;
|
||||||
|
BinElevator* DentRobot::binElevator=NULL;
|
||||||
CommandGroup* DentRobot::aut=NULL;
|
CommandGroup* DentRobot::aut=NULL;
|
||||||
DentRobot::DentRobot(){
|
DentRobot::DentRobot(){
|
||||||
oi=new OI();
|
oi=new OI();
|
||||||
collector=new Collector();
|
collector=new Collector();
|
||||||
drivetrain=new Drivetrain();
|
drivetrain=new Drivetrain();
|
||||||
elevator=new Elevator();
|
elevator=new Elevator();
|
||||||
|
binElevator=new BinElevator();
|
||||||
aut=new Autonomous();
|
aut=new Autonomous();
|
||||||
|
CameraServer::GetInstance()->SetQuality(25);
|
||||||
|
CameraServer::GetInstance()->StartAutomaticCapture("cam0");
|
||||||
printf("Initialized");
|
printf("Initialized");
|
||||||
}
|
}
|
||||||
void DentRobot::RobotInit(){
|
void DentRobot::RobotInit(){
|
||||||
@ -28,14 +33,19 @@ void DentRobot::AutonomousPeriodic(){
|
|||||||
Scheduler::GetInstance()->Run();
|
Scheduler::GetInstance()->Run();
|
||||||
}
|
}
|
||||||
void DentRobot::TeleopInit(){
|
void DentRobot::TeleopInit(){
|
||||||
//if (aut != NULL){
|
if (aut != NULL){
|
||||||
// aut->Cancel();
|
aut->Cancel();
|
||||||
//}
|
}
|
||||||
}
|
}
|
||||||
void DentRobot::TeleopPeriodic(){
|
void DentRobot::TeleopPeriodic(){
|
||||||
Scheduler::GetInstance()->Run();
|
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(){
|
void DentRobot::TestPeriodic(){
|
||||||
}
|
}
|
||||||
START_ROBOT_CLASS(DentRobot);
|
START_ROBOT_CLASS(DentRobot);
|
||||||
// vim: ts2:sw=2:et
|
// vim: ts=2:sw=2:et
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
#include "WPILib.h"
|
#include "WPILib.h"
|
||||||
#include "OI.h"
|
#include "OI.h"
|
||||||
#include "Subsystems/Elevator.h"
|
#include "Subsystems/Elevator.h"
|
||||||
|
#include "Subsystems/BinElevator.h"
|
||||||
#include "Subsystems/Drivetrain.h"
|
#include "Subsystems/Drivetrain.h"
|
||||||
#include "Subsystems/Collector.h"
|
#include "Subsystems/Collector.h"
|
||||||
#include "Commands/Autonomous/Autonomous.h"
|
#include "Commands/Autonomous/Autonomous.h"
|
||||||
@ -15,6 +16,7 @@ class DentRobot: public IterativeRobot {
|
|||||||
static Collector* collector;
|
static Collector* collector;
|
||||||
static Drivetrain* drivetrain;
|
static Drivetrain* drivetrain;
|
||||||
static Elevator* elevator;
|
static Elevator* elevator;
|
||||||
|
static BinElevator* binElevator;
|
||||||
static CommandGroup* aut;
|
static CommandGroup* aut;
|
||||||
void RobotInit();
|
void RobotInit();
|
||||||
void DisabledPeriodic();
|
void DisabledPeriodic();
|
||||||
|
5
Makefile
5
Makefile
@ -9,6 +9,7 @@ EXEC=bin/FRCUserProgram
|
|||||||
CLEANSER=rm -r
|
CLEANSER=rm -r
|
||||||
|
|
||||||
all : $(OBJECTS)
|
all : $(OBJECTS)
|
||||||
|
if [ ! -d bin ];then mkdir bin; fi
|
||||||
$(CC) -L$(WPILIB)/lib $(LDFLAGS) -o $(EXEC) $(OBJECTS) -lwpi
|
$(CC) -L$(WPILIB)/lib $(LDFLAGS) -o $(EXEC) $(OBJECTS) -lwpi
|
||||||
|
|
||||||
%.o : %.cpp
|
%.o : %.cpp
|
||||||
@ -17,10 +18,10 @@ all : $(OBJECTS)
|
|||||||
clean:
|
clean:
|
||||||
$(CLEANSER) $(OBJECTS) bin/FRCUserProgram
|
$(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'
|
@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'
|
@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:
|
putkey:
|
||||||
|
18
OI.cpp
18
OI.cpp
@ -14,15 +14,15 @@ OI::OI() {
|
|||||||
// Collector
|
// Collector
|
||||||
JoystickButton *right1=new JoystickButton(rightStick, 1);
|
JoystickButton *right1=new JoystickButton(rightStick, 1);
|
||||||
JoystickButton *right2=new JoystickButton(rightStick, 2);
|
JoystickButton *right2=new JoystickButton(rightStick, 2);
|
||||||
JoystickButton *left3=new JoystickButton(leftStick, 3);
|
JoystickButton *left1=new JoystickButton(leftStick, 1);
|
||||||
JoystickButton *left4=new JoystickButton(leftStick, 4);
|
JoystickButton *left2=new JoystickButton(leftStick, 2);
|
||||||
right1->WhileHeld(new OpenCollector());
|
right1->WhileHeld(new CloseCollector());
|
||||||
right2->WhileHeld(new CloseCollector());
|
right2->WhileHeld(new OpenCollector());
|
||||||
left3->WhileHeld(new CollectTote());
|
left1->WhileHeld(new CollectTote());
|
||||||
left4->WhileHeld(new ReleaseTote());
|
left2->WhileHeld(new ReleaseTote());
|
||||||
// Elevator
|
// Elevator
|
||||||
Raise* raise=new Raise();
|
raise=new Raise();
|
||||||
Lower* lower=new Lower();
|
lower=new Lower();
|
||||||
JoystickButton *right3=new JoystickButton(rightStick, 3);
|
JoystickButton *right3=new JoystickButton(rightStick, 3);
|
||||||
JoystickButton *right4=new JoystickButton(rightStick, 4);
|
JoystickButton *right4=new JoystickButton(rightStick, 4);
|
||||||
JoystickButton *right5=new JoystickButton(rightStick, 5);
|
JoystickButton *right5=new JoystickButton(rightStick, 5);
|
||||||
@ -50,4 +50,4 @@ Joystick* OI::GetRightStick(){
|
|||||||
Joystick* OI::GetLeftStick(){
|
Joystick* OI::GetLeftStick(){
|
||||||
return leftStick;
|
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
|
#define OI_H
|
||||||
|
|
||||||
#include "WPILib.h"
|
#include "WPILib.h"
|
||||||
|
#include "Commands/Command.h"
|
||||||
|
|
||||||
class OI
|
class OI
|
||||||
{
|
{
|
||||||
@ -11,6 +12,7 @@ class OI
|
|||||||
OI();
|
OI();
|
||||||
Joystick* GetRightStick();
|
Joystick* GetRightStick();
|
||||||
Joystick* GetLeftStick();
|
Joystick* GetLeftStick();
|
||||||
|
Command *raise, *lower;
|
||||||
};
|
};
|
||||||
#endif
|
#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_BOTTOM_DIO 0
|
||||||
#define ELEVATOR_COLELCT_TOTE_DIO 1
|
#define ELEVATOR_COLELCT_TOTE_DIO 1
|
||||||
#define ELEVATOR_READY_TOTE_DIO 2
|
#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_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
|
// Drivetrain
|
||||||
#define DRIVE_FRONT_LEFT_CAN 2
|
#define DRIVE_FRONT_LEFT_CAN 2
|
||||||
@ -22,7 +30,8 @@
|
|||||||
#define COLLECTOR_WINDOW_LEFT_CAN 6
|
#define COLLECTOR_WINDOW_LEFT_CAN 6
|
||||||
#define COLLECTOR_WINDOW_RIGHT_CAN 7
|
#define COLLECTOR_WINDOW_RIGHT_CAN 7
|
||||||
#define COLLECTOR_LEFT_CAN 8
|
#define COLLECTOR_LEFT_CAN 8
|
||||||
|
#define COLLECTOR_BOTTOM_CAN 10
|
||||||
#define COLLECTOR_RIGHT_CAN 9
|
#define COLLECTOR_RIGHT_CAN 9
|
||||||
|
|
||||||
#endif
|
#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);
|
windowMotorLeft=new CANTalon(COLLECTOR_WINDOW_LEFT_CAN);
|
||||||
windowMotorRight=new CANTalon(COLLECTOR_WINDOW_RIGHT_CAN);
|
windowMotorRight=new CANTalon(COLLECTOR_WINDOW_RIGHT_CAN);
|
||||||
collectorMotorLeft=new CANTalon(COLLECTOR_LEFT_CAN);
|
collectorMotorLeft=new CANTalon(COLLECTOR_LEFT_CAN);
|
||||||
|
collectorMotorBottom=new CANTalon(COLLECTOR_BOTTOM_CAN);
|
||||||
collectorMotorRight=new CANTalon(COLLECTOR_RIGHT_CAN);
|
collectorMotorRight=new CANTalon(COLLECTOR_RIGHT_CAN);
|
||||||
}
|
}
|
||||||
void Collector::InitDefaultCommand() {
|
void Collector::InitDefaultCommand() {
|
||||||
@ -15,6 +16,7 @@ void Collector::MoveArms(double a){
|
|||||||
}
|
}
|
||||||
void Collector::MoveRollers(double a){
|
void Collector::MoveRollers(double a){
|
||||||
collectorMotorLeft->Set(a);
|
collectorMotorLeft->Set(a);
|
||||||
|
collectorMotorBottom->Set(a);
|
||||||
collectorMotorRight->Set(-a);
|
collectorMotorRight->Set(-a);
|
||||||
}
|
}
|
||||||
bool Collector::ArmSensor(){
|
bool Collector::ArmSensor(){
|
||||||
@ -25,4 +27,4 @@ bool Collector::BoxCollected(){
|
|||||||
return false;
|
return false;
|
||||||
//return boxSwitch->Get();
|
//return boxSwitch->Get();
|
||||||
}
|
}
|
||||||
// vim: ts2:sw=2:et
|
// vim: ts=2:sw=2:et
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
class Collector: public Subsystem
|
class Collector: public Subsystem
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
CANTalon *windowMotorLeft, *windowMotorRight, *collectorMotorLeft, *collectorMotorRight;
|
CANTalon *windowMotorLeft, *windowMotorRight, *collectorMotorLeft, *collectorMotorBottom, *collectorMotorRight;
|
||||||
public:
|
public:
|
||||||
Collector();
|
Collector();
|
||||||
void InitDefaultCommand();
|
void InitDefaultCommand();
|
||||||
@ -15,4 +15,4 @@ class Collector: public Subsystem
|
|||||||
bool BoxCollected();
|
bool BoxCollected();
|
||||||
};
|
};
|
||||||
#endif
|
#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;
|
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);
|
void TestMotor(e_motors,float);
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
// vim: ts2:sw=2:et
|
// vim: ts=2:sw=2:et
|
||||||
|
@ -2,26 +2,26 @@
|
|||||||
#include "../RobotMap.h"
|
#include "../RobotMap.h"
|
||||||
Elevator::Elevator(){
|
Elevator::Elevator(){
|
||||||
motor=new CANTalon(ELEVATOR_CAN);
|
motor=new CANTalon(ELEVATOR_CAN);
|
||||||
elevatorEncoder=new Encoder(0,1,false);
|
elevatorEncoder=new Encoder(ELEVATOR_ENCODERA,ELEVATOR_ENCODERB,false);
|
||||||
offset=0;
|
|
||||||
height=0;
|
|
||||||
elevatorBottom=new DigitalInput(ELEVATOR_BOTTOM_DIO);
|
elevatorBottom=new DigitalInput(ELEVATOR_BOTTOM_DIO);
|
||||||
elevatorTop=new DigitalInput(ELEVATOR_TOP_DIO);
|
elevatorTop=new DigitalInput(ELEVATOR_TOP_DIO);
|
||||||
//SetAbsoluteTolerance(0.004);
|
// Checks if the elevator is drifting
|
||||||
|
useEncoder=false;
|
||||||
}
|
}
|
||||||
void Elevator::InitDefaultCommand(){
|
void Elevator::InitDefaultCommand(){
|
||||||
}
|
}
|
||||||
void Elevator::Run(double power){
|
void Elevator::Run(double power){
|
||||||
|
// If we're not telling it to stop
|
||||||
|
if(power != 0.0){
|
||||||
|
SetUseEncoder(false);
|
||||||
|
}
|
||||||
motor->Set(power);
|
motor->Set(power);
|
||||||
}
|
}
|
||||||
void Elevator::SetOffset(double ht){
|
|
||||||
offset=ht;
|
|
||||||
}
|
|
||||||
void Elevator::ResetEncoder(){
|
void Elevator::ResetEncoder(){
|
||||||
elevatorEncoder->Reset();
|
elevatorEncoder->Reset();
|
||||||
}
|
}
|
||||||
double Elevator::GetHeight(){
|
double Elevator::GetHeight(){
|
||||||
return elevatorEncoder->Get()+offset;
|
return elevatorEncoder->Get();
|
||||||
}
|
}
|
||||||
bool Elevator::GetElevatorBottom(){
|
bool Elevator::GetElevatorBottom(){
|
||||||
return elevatorBottom->Get();
|
return elevatorBottom->Get();
|
||||||
@ -29,4 +29,10 @@ bool Elevator::GetElevatorBottom(){
|
|||||||
bool Elevator::GetElevatorTop(){
|
bool Elevator::GetElevatorTop(){
|
||||||
return elevatorTop->Get();
|
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;
|
CANTalon *motor;
|
||||||
Encoder *elevatorEncoder;
|
Encoder *elevatorEncoder;
|
||||||
static constexpr double kP_real=4, kI_real=.0f, kP_simulation=18, kI_simulation=.2;
|
static constexpr double kP_real=4, kI_real=.0f, kP_simulation=18, kI_simulation=.2;
|
||||||
double offset, height;
|
|
||||||
DigitalInput *elevatorBottom, *elevatorTop;
|
DigitalInput *elevatorBottom, *elevatorTop;
|
||||||
|
bool useEncoder;
|
||||||
public:
|
public:
|
||||||
Elevator();
|
Elevator();
|
||||||
void InitDefaultCommand();
|
void InitDefaultCommand();
|
||||||
void Run(double);
|
void Run(double);
|
||||||
void SetOffset(double);
|
|
||||||
void ResetEncoder();
|
void ResetEncoder();
|
||||||
double GetHeight();
|
double GetHeight();
|
||||||
bool GetElevatorTop();
|
bool GetElevatorTop();
|
||||||
bool GetElevatorBottom();
|
bool GetElevatorBottom();
|
||||||
|
void SetUseEncoder(bool);
|
||||||
|
bool GetUseEncoder();
|
||||||
};
|
};
|
||||||
#endif
|
#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