mirror of
https://github.com/team2059/Zaphod
synced 2025-01-27 22:21:07 -05:00
it shoots, it scores.
This commit is contained in:
parent
078cf93c94
commit
a06d05b176
@ -1,6 +1,9 @@
|
|||||||
#ifndef __DEFINITIONS_H__
|
#ifndef __DEFINITIONS_H__
|
||||||
#define __DEFINITIONS_H__
|
#define __DEFINITIONS_H__
|
||||||
|
|
||||||
|
|
||||||
|
#define CODE_VERSION 0.07
|
||||||
|
|
||||||
//Sidecar declarations
|
//Sidecar declarations
|
||||||
#define DRIVE_LEFT_SIDECAR 1
|
#define DRIVE_LEFT_SIDECAR 1
|
||||||
#define DRIVE_RIGHT_SIDECAR 2
|
#define DRIVE_RIGHT_SIDECAR 2
|
||||||
|
@ -10,17 +10,19 @@ HHRobot::HHRobot():
|
|||||||
//sonar(new HHSonar()){
|
//sonar(new HHSonar()){
|
||||||
driveTable=NetworkTable::GetTable("ZaphodDrive");
|
driveTable=NetworkTable::GetTable("ZaphodDrive");
|
||||||
shooterTable=NetworkTable::GetTable("ZaphodShooter");
|
shooterTable=NetworkTable::GetTable("ZaphodShooter");
|
||||||
|
collectorTable=NetworkTable::GetTable("ZaphodCollector");
|
||||||
right1 = new Talon(DRIVE_RIGHT_SIDECAR,DRIVE_RIGHT_MOTOR_ONE);
|
right1 = new Talon(DRIVE_RIGHT_SIDECAR,DRIVE_RIGHT_MOTOR_ONE);
|
||||||
right2 = new Talon(DRIVE_RIGHT_SIDECAR,DRIVE_RIGHT_MOTOR_TWO);
|
right2 = new Talon(DRIVE_RIGHT_SIDECAR,DRIVE_RIGHT_MOTOR_TWO);
|
||||||
right3 = new Talon(DRIVE_RIGHT_SIDECAR,DRIVE_RIGHT_MOTOR_THREE);
|
right3 = new Talon(DRIVE_RIGHT_SIDECAR,DRIVE_RIGHT_MOTOR_THREE);
|
||||||
left1 = new Talon(DRIVE_LEFT_SIDECAR, DRIVE_LEFT_MOTOR_ONE);
|
left1 = new Talon(DRIVE_LEFT_SIDECAR, DRIVE_LEFT_MOTOR_ONE);
|
||||||
left2 = new Talon(DRIVE_LEFT_SIDECAR, DRIVE_LEFT_MOTOR_TWO);
|
left2 = new Talon(DRIVE_LEFT_SIDECAR, DRIVE_LEFT_MOTOR_TWO);
|
||||||
left3 = new Talon(DRIVE_LEFT_SIDECAR, DRIVE_LEFT_MOTOR_THREE);
|
left3 = new Talon(DRIVE_LEFT_SIDECAR, DRIVE_LEFT_MOTOR_THREE);
|
||||||
|
shooterTable->PutNumber("Target Shooter Angle",90);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HHRobot::Init(){
|
void HHRobot::Init(){
|
||||||
printf("Initing\n");
|
printf("Initing\n");
|
||||||
printf("Code Version: 0.0.06\n");
|
printf("Code Version: %f\n",CODE_VERSION);
|
||||||
collector->CollectBallAtSpeed(0);
|
collector->CollectBallAtSpeed(0);
|
||||||
//Put table values initally to avoid annoying refreshing
|
//Put table values initally to avoid annoying refreshing
|
||||||
shooterTable->PutNumber("Target Shooter Angle",90);
|
shooterTable->PutNumber("Target Shooter Angle",90);
|
||||||
@ -102,7 +104,7 @@ void HHRobot::RunAuto(){
|
|||||||
|
|
||||||
//Main function used to handle periodic tasks on the robot
|
//Main function used to handle periodic tasks on the robot
|
||||||
void HHRobot::Handler(){
|
void HHRobot::Handler(){
|
||||||
int targetAngle;
|
double targetAngle = shooterTable->GetNumber("Target Shooter Angle");
|
||||||
bool allowCompressing;
|
bool allowCompressing;
|
||||||
//Periodic tasks that should be run by every loop
|
//Periodic tasks that should be run by every loop
|
||||||
shooter->UpdateShooterPosition(targetAngle);
|
shooter->UpdateShooterPosition(targetAngle);
|
||||||
@ -119,9 +121,12 @@ void HHRobot::Handler(){
|
|||||||
//Collector button assignments
|
//Collector button assignments
|
||||||
if(controlSystem->GetJoystickButton(1,COLLECTOR_INTAKE)) {
|
if(controlSystem->GetJoystickButton(1,COLLECTOR_INTAKE)) {
|
||||||
collector->CollectBall();
|
collector->CollectBall();
|
||||||
|
collectorTable->PutNumber("Current Collector Speed",1);
|
||||||
}else if(controlSystem->GetJoystickButton(1,COLLECTOR_OUTTAKE)) {
|
}else if(controlSystem->GetJoystickButton(1,COLLECTOR_OUTTAKE)) {
|
||||||
|
collectorTable->PutNumber("Current Collector Speed",-1);
|
||||||
collector->ReleaseBall();
|
collector->ReleaseBall();
|
||||||
}else{
|
}else{
|
||||||
|
collectorTable->PutNumber("Current Collector Speed",0);
|
||||||
collector->CollectorStop();
|
collector->CollectorStop();
|
||||||
}
|
}
|
||||||
if(controlSystem->GetJoystickButton(1,COLLECTOR_EXTEND)){
|
if(controlSystem->GetJoystickButton(1,COLLECTOR_EXTEND)){
|
||||||
@ -132,20 +137,17 @@ void HHRobot::Handler(){
|
|||||||
}
|
}
|
||||||
if(controlSystem->GetJoystickButton(2,SHOOTER_ANGLE_ONE)){
|
if(controlSystem->GetJoystickButton(2,SHOOTER_ANGLE_ONE)){
|
||||||
targetAngle=100;
|
targetAngle=100;
|
||||||
shooterTable->PutNumber("Target Shooter Angle",targetAngle);
|
|
||||||
}
|
}
|
||||||
if(controlSystem->GetJoystickButton(2,SHOOTER_ANGLE_TWO)){
|
if(controlSystem->GetJoystickButton(2,SHOOTER_ANGLE_TWO)){
|
||||||
targetAngle=120;
|
targetAngle=120;
|
||||||
shooterTable->PutNumber("Target Shooter Angle",targetAngle);
|
|
||||||
}
|
}
|
||||||
if(controlSystem->GetJoystickButton(2,SHOOTER_ANGLE_THREE)){
|
if(controlSystem->GetJoystickButton(2,SHOOTER_ANGLE_THREE)){
|
||||||
targetAngle=90;
|
targetAngle=90;
|
||||||
shooterTable->PutNumber("Target Shooter Angle",targetAngle);
|
|
||||||
}
|
}
|
||||||
if(controlSystem->GetJoystickButton(2,SHOOTER_ANGLE_FOUR)){
|
if(controlSystem->GetJoystickButton(2,SHOOTER_ANGLE_FOUR)){
|
||||||
targetAngle=130;
|
targetAngle=130;
|
||||||
shooterTable->PutNumber("Target Shooter Angle",targetAngle);
|
|
||||||
}
|
}
|
||||||
|
shooterTable->PutNumber("Target Shooter Angle",targetAngle);
|
||||||
//TODO: Fix whatever this is supposed to do
|
//TODO: Fix whatever this is supposed to do
|
||||||
//if(controlSystem->rightJoystickValues[DISABLE_COMPRESSOR]){
|
//if(controlSystem->rightJoystickValues[DISABLE_COMPRESSOR]){
|
||||||
if(false){
|
if(false){
|
||||||
@ -159,8 +161,7 @@ void HHRobot::Handler(){
|
|||||||
targetAngle=100;
|
targetAngle=100;
|
||||||
if(sonar->GetInches("FRONTLEFT")>=45){
|
if(sonar->GetInches("FRONTLEFT")>=45){
|
||||||
DriveRobot(0,-.5);
|
DriveRobot(0,-.5);
|
||||||
}
|
} else{
|
||||||
else{
|
|
||||||
DriveRobot(0,0);
|
DriveRobot(0,0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@ class HHRobot{
|
|||||||
Talon *right1, *right2, *right3, *left1, *left2, *left3;
|
Talon *right1, *right2, *right3, *left1, *left2, *left3;
|
||||||
Joystick *rightStick, *leftStick;
|
Joystick *rightStick, *leftStick;
|
||||||
JoystickController *controlSystem;
|
JoystickController *controlSystem;
|
||||||
NetworkTable *driveTable, *shooterTable;
|
NetworkTable *driveTable, *shooterTable, *collectorTable;
|
||||||
HHShooter *shooter;
|
HHShooter *shooter;
|
||||||
HHCollector *collector;
|
HHCollector *collector;
|
||||||
HHCompressor *compressorSystem;
|
HHCompressor *compressorSystem;
|
||||||
|
@ -11,11 +11,11 @@ void HHShooter::StartShootingSequence(float throttle){
|
|||||||
//Changes the enum to tell the shooter to be firing
|
//Changes the enum to tell the shooter to be firing
|
||||||
e_ShooterState=FIRING;
|
e_ShooterState=FIRING;
|
||||||
// Convert the throttle input to a pwm value
|
// Convert the throttle input to a pwm value
|
||||||
shootingPower=throttle * 127.0f + 128;
|
shootingPower=throttle;
|
||||||
}
|
}
|
||||||
//First step in shooting process
|
//First step in shooting process
|
||||||
bool HHShooter::ShootForAngle(float power, float desiredAngle){
|
bool HHShooter::ShootForAngle(float power, float desiredAngle){
|
||||||
if(GetAngle() <= desiredAngle && power >= 15){
|
if(GetAngle() <= desiredAngle){
|
||||||
ShootRaw(power);
|
ShootRaw(power);
|
||||||
e_ShooterState=FIRING;
|
e_ShooterState=FIRING;
|
||||||
return true;
|
return true;
|
||||||
@ -49,7 +49,7 @@ void HHShooter::ShootRaw(float power){
|
|||||||
shooterRight2->SetRaw(int(FloatToPWM(-power)));
|
shooterRight2->SetRaw(int(FloatToPWM(-power)));
|
||||||
}
|
}
|
||||||
//Should be run in a loop
|
//Should be run in a loop
|
||||||
void HHShooter::UpdateShooterPosition(int angle){
|
void HHShooter::UpdateShooterPosition(double angle){
|
||||||
if(e_ShooterState == IDLE_PRESHOT){
|
if(e_ShooterState == IDLE_PRESHOT){
|
||||||
isShooting=false;
|
isShooting=false;
|
||||||
StopShooter();
|
StopShooter();
|
||||||
@ -58,7 +58,7 @@ void HHShooter::UpdateShooterPosition(int angle){
|
|||||||
isShooting=true;
|
isShooting=true;
|
||||||
if (ShootForAngle(shootingPower,angle)){
|
if (ShootForAngle(shootingPower,angle)){
|
||||||
printf("Shooting!\n");
|
printf("Shooting!\n");
|
||||||
printf("Shooting at power %f\n",shooterRight1->GetRaw());
|
printf("Shooting at power %d\n",shooterRight1->GetRaw());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
printf("Done shooting!\n");
|
printf("Done shooting!\n");
|
||||||
|
@ -19,7 +19,7 @@ class HHShooter{
|
|||||||
void ShootRaw(float);
|
void ShootRaw(float);
|
||||||
void Lower(float);
|
void Lower(float);
|
||||||
void StopShooter();
|
void StopShooter();
|
||||||
void UpdateShooterPosition(int);
|
void UpdateShooterPosition(double);
|
||||||
float FloatToPWM(float input);
|
float FloatToPWM(float input);
|
||||||
float GetAngle();
|
float GetAngle();
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user