Merge branch 'master' into logging
This commit is contained in:
commit
9407b57429
@ -19,10 +19,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 0.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
|
||||||
|
|
||||||
#ifndef LOG
|
#ifndef LOG
|
||||||
@ -65,6 +70,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();
|
||||||
@ -105,6 +111,7 @@ private:
|
|||||||
unjamming = false;
|
unjamming = false;
|
||||||
arming = false;
|
arming = false;
|
||||||
shooter_power = 0;
|
shooter_power = 0;
|
||||||
|
arcade = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -152,7 +159,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))
|
||||||
@ -223,21 +254,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.
|
||||||
@ -373,6 +404,45 @@ private:
|
|||||||
LOG("\t" << DriverStation::GetInstance().IsSysBrownedOut());
|
LOG("\t" << DriverStation::GetInstance().IsSysBrownedOut());
|
||||||
LOG(std::endl);
|
LOG(std::endl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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