Skip to content

Commit

Permalink
Merge pull request #40 from 2202Programming/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
Tom Lazar committed Mar 7, 2016
2 parents 5b0be16 + 2be6620 commit 2e81a77
Show file tree
Hide file tree
Showing 9 changed files with 168 additions and 54 deletions.
2 changes: 1 addition & 1 deletion .settings/language.settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
<provider class="org.eclipse.cdt.internal.build.crossgcc.CrossGCCBuiltinSpecsDetector" console="false" env-hash="-869912976868427516" id="org.eclipse.cdt.build.crossgcc.CrossGCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT Cross GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<provider class="org.eclipse.cdt.internal.build.crossgcc.CrossGCCBuiltinSpecsDetector" console="false" env-hash="1917928739181448850" id="org.eclipse.cdt.build.crossgcc.CrossGCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT Cross GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<language-scope id="org.eclipse.cdt.core.gcc"/>
<language-scope id="org.eclipse.cdt.core.g++"/>
</provider>
Expand Down
Binary file modified Debug/src/IControl.o
Binary file not shown.
86 changes: 42 additions & 44 deletions src/Components/RelayController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,54 +14,38 @@ const int RELAY_BLUE = 0;

RelayController::RelayController() {
// TODO Auto-generated constructor stub
Red = new Relay(RelayIO::RELAY_RED);
Blue = new Relay(RelayIO::RELAY_BLUE);
Red = new Relay(RelayIO::RELAY_RED, Relay::kForwardOnly);
Blue = new Relay(RelayIO::RELAY_BLUE, Relay::kForwardOnly);
}

RelayController::~RelayController() {
// TODO Auto-generated destructor stub
delete Red;
delete Blue;
Red = 0;
Blue = 0;
}

void RelayController::ToggleColor() {
switch (currnet) {
case RelayColor::neither:
break; //TODO
case RelayColor::blue:
break; //TODO
case RelayColor::red:
break; // TODO
}
}

void RelayController::setColor(RelayColor color) {
if(currnet != color){
switch (color) {
case RelayColor::neither:
void RelayController::TeleopInit()
{
DriverStation::Alliance alligent = DriverStation::GetInstance().GetAlliance();
switch(alligent){
case DriverStation::kBlue:
Red->Set(Relay::kOff);
Blue->Set(Relay::kOff);
Blue->Set(Relay::kOn);
break;
case RelayColor::red:
case DriverStation::kRed:
Red->Set(Relay::kOn);
Blue->Set(Relay::kOff);
break;
case RelayColor::blue:
case DriverStation::kInvalid:
Red->Set(Relay::kOff);
Blue->Set(Relay::kOn);
break;
}
currnet = color;
}
}

void RelayController::relayBlink(int speed) {

}

void RelayController::burnUp() {
void RelayController::AutonomousInit()
{
DriverStation::Alliance alligent = DriverStation::GetInstance().GetAlliance();
switch(alligent){
case DriverStation::kBlue:
Expand All @@ -79,28 +63,42 @@ void RelayController::burnUp() {
}
}

void RelayController::stopBlink() {
burnUp();
}

void RelayController::TeleopInit()
{
burnUp();
}

void RelayController::AutonomousInit()
{
burnUp();
}

void RelayController::RobotInit()
{
burnUp();
DriverStation::Alliance alligent = DriverStation::GetInstance().GetAlliance();
switch(alligent){
case DriverStation::kBlue:
Red->Set(Relay::kOff);
Blue->Set(Relay::kOn);
break;
case DriverStation::kRed:
Red->Set(Relay::kOn);
Blue->Set(Relay::kOff);
break;
case DriverStation::kInvalid:
Red->Set(Relay::kOff);
Blue->Set(Relay::kOn);
break;
}
}

void RelayController::DisabledInit()
{
burnUp();
DriverStation::Alliance alligent = DriverStation::GetInstance().GetAlliance();
switch(alligent){
case DriverStation::kBlue:
Red->Set(Relay::kOff);
Blue->Set(Relay::kOn);
break;
case DriverStation::kRed:
Red->Set(Relay::kOn);
Blue->Set(Relay::kOff);
break;
case DriverStation::kInvalid:
Red->Set(Relay::kOff);
Blue->Set(Relay::kOn);
break;
}
}

/*
Expand Down
4 changes: 4 additions & 0 deletions src/Robot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,10 @@ class Robot: public IterativeRobot {
test = test->parent;
}


// Turn???
NavxSensorControl::AutonomousPeriodic(turn);

}

void TeleopInit() {
Expand Down
19 changes: 17 additions & 2 deletions src/SensorControl/NavxSensorControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/

#include <SensorControl/NavxSensorControl.h>
#include <math.h>

NavxSensorControl::NavxSensorControl(IXbox *xboxInstance,
IProfile *profileInstance, IVision *visionInstance) {
Expand Down Expand Up @@ -79,7 +80,8 @@ void NavxSensorControl::TargetingStateMachine() {
float motorSpeed = 0;
switch (targetState) {
case TargetingState::waitForButtonPress:
if (xbox->getLeftTriggerPressed()) {
if ((xbox->getLeftTriggerPressed() && !comp)
|| (xbox->getLeftBumperPressed() && comp)) {
commandDriveState = DriveSystemState::stopped;
targetState = TargetingState::waitForStopped;
}
Expand All @@ -93,6 +95,9 @@ void NavxSensorControl::TargetingStateMachine() {
}
break;
case TargetingState::waitForPicResult:
if (xbox->getStartPressed()) {

}
if (vision->getDoneAiming()) {

visionTargetAngle = vision->getDegreesToTurn();
Expand All @@ -108,7 +113,7 @@ void NavxSensorControl::TargetingStateMachine() {
}
break;
case TargetingState::driveToAngle:
if (fabs(turnController->GetError()) < 3) {
if (fabs(turnController->GetError()) < 1) {
if (t == NULL) {
t = new Timer();
t->Start();
Expand Down Expand Up @@ -159,16 +164,26 @@ void NavxSensorControl::TargetingStateMachine() {
}

void NavxSensorControl::PIDWrite(float output) {
bool positive=output>=0;
output=sqrt(fabs(output));//negative numbers don't have a real square root
if (!positive)
output*=-1;
turnSpeed = output;
}

void NavxSensorControl::RobotInit() {
SmartDashboard::PutNumber("P", 0);
SmartDashboard::PutNumber("I", 0);
SmartDashboard::PutNumber("D", 0);
}
void NavxSensorControl::TeleopInit() {
ahrs->ZeroYaw();
turnSpeed = 0;
targetState = TargetingState::waitForButtonPress;
currentDriveState = DriveSystemState::running;
commandDriveState = DriveSystemState::running;
t = NULL;

turnController->SetPID(0.055, 0.0004, 0.0);
left->Reset();
right->Reset();
Expand Down
2 changes: 2 additions & 0 deletions src/SensorControl/NavxSensorControl.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class NavxSensorControl: public ISensorControl, public PIDOutput {
MotorCommand *UpdateMotorSpeeds(float leftMotorSpeed, float rightMotorSpeed);
DriveSystemState DriveSystemControlUpdate(DriveSystemState currentState, DriveSystemState requestedState);

void RobotInit();
void TeleopInit();
void TeleopPeriodic();
void AutonomousInit();
Expand All @@ -72,6 +73,7 @@ class NavxSensorControl: public ISensorControl, public PIDOutput {
float turnSpeed;
int currentStep;

bool comp = true;
bool inAutonomous;
bool time;
bool autoTime;
Expand Down
108 changes: 101 additions & 7 deletions src/Shooter/Shooter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ void Shooter::TeleopInit() {
}

void Shooter::TeleopPeriodic() {
readXboxState();
readXboxComp();
updateMotor2();
setPnumatics();

Expand Down Expand Up @@ -181,7 +181,10 @@ void Shooter::TeleopPeriodic() {
}
}*/

intakeSpeed = SmartDashboard::GetNumber("Intake Speed Change", -0.7);
intakeSpeed = SmartDashboard::GetNumber("Intake Speed Change", 0.7);
if(intakeDirection){
intakeSpeed = -intakeSpeed;
}

switch (sState) {
case ready:
Expand Down Expand Up @@ -317,6 +320,97 @@ void Shooter::readXboxState() {
}
}

void Shooter::readXboxComp() {
if (xbox->getRightBumperPressed()) { //Up
angle = !angle;
}

if (xbox->getLeftTriggerPressed()) {
intakePos = !intakePos;
runIntake = !runIntake;
//TODO run motors for 2 sec after retract
}

if(xbox->getAPressed())
{
intakeDirection = !intakeDirection;
}

if (xbox->getBackPressed()) {
runIntake = !runIntake;
}

if(xbox->getYPressed())
{
//TODO Reverse Motors
}

switch (sState) {
case ready:
if (xbox->getRightTriggerPressed()) {
sState = windup;
}
break;
case windup:
runShoot = true;
if (xbox->getRightTriggerPressed()) {
sState = goShoot;
}
if (xbox->getBPressed()) {
sState = winddown;
}
break;
case goShoot:
runTrigger = true;

if (t == NULL) {
t = new Timer();
t->Start();
} else {
if (t->Get() > 1) {
time = true;
}
}

if (time) {
sState = winddown;
time = false;
delete t;
t = NULL;
}

break;
case winddown:
runShoot = false;
runTrigger = false;

if (t == NULL) {
t = new Timer();
t->Start();
} else {
if (t->Get() > 1) {
time = true;
}
}

if (time) {
sState = ready;
time = false;
delete t;
t = NULL;
}
break;
}

if (xbox->getXPressed()) {
if (shootPercentState < 4) {
shootPercentState++;
} else {
shootPercentState = 0;
}
}
}

void Shooter::setPnumatics() {

if (angle) {
Expand Down Expand Up @@ -349,11 +443,11 @@ void Shooter::updateMotor2() {
}

if (runIntake) {
/*if (intakeDirection) {
intakeSpeed = 1;
} else {
intakeSpeed = -1;
}*/
// if (intakeDirection) {
// intakeSpeed = ;
// } else {
// intakeSpeed = -1;
// }
} else {
intakeSpeed = 0.0;
}
Expand Down
1 change: 1 addition & 0 deletions src/Shooter/Shooter.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class Shooter: public IControl {
//Input from Xbox Controller
void readXbox();
void readXboxState();
void readXboxComp(); // Lukas and Aaron layout
void setPnumatics();
void updateMotor1(); // w/ encoders
void updateMotor2(); // w/o encoders
Expand Down
Binary file modified sysProps.xml
Binary file not shown.

0 comments on commit 2e81a77

Please # to comment.