Skip to content

Commit

Permalink
Added commented code for pot angle in case we ever use it
Browse files Browse the repository at this point in the history
  • Loading branch information
anidev committed Apr 23, 2014
1 parent 9ce5bab commit 9cb4e7e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 12 deletions.
32 changes: 20 additions & 12 deletions Shooter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ Shooter::Shooter(main_robot* r,uint8_t axisCan,
wormGear = new CANJaguar(wormCan);
puncher = new DoubleSolenoid(punchMod,punchFChan,punchRChan);
bobTheAccelerometer = new ADXL345_I2C_612(bobMod);
// bobThePot = new AnalogChannel(1,5);
isPickingUp = false;
shooterJoy = robot -> gunnerJoy;
shooterJoy -> addJoyFunctions(&buttonHelper,(void*)this,CLAMP);
Expand Down Expand Up @@ -223,6 +224,24 @@ void Shooter::buttonHelper(void* objPtr, uint32_t button)
}
}

double Shooter::getAngle() {
double bobX = bobTheAccelerometer->GetAcceleration(ADXL345_I2C_612::kAxis_X);
double bobY = bobTheAccelerometer->GetAcceleration(ADXL345_I2C_612::kAxis_Y);
double bobZ = bobTheAccelerometer->GetAcceleration(ADXL345_I2C_612::kAxis_Z);
accelWorking = !(doubleEqual(bobX,0.0) && doubleEqual(bobY,0.0) && doubleEqual(bobZ,0.0));
if(!accelWorking)
{
isPitchingUp = false;
isPitchingDown = false;
}
double newPitch = (atan2(bobX, sqrt(bobY*bobY + bobZ*bobZ))*180.0)/PI;
// if(fabs(newPitch-currentPitch) < 10)
currentPitch = newPitch;
/* double volts = bobThePot->GetVoltage();
currentPitch = bobThePot; // TODO get pot conversion */
return currentPitch;
}

/*
*
* The following code is a shortcut of sorts for Ben so that he can press one button to do a bunch of stuff
Expand All @@ -246,18 +265,7 @@ void Shooter::setPickupHelper(void* instName, uint32_t button) {

void Shooter::update()
{
double bobX = bobTheAccelerometer->GetAcceleration(ADXL345_I2C_612::kAxis_X);
double bobY = bobTheAccelerometer->GetAcceleration(ADXL345_I2C_612::kAxis_Y);
double bobZ = bobTheAccelerometer->GetAcceleration(ADXL345_I2C_612::kAxis_Z);
accelWorking = !(doubleEqual(bobX,0.0) && doubleEqual(bobY,0.0) && doubleEqual(bobZ,0.0));
if(!accelWorking)
{
isPitchingUp = false;
isPitchingDown = false;
}
double newPitch = (atan2(bobX, sqrt(bobY*bobY + bobZ*bobZ))*180.0)/PI;
// if(fabs(newPitch-currentPitch) < 10)
currentPitch = newPitch;
getAngle();

static int output = 0;
if(output%20 == 0)
Expand Down
3 changes: 3 additions & 0 deletions Shooter.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <CANJaguar.h>
#include <Talon.h>
#include <DoubleSolenoid.h>
#include <AnalogChannel.h>
#include "ADXL345_I2C_612.h"
#include <cmath>
#include "controls.h"
Expand Down Expand Up @@ -43,6 +44,7 @@ class Shooter
void punch();
void smartFire();
bool doubleEqual(double a,double b);
double getAngle();

void setPickup();
static void setPickupHelper(void*, uint32_t);
Expand All @@ -54,6 +56,7 @@ class Shooter
CANJaguar* wormGear;
DoubleSolenoid* puncher;
ADXL345_I2C_612* bobTheAccelerometer;
// AnalogChannel* bobThePot;
main_robot* robot;

bool isPickingUp;
Expand Down

0 comments on commit 9cb4e7e

Please sign in to comment.