2015-01-05 19:07:24 -05:00
|
|
|
#include "HHRobot.h"
|
|
|
|
#include "HHBase.h"
|
|
|
|
HHRobot::HHRobot():
|
|
|
|
hhdrive(new RobotDrive(2,0,3,1)),
|
2015-01-09 20:20:05 -05:00
|
|
|
gyro(new Gyro(1)),
|
2015-01-09 20:57:26 -05:00
|
|
|
collector(new DentCollector(4, 5, 6, 7)),
|
2015-01-10 21:24:24 -05:00
|
|
|
driveStick(new Extreme3dPro(0)){
|
2015-01-05 19:07:24 -05:00
|
|
|
hhdrive->SetExpiration(0.1);
|
2015-01-09 20:20:05 -05:00
|
|
|
hhdrive->SetInvertedMotor(RobotDrive::kFrontRightMotor, true);
|
|
|
|
hhdrive->SetInvertedMotor(RobotDrive::kRearLeftMotor,true);
|
2015-01-05 19:07:24 -05:00
|
|
|
}
|
|
|
|
void HHRobot::Init(){
|
|
|
|
printf("Initing\n");
|
|
|
|
printf("Code Version: %f\n",0000.1);
|
2015-01-09 20:20:05 -05:00
|
|
|
gyro->Reset();
|
2015-01-05 19:07:24 -05:00
|
|
|
}
|
|
|
|
//Main function used to handle periodic tasks on the robot
|
|
|
|
void HHRobot::Handler(){
|
2015-01-09 20:20:05 -05:00
|
|
|
const float Kp = 0.3;
|
2015-01-10 21:24:24 -05:00
|
|
|
if(driveStick->GetJoystickButton(1)==1){
|
|
|
|
hhdrive->MecanumDrive_Cartesian(driveStick->GetJoystickAxis("z"), 0, driveStick->GetJoystickAxis("x"));
|
|
|
|
}else if(driveStick->GetJoystickButton(2)==1){
|
|
|
|
hhdrive->MecanumDrive_Cartesian(driveStick->GetJoystickAxis("z"), driveStick->GetJoystickAxis("y"), 0);
|
|
|
|
}else if(driveStick->GetJoystickButton(3)==1){
|
|
|
|
hhdrive->Drive(driveStick->GetJoystickAxis("y"), driveStick->GetJoystickAxis("y")*Kp*-gyro->GetAngle());
|
2015-01-09 20:20:05 -05:00
|
|
|
}else{
|
2015-01-10 21:24:24 -05:00
|
|
|
hhdrive->MecanumDrive_Cartesian(driveStick->GetJoystickAxis("z"), driveStick->GetJoystickAxis("y"), driveStick->GetJoystickAxis("x"));
|
2015-01-09 20:20:05 -05:00
|
|
|
}
|
2015-01-10 21:24:24 -05:00
|
|
|
if(driveStick->GetJoystickButton(11)==1){
|
|
|
|
collector->Collect(driveStick->GetThrottle());
|
|
|
|
}else if(driveStick->GetJoystickButton(12)==1){
|
|
|
|
collector->Collect(-driveStick->GetThrottle());
|
|
|
|
}else if(driveStick->GetJoystickButton(9)==1){
|
|
|
|
collector->Raise(driveStick->GetThrottle());
|
|
|
|
}else if(driveStick->GetJoystickButton(10)==1){
|
|
|
|
collector->Raise(-driveStick->GetThrottle());
|
2015-01-09 20:57:26 -05:00
|
|
|
}else{
|
|
|
|
collector->Rest();
|
|
|
|
}
|
2015-01-10 21:24:24 -05:00
|
|
|
SmartDashboard::PutNumber("hambone1", driveStick->GetThrottle());
|
|
|
|
SmartDashboard::PutNumber("hambone2", driveStick->GetJoystickAxis("joystick"));
|
|
|
|
SmartDashboard::PutNumber("hambone3", driveStick->GetRawJoystickAxis(3));
|
|
|
|
printf("hambone2: %f", driveStick->GetThrottle());
|
2015-01-09 20:20:05 -05:00
|
|
|
Wait(0.005);
|
2015-01-05 19:07:24 -05:00
|
|
|
}
|
|
|
|
// vim: ts=2:sw=2:et
|