diff --git a/src/HHRobot.cpp b/src/HHRobot.cpp index 5ce416c..e8a2eae 100644 --- a/src/HHRobot.cpp +++ b/src/HHRobot.cpp @@ -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")); } diff --git a/src/HHRobot.h b/src/HHRobot.h index 398e3de..a930468 100644 --- a/src/HHRobot.h +++ b/src/HHRobot.h @@ -1,12 +1,14 @@ -#ifndef __ZAPHOD_ROBOT_H__ -#define __ZAPHOD_ROBOT_H__ +#ifndef __ROBOT_H__ +#define __ROBOT_H__ #include #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(); diff --git a/src/classes/Collector.cpp b/src/classes/Collector.cpp new file mode 100644 index 0000000..ab1a040 --- /dev/null +++ b/src/classes/Collector.cpp @@ -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 diff --git a/src/classes/Collector.h b/src/classes/Collector.h new file mode 100644 index 0000000..386f078 --- /dev/null +++ b/src/classes/Collector.h @@ -0,0 +1,15 @@ +#ifndef __COLLECTOR_H__ +#include +#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