Merge branch 'master' of code.dublinschool.org:repos/FRC/FRC2016
This commit is contained in:
commit
a42226c489
@ -11,10 +11,15 @@
|
|||||||
#define RAMP_LOWER 3 // Button 4 to lower ramp.
|
#define RAMP_LOWER 3 // Button 4 to lower ramp.
|
||||||
#define UNJAM 11
|
#define UNJAM 11
|
||||||
|
|
||||||
#define DEADZONE_RADIUS 0.01 // Deadzone Radius prevents tiny twitches in the joystick's value from
|
#define DEADZONE_RADIUS 0.05 // Deadzone Radius prevents tiny twitches in the joystick's value from
|
||||||
// affecting the robot. Use this for cleaning up drive train and shooter.
|
// affecting the robot. Use this for cleaning up drive train and shooter.
|
||||||
// Also used for detecting changes in an axis' value.
|
// Also used for detecting changes in an axis' value.
|
||||||
|
|
||||||
|
#define TURN_FACTOR 1.5 // Left(x,y) = y*(1 + TF*x) : x < 0
|
||||||
|
// = y : x >= 0
|
||||||
|
// Right(x,y) = y : x < 0
|
||||||
|
// = y*(1 - TF*x) : x >= 0
|
||||||
|
|
||||||
#endif // BUTTON_LAYOUT
|
#endif // BUTTON_LAYOUT
|
||||||
|
|
||||||
class Robot: public IterativeRobot
|
class Robot: public IterativeRobot
|
||||||
@ -51,6 +56,7 @@ private:
|
|||||||
bool shooting;
|
bool shooting;
|
||||||
bool unjamming;
|
bool unjamming;
|
||||||
bool arming;
|
bool arming;
|
||||||
|
bool arcade;
|
||||||
float shooter_power;
|
float shooter_power;
|
||||||
|
|
||||||
LiveWindow *lw = LiveWindow::GetInstance();
|
LiveWindow *lw = LiveWindow::GetInstance();
|
||||||
@ -77,6 +83,7 @@ private:
|
|||||||
unjamming = false;
|
unjamming = false;
|
||||||
arming = false;
|
arming = false;
|
||||||
shooter_power = 0;
|
shooter_power = 0;
|
||||||
|
arcade = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -118,7 +125,31 @@ private:
|
|||||||
std::cout << "arm encoder position: " << arms.GetEncPosition() << std::endl;
|
std::cout << "arm encoder position: " << arms.GetEncPosition() << std::endl;
|
||||||
std::cout << "arm encoder velocity: " << arms.GetEncVel() << std::endl;
|
std::cout << "arm encoder velocity: " << arms.GetEncVel() << std::endl;
|
||||||
drive.ArcadeDrive(-driver_stick.GetY(), -driver_stick.GetX()*0.75);
|
drive.ArcadeDrive(-driver_stick.GetY(), -driver_stick.GetX()*0.75);
|
||||||
|
if(driver_stick.GetRawButton(7))
|
||||||
|
{
|
||||||
|
arcade = true;
|
||||||
|
}
|
||||||
|
if(driver_stick.GetRawButton(8))
|
||||||
|
{
|
||||||
|
arcade = false;
|
||||||
|
}
|
||||||
|
if (arcade)
|
||||||
|
{
|
||||||
|
drive.ArcadeDrive(driver_stick);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (driver_stick.GetRawButton(THUMB))
|
||||||
|
{
|
||||||
|
float left = driver_stick.GetTwist();
|
||||||
|
float right = -driver_stick.GetTwist();
|
||||||
|
drive.TankDrive(left, right);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
UpdateDrive();
|
||||||
|
}
|
||||||
|
}
|
||||||
//bool rampDoing = false;
|
//bool rampDoing = false;
|
||||||
// This is shit code for testing. Replace it with real code.
|
// This is shit code for testing. Replace it with real code.
|
||||||
if(!ramping && operator_stick.GetRawButton(RAMP_RAISE))
|
if(!ramping && operator_stick.GetRawButton(RAMP_RAISE))
|
||||||
@ -189,21 +220,21 @@ private:
|
|||||||
* This is important because the TeleopPeriodic method executes something like once every 10ms.
|
* This is important because the TeleopPeriodic method executes something like once every 10ms.
|
||||||
* Thus, this if-else if pair make the button a toggle.
|
* Thus, this if-else if pair make the button a toggle.
|
||||||
*/
|
*/
|
||||||
if(driver_stick.GetRawButton(THUMB) && !inverting)
|
if(driver_stick.GetRawButton(TRIGGER) && !inverting)
|
||||||
{
|
{
|
||||||
std::cout << "Inverting Drive Train.";
|
std::cout << "Inverting Drive Train.";
|
||||||
left_drive.SetInverted(!left_drive.GetInverted());
|
left_drive.SetInverted(!left_drive.GetInverted());
|
||||||
right_drive.SetInverted(!right_drive.GetInverted());
|
right_drive.SetInverted(!right_drive.GetInverted());
|
||||||
inverting = true;
|
inverting = true;
|
||||||
}
|
}
|
||||||
else if(!driver_stick.GetRawButton(THUMB))
|
else if(!driver_stick.GetRawButton(TRIGGER))
|
||||||
{
|
{
|
||||||
inverting = false;
|
inverting = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Unlike the previous actions, this method does need to be called every itteration of
|
* Unlike the previous actions, this method does need to be called every iteration of
|
||||||
* TeleopPeriodic. This is because the logic running this operation needs to be checked
|
* TeleopPeriodic. This is because the logic running this operation needs to be checked
|
||||||
* Every time the method is called. This cannot be a loop in the Shoot method because
|
* Every time the method is called. This cannot be a loop in the Shoot method because
|
||||||
* that would lock the robot every time the trigger is hit.
|
* that would lock the robot every time the trigger is hit.
|
||||||
@ -257,6 +288,45 @@ private:
|
|||||||
{
|
{
|
||||||
lw->Run();
|
lw->Run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SimpleDrive()
|
||||||
|
{
|
||||||
|
float x = -driver_stick.GetX();
|
||||||
|
float y = -driver_stick.GetY();
|
||||||
|
float left = 0;
|
||||||
|
float right = 0;
|
||||||
|
|
||||||
|
if (x > 0)
|
||||||
|
{
|
||||||
|
right = y;
|
||||||
|
left = (1- x*TURN_FACTOR)*y ;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
left = y;
|
||||||
|
right = (1+x*TURN_FACTOR)*y;
|
||||||
|
}
|
||||||
|
|
||||||
|
drive.TankDrive(left, right);
|
||||||
|
}
|
||||||
|
|
||||||
|
void UpdateDrive()
|
||||||
|
{
|
||||||
|
float x = -driver_stick.GetX();
|
||||||
|
float y = -driver_stick.GetY();
|
||||||
|
if (x > 0)
|
||||||
|
{
|
||||||
|
float right = y * SaneThrottle(driver_stick.GetThrottle());
|
||||||
|
float left = (1-x)*y * SaneThrottle(driver_stick.GetThrottle());
|
||||||
|
drive.TankDrive(left, right);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
float left = y * SaneThrottle(driver_stick.GetThrottle());
|
||||||
|
float right = (1+x)*y * SaneThrottle(driver_stick.GetThrottle());
|
||||||
|
drive.TankDrive(left, right);
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
START_ROBOT_CLASS(Robot)
|
START_ROBOT_CLASS(Robot)
|
||||||
|
Reference in New Issue
Block a user