2
0
mirror of https://github.com/team2059/Dent synced 2024-12-18 20:52:29 -05:00

Attempted writing Raise and Lower commands (untested)

This commit is contained in:
Austen Adler 2015-01-17 13:28:27 -05:00
parent 8d296a6718
commit 6c62797e07
9 changed files with 28 additions and 14 deletions

View File

@ -2,6 +2,7 @@
#include "Subsystems/Drivetrain.h"
#include "Subsystems/Collector.h"
#include "Subsystems/Elevator.h"
#include "Commands/Drive.h"
#include "Commands/Collect.h"
#include "Commands/Eject.h"
#include "Commands/Raise.h"
@ -21,4 +22,3 @@ void CommandBase::init()
elevator = new Elevator();
oi = new OI();
}

View File

@ -9,7 +9,6 @@ bool Collect::IsFinished(){
return false;
}
void Collect::End(){
}
void Collect::Interrupted(){
}

View File

@ -1,11 +1,22 @@
#include "Drive.h"
#include <cmath>
#include "../DentRobot.h"
Drive::Drive() : Command("Drive"){
}
void Drive::Initialize(){
}
void Drive::Execute(){
DentRobot::drivetrain->DriveMecanum(DentRobot::oi->GetLeftStick()->GetRawAxis(2), DentRobot::oi->GetLeftStick()->GetRawAxis(1), DentRobot::oi->GetLeftStick()->GetRawAxis(0));
static float sens=0.7;
float x, y, twist;
x=DentRobot::oi->GetLeftStick()->GetRawAxis(0);
y=DentRobot::oi->GetLeftStick()->GetRawAxis(1);
twist=DentRobot::oi->GetLeftStick()->GetRawAxis(2);
if(true){
x=sens*std::pow(x, 3)+(1.0f-sens)*x;
y=sens*std::pow(y, 3)+(1.0f-sens)*y;
}
//DentRobot::drivetrain->DriveMecanum(DentRobot::oi->GetLeftStick()->GetRawAxis(2), DentRobot::oi->GetLeftStick()->GetRawAxis(1), DentRobot::oi->GetLeftStick()->GetRawAxis(0));
DentRobot::drivetrain->DriveMecanum(x, y, twist);
}
bool Drive::IsFinished(){
return false;

View File

@ -12,7 +12,6 @@ bool Eject::IsFinished(){
return false;
}
void Eject::End(){
}
void Eject::Interrupted(){
}

View File

@ -1,15 +1,19 @@
#include "Lower.h"
#include "../DentRobot.h"
Lower::Lower() : Command("Lower"){
}
void Lower::Initialize(){
}
void Lower::Execute(){
DentRobot::elevator->Run(-0.4f);
}
bool Lower::IsFinished(){
return false;
// 0.1f is a placeholder for the min elevator value
return DentRobot::elevator->GetPotValue()>=0.1f;
}
void Lower::End(){
DentRobot::elevator->Run(0.0f);
}
void Lower::Interrupted(){
End();
}

View File

@ -13,5 +13,4 @@ class Lower: public Command{
void End();
void Interrupted();
};
#endif

View File

@ -1,15 +1,19 @@
#include "Raise.h"
#include "../DentRobot.h"
Raise::Raise(){
}
void Raise::Initialize(){
}
void Raise::Execute(){
DentRobot::elevator->Run(0.4f);
}
bool Raise::IsFinished(){
return false;
// 0.9f is a placeholder for the max elevator value
return DentRobot::elevator->GetPotValue()>=0.9f;
}
void Raise::End(){
DentRobot::elevator->Run(0.0f);
}
void Raise::Interrupted(){
End();
}

View File

@ -1,7 +1,6 @@
#include "Elevator.h"
#include "../RobotMap.h"
//Elevator::Elevator() : PIDSubsystem("Elevator", kP_real, kI_real, 0.0){
Elevator::Elevator() : Subsystem("Elevator"){
Elevator::Elevator() : PIDSubsystem("Elevator", kP_real, kI_real, 0.0){
pot=new AnalogPotentiometer(0);
leftMotor=new Talon(1);
rightMotor=new Talon(0);

View File

@ -2,9 +2,8 @@
#define ELEVATOR_H
#include "WPILib.h"
//#include "Commands/PIDSubsystem.h"
//class Elevator: public PIDSubsystem{
class Elevator: public Subsystem{
#include "Commands/PIDSubsystem.h"
class Elevator: public PIDSubsystem{
private:
AnalogPotentiometer *pot;
Talon *leftMotor, *rightMotor;