2
0
mirror of https://github.com/team2059/Zaphod synced 2024-12-18 20:12:28 -05:00

it shoots, it scores.

This commit is contained in:
Adam Long 2014-12-06 19:46:20 +00:00
parent 078cf93c94
commit a06d05b176
5 changed files with 18 additions and 14 deletions

View File

@ -1,6 +1,9 @@
#ifndef __DEFINITIONS_H__
#define __DEFINITIONS_H__
#define CODE_VERSION 0.07
//Sidecar declarations
#define DRIVE_LEFT_SIDECAR 1
#define DRIVE_RIGHT_SIDECAR 2

View File

@ -10,17 +10,19 @@ HHRobot::HHRobot():
//sonar(new HHSonar()){
driveTable=NetworkTable::GetTable("ZaphodDrive");
shooterTable=NetworkTable::GetTable("ZaphodShooter");
collectorTable=NetworkTable::GetTable("ZaphodCollector");
right1 = new Talon(DRIVE_RIGHT_SIDECAR,DRIVE_RIGHT_MOTOR_ONE);
right2 = new Talon(DRIVE_RIGHT_SIDECAR,DRIVE_RIGHT_MOTOR_TWO);
right3 = new Talon(DRIVE_RIGHT_SIDECAR,DRIVE_RIGHT_MOTOR_THREE);
left1 = new Talon(DRIVE_LEFT_SIDECAR, DRIVE_LEFT_MOTOR_ONE);
left2 = new Talon(DRIVE_LEFT_SIDECAR, DRIVE_LEFT_MOTOR_TWO);
left3 = new Talon(DRIVE_LEFT_SIDECAR, DRIVE_LEFT_MOTOR_THREE);
shooterTable->PutNumber("Target Shooter Angle",90);
}
void HHRobot::Init(){
printf("Initing\n");
printf("Code Version: 0.0.06\n");
printf("Code Version: %f\n",CODE_VERSION);
collector->CollectBallAtSpeed(0);
//Put table values initally to avoid annoying refreshing
shooterTable->PutNumber("Target Shooter Angle",90);
@ -102,7 +104,7 @@ void HHRobot::RunAuto(){
//Main function used to handle periodic tasks on the robot
void HHRobot::Handler(){
int targetAngle;
double targetAngle = shooterTable->GetNumber("Target Shooter Angle");
bool allowCompressing;
//Periodic tasks that should be run by every loop
shooter->UpdateShooterPosition(targetAngle);
@ -119,9 +121,12 @@ void HHRobot::Handler(){
//Collector button assignments
if(controlSystem->GetJoystickButton(1,COLLECTOR_INTAKE)) {
collector->CollectBall();
collectorTable->PutNumber("Current Collector Speed",1);
}else if(controlSystem->GetJoystickButton(1,COLLECTOR_OUTTAKE)) {
collectorTable->PutNumber("Current Collector Speed",-1);
collector->ReleaseBall();
}else{
collectorTable->PutNumber("Current Collector Speed",0);
collector->CollectorStop();
}
if(controlSystem->GetJoystickButton(1,COLLECTOR_EXTEND)){
@ -132,20 +137,17 @@ void HHRobot::Handler(){
}
if(controlSystem->GetJoystickButton(2,SHOOTER_ANGLE_ONE)){
targetAngle=100;
shooterTable->PutNumber("Target Shooter Angle",targetAngle);
}
if(controlSystem->GetJoystickButton(2,SHOOTER_ANGLE_TWO)){
targetAngle=120;
shooterTable->PutNumber("Target Shooter Angle",targetAngle);
}
if(controlSystem->GetJoystickButton(2,SHOOTER_ANGLE_THREE)){
targetAngle=90;
shooterTable->PutNumber("Target Shooter Angle",targetAngle);
}
if(controlSystem->GetJoystickButton(2,SHOOTER_ANGLE_FOUR)){
targetAngle=130;
shooterTable->PutNumber("Target Shooter Angle",targetAngle);
}
shooterTable->PutNumber("Target Shooter Angle",targetAngle);
//TODO: Fix whatever this is supposed to do
//if(controlSystem->rightJoystickValues[DISABLE_COMPRESSOR]){
if(false){
@ -159,8 +161,7 @@ void HHRobot::Handler(){
targetAngle=100;
if(sonar->GetInches("FRONTLEFT")>=45){
DriveRobot(0,-.5);
}
else{
} else{
DriveRobot(0,0);
}
}

View File

@ -15,7 +15,7 @@ class HHRobot{
Talon *right1, *right2, *right3, *left1, *left2, *left3;
Joystick *rightStick, *leftStick;
JoystickController *controlSystem;
NetworkTable *driveTable, *shooterTable;
NetworkTable *driveTable, *shooterTable, *collectorTable;
HHShooter *shooter;
HHCollector *collector;
HHCompressor *compressorSystem;

View File

@ -11,11 +11,11 @@ void HHShooter::StartShootingSequence(float throttle){
//Changes the enum to tell the shooter to be firing
e_ShooterState=FIRING;
// Convert the throttle input to a pwm value
shootingPower=throttle * 127.0f + 128;
shootingPower=throttle;
}
//First step in shooting process
bool HHShooter::ShootForAngle(float power, float desiredAngle){
if(GetAngle() <= desiredAngle && power >= 15){
if(GetAngle() <= desiredAngle){
ShootRaw(power);
e_ShooterState=FIRING;
return true;
@ -49,7 +49,7 @@ void HHShooter::ShootRaw(float power){
shooterRight2->SetRaw(int(FloatToPWM(-power)));
}
//Should be run in a loop
void HHShooter::UpdateShooterPosition(int angle){
void HHShooter::UpdateShooterPosition(double angle){
if(e_ShooterState == IDLE_PRESHOT){
isShooting=false;
StopShooter();
@ -58,7 +58,7 @@ void HHShooter::UpdateShooterPosition(int angle){
isShooting=true;
if (ShootForAngle(shootingPower,angle)){
printf("Shooting!\n");
printf("Shooting at power %f\n",shooterRight1->GetRaw());
printf("Shooting at power %d\n",shooterRight1->GetRaw());
}
else {
printf("Done shooting!\n");

View File

@ -19,7 +19,7 @@ class HHShooter{
void ShootRaw(float);
void Lower(float);
void StopShooter();
void UpdateShooterPosition(int);
void UpdateShooterPosition(double);
float FloatToPWM(float input);
float GetAngle();
};