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

Added collector code (untested)

This commit is contained in:
Austen Adler 2015-01-09 20:57:26 -05:00
parent 734399f344
commit f61920501d
4 changed files with 53 additions and 2 deletions

View File

@ -3,6 +3,7 @@
HHRobot::HHRobot():
hhdrive(new RobotDrive(2,0,3,1)),
gyro(new Gyro(1)),
collector(new DentCollector(4, 5, 6, 7)),
joystick1(new Extreme3dPro(0)){
hhdrive->SetExpiration(0.1);
hhdrive->SetInvertedMotor(RobotDrive::kFrontRightMotor, true);
@ -26,6 +27,17 @@ void HHRobot::Handler(){
}else{
hhdrive->MecanumDrive_Cartesian(joystick1->GetJoystickAxis("z"), joystick1->GetJoystickAxis("y"), joystick1->GetJoystickAxis("x"));
}
if(joystick1->GetJoystickButton(11)){
collector->Collect(255);
}else if(joystick1->GetJoystickButton(12)){
collector->Collect(1);
}else if(joystick1->GetJoystickButton(9)){
collector->Raise(255);
}else if(joystick1->GetJoystickButton(10)){
collector->Raise(1);
}else{
collector->Rest();
}
Wait(0.005);
// hhdrive->MecanumDrive_Cartesian(joystick1->GetJoystickAxis("z"), joystick1->GetJoystickAxis("y"), joystick1->GetJoystickAxis("x"));
}

View File

@ -1,12 +1,14 @@
#ifndef __ZAPHOD_ROBOT_H__
#define __ZAPHOD_ROBOT_H__
#ifndef __ROBOT_H__
#define __ROBOT_H__
#include <WPILib.h>
#include "HHBase.h"
#include "classes/Collector.h"
#include "hhlib/input/controller/Joystick.h"
class HHRobot{
private:
RobotDrive *hhdrive;
Gyro *gyro;
DentCollector *collector;
Extreme3dPro *joystick1;
public:
HHRobot();

22
src/classes/Collector.cpp Normal file
View File

@ -0,0 +1,22 @@
#include "Collector.h"
DentCollector::DentCollector(int fl, int fr, int rl, int rr){
frontLeft = new Talon(fl);
frontRight = new Talon(fr);
raiserLeft = new Talon(rl);
raiserRight = new Talon(rr);
}
void DentCollector::Collect(int power){
frontLeft->Set(power);
frontRight->Set(power);
}
void DentCollector::Raise(int power){
raiserLeft->Set(power);
raiserRight->Set(power);
}
void DentCollector::Rest(){
raiserLeft->Set(0);
raiserRight->Set(0);
frontLeft->Set(0);
frontRight->Set(0);
}
// vim: ts=2:sw=2:et

15
src/classes/Collector.h Normal file
View File

@ -0,0 +1,15 @@
#ifndef __COLLECTOR_H__
#include <WPILib.h>
#define __COLLECTOR_H__
//#include ""
class DentCollector{
private:
Talon *frontLeft, *frontRight, *raiserLeft, *raiserRight;
public:
DentCollector(int, int, int, int);
void Collect(int);
void Raise(int);
void Rest();
};
#endif
// vim: ts=2:sw=2:et