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

Robot fully works

This commit is contained in:
Austen Adler 2015-02-07 17:04:16 -05:00
parent f8da6b1d22
commit 4c6e75969e
6 changed files with 23 additions and 18 deletions

2
.env
View File

@ -7,7 +7,7 @@ function mc(){
function mk(){ function mk(){
vagrant ssh -c "cd /vagrant/src;make" vagrant ssh -c "cd /vagrant/src;make"
} }
function md(){ function me(){
vagrant ssh -c "cd /vagrant/src;make deploy" vagrant ssh -c "cd /vagrant/src;make deploy"
} }
function ma(){ function ma(){

View File

@ -13,7 +13,7 @@ void AutoDrive::Execute(){
DentRobot::drivetrain->DriveMecanum(0.5,0,0,0.9,0); DentRobot::drivetrain->DriveMecanum(0.5,0,0,0.9,0);
} }
bool AutoDrive::IsFinished(){ bool AutoDrive::IsFinished(){
return false; return IsTimedOut();
} }
void AutoDrive::End(){ void AutoDrive::End(){
} }

View File

@ -18,10 +18,6 @@ void Drive::Execute(){
if (DentRobot::oi->GetLeftStick()->GetRawButton(2)){ if (DentRobot::oi->GetLeftStick()->GetRawButton(2)){
y=0; y=0;
} }
if (DentRobot::oi->GetLeftStick()->GetRawAxis(3)<=0.5){
y /= 2;
z /= 2;
}
//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);
} }

View File

@ -4,13 +4,14 @@
Lower::Lower() : Command("Lower"){ Lower::Lower() : Command("Lower"){
} }
void Lower::Initialize(){ void Lower::Initialize(){
SetTimeout(2.0); SetTimeout(1.0);
} }
void Lower::Execute(){ void Lower::Execute(){
DentRobot::elevator->Run((-DentRobot::oi->GetLeftStick()->GetRawAxis(3)+1.0)/2); DentRobot::elevator->Run(-1.0);
} }
bool Lower::IsFinished(){ bool Lower::IsFinished(){
if (DentRobot::elevator->GetElevatorBottom()||IsTimedOut()){ if (!DentRobot::elevator->GetElevatorBottom()||IsTimedOut()){
printf("Robot stoped lowering. Sensor based? %d\n", !DentRobot::elevator->GetElevatorBottom());
return true; return true;
}else{ }else{
return false; return false;

View File

@ -4,13 +4,14 @@
Raise::Raise() : Command("Raise"){ Raise::Raise() : Command("Raise"){
} }
void Raise::Initialize(){ void Raise::Initialize(){
SetTimeout(2.0); SetTimeout(2.5);
} }
void Raise::Execute(){ void Raise::Execute(){
DentRobot::elevator->Run(-(-DentRobot::oi->GetLeftStick()->GetRawAxis(3)+1.0)/2); DentRobot::elevator->Run(1.0);
} }
bool Raise::IsFinished(){ bool Raise::IsFinished(){
if (DentRobot::elevator->GetElevatorTop()||IsTimedOut()){ if (!DentRobot::elevator->GetElevatorTop()||IsTimedOut()){
printf("Robot stoped raising. Sensor based? %d\n", !DentRobot::elevator->GetElevatorTop());
return true; return true;
}else{ }else{
return false; return false;

19
OI.cpp
View File

@ -7,21 +7,28 @@
#include "Commands/Collector/ReleaseTote.h" #include "Commands/Collector/ReleaseTote.h"
OI::OI() { OI::OI() {
// Joysticks
leftStick=new Joystick(0); leftStick=new Joystick(0);
rightStick=new Joystick(1); rightStick=new Joystick(1);
//TODO name these buttons to their functions rather to their number
// 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 *left4=new JoystickButton(leftStick, 4);
right1->WhileHeld(new OpenCollector());
right2->WhileHeld(new CloseCollector());
left3->WhileHeld(new CollectTote());
left4->WhileHeld(new ReleaseTote());
// Elevator
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);
JoystickButton *right6=new JoystickButton(rightStick, 6); JoystickButton *right6=new JoystickButton(rightStick, 6);
right1->WhileHeld(new OpenCollector()); right3->WhenPressed(new Lower());
right2->WhileHeld(new CloseCollector()); right4->WhenPressed(new Lower());
right3->WhileHeld(new CollectTote());
right4->WhileHeld(new ReleaseTote());
right5->WhenPressed(new Raise()); right5->WhenPressed(new Raise());
right6->WhenPressed(new Lower()); right6->WhenPressed(new Raise());
} }
Joystick* OI::GetRightStick(){ Joystick* OI::GetRightStick(){
return rightStick; return rightStick;