mirror of
https://github.com/team2059/Dent
synced 2025-01-17 22:19:21 -05:00
Merge branch 'tag/v2.1'
This commit is contained in:
commit
03bcdd5a12
@ -23,9 +23,9 @@ class AutoDrive: public Command{
|
||||
*
|
||||
* @param duration Timeout in seconds
|
||||
* @param xtmp Joystick x value (default: 0.0)
|
||||
* @param ytmp Joystick y value (default: 0.75)
|
||||
* @param ytmp Joystick y value (default: -0.75)
|
||||
* @param ztmp Joystick z value (default: 0.0)
|
||||
* @param useGyro Use the gyro when driving
|
||||
* @param useGyro Use the gyro when driving (default: true)
|
||||
*/
|
||||
AutoDrive(double duration, double xtmp = 0.0, double ytmp = -0.75, double ztmp = 0.0, bool useGyro = true);
|
||||
/**
|
||||
|
@ -71,7 +71,7 @@ Autonomous::Autonomous(int seq){
|
||||
//TODO: Implement this
|
||||
break;
|
||||
case 7:
|
||||
// Same as auto 4 with (Three|Two) totes checked, collect bin, drive to Auto Zone (TM), release totes
|
||||
// Same as auto 4, then collect bin, drive to Auto Zone (TM), release totes
|
||||
//TODO: Implement this
|
||||
break;
|
||||
case 8:
|
||||
@ -82,7 +82,7 @@ Autonomous::Autonomous(int seq){
|
||||
break;
|
||||
case 9:
|
||||
//Use rear elevator to move bin
|
||||
AddSequential(new BinLower(.1));
|
||||
AddSequential(new BinLower(0.1));
|
||||
AddSequential(new AutoDrive(SmartDashboard::GetNumber("Auto Zone Distance"), 0.0, 0.75));
|
||||
AddSequential(new Turn(2.1));
|
||||
break;
|
||||
|
@ -19,13 +19,25 @@
|
||||
* Sequence 2: Collects a tote, turns, then drives to the auto zone
|
||||
*
|
||||
* Sequence 3: Collects two or three totes then drives to auto zone
|
||||
*
|
||||
* Sequence 4: Collect one, two, or three totes, drive to Auto Zone, release totes
|
||||
*
|
||||
* Sequence 5: Same as auto 4, but navigate around bins (not implemented)
|
||||
*
|
||||
* Sequence 6: Collect 1 bin and 1 tote (not implemented)
|
||||
*
|
||||
* Sequence 7: Same as auto 4, then collect bin, drive to auto zone, release totes (not implemented)
|
||||
*
|
||||
* Sequence 8: Use rear elevator to move tote
|
||||
*
|
||||
* Sequence 9: Use rear elevator to move bin
|
||||
*/
|
||||
class Autonomous: public CommandGroup{
|
||||
public:
|
||||
/**
|
||||
* @brief Constructs Autonomous
|
||||
*
|
||||
* @param seq The sequence to run
|
||||
* @param seq The sequence to run (default: 0)
|
||||
*/
|
||||
Autonomous(int seq = 0);
|
||||
};
|
||||
|
@ -12,7 +12,6 @@
|
||||
* Turns the robot until a timeout is reached
|
||||
*/
|
||||
class Turn: public Command{
|
||||
private:
|
||||
public:
|
||||
/**
|
||||
* @brief Constructs Turn
|
||||
|
@ -5,7 +5,7 @@
|
||||
#include "WPILib.h"
|
||||
|
||||
/**
|
||||
* @brief Closes BinElevatorArms (NOT USED)
|
||||
* @brief Closes BinElevatorArms (unused)
|
||||
*
|
||||
* Sets the solenoid to close the arms of the BinElevator
|
||||
*/
|
||||
@ -14,7 +14,7 @@ class BinCloseArms: public Command{
|
||||
/**
|
||||
* @brief Constructs BinCloseArms
|
||||
*
|
||||
* @param timeout The timeout
|
||||
* @param timeout Timeout in seconds (default: 0.5)
|
||||
*/
|
||||
BinCloseArms(double timeout = 0.5);
|
||||
/**
|
||||
@ -40,6 +40,5 @@ class BinCloseArms: public Command{
|
||||
*/
|
||||
void Interrupted();
|
||||
};
|
||||
|
||||
#endif
|
||||
// vim: ts=2:sw=2:et
|
||||
|
@ -8,12 +8,11 @@
|
||||
* @brief Lowers the bin elevator until a timeout is reached
|
||||
*/
|
||||
class BinLower: public Command{
|
||||
private:
|
||||
public:
|
||||
/**
|
||||
* @brief Constructs BinLower
|
||||
*
|
||||
* @param timeout The timeout
|
||||
* @param timeout Timeout in seconds
|
||||
*/
|
||||
BinLower(float timeout);
|
||||
/**
|
||||
|
@ -12,7 +12,7 @@ class BinOpenArms: public Command{
|
||||
/**
|
||||
* @brief Constructs BinOpenArms
|
||||
*
|
||||
* @param timeout The timeout
|
||||
* @param timeout Timeout in seconds
|
||||
*/
|
||||
BinOpenArms(double timeout);
|
||||
/**
|
||||
|
@ -14,7 +14,7 @@ class RollOut: public Command{
|
||||
/**
|
||||
* @brief Constructs RollOut
|
||||
*
|
||||
* @param timeout The timeout
|
||||
* @param timeout Timeout in seconds (default: 2.0)
|
||||
*/
|
||||
RollOut(double timeout = 2.0);
|
||||
/**
|
||||
|
@ -11,7 +11,7 @@
|
||||
*/
|
||||
class RollVar: public Command{
|
||||
private:
|
||||
double speed; //<! Speed control of the collector
|
||||
double speed; //<! Speed multiplier of the collector
|
||||
public:
|
||||
/**
|
||||
* @brief Constructs RollVar
|
||||
|
@ -3,7 +3,6 @@
|
||||
|
||||
#include "Commands/Command.h"
|
||||
#include "../../DentRobot.h"
|
||||
#include "../../DentRobot.h"
|
||||
#include "WPILib.h"
|
||||
|
||||
/**
|
||||
|
@ -11,6 +11,8 @@ class Lower: public Command{
|
||||
public:
|
||||
/**
|
||||
* @brief Constructs Lower
|
||||
*
|
||||
* @param timeout Timeout in seconds (default: 3.0)
|
||||
*/
|
||||
Lower(double timeout = 3.0);
|
||||
/**
|
||||
|
@ -11,6 +11,8 @@ class Raise: public Command{
|
||||
public:
|
||||
/**
|
||||
* @brief Constructs Raise
|
||||
*
|
||||
* @param timeout Timeout in seconds (default: 3.5)
|
||||
*/
|
||||
Raise(double timeout = 3.5);
|
||||
/**
|
||||
|
@ -72,7 +72,6 @@ void DentRobot::TeleopInit(){
|
||||
}
|
||||
void DentRobot::TeleopPeriodic(){
|
||||
Scheduler::GetInstance()->Run();
|
||||
//TODO: Calibrate 1.0 to the height we want the elevator to automatically raise
|
||||
if(elevator->GetUseEncoder()&&elevator->GetHeight() <= -1.0){
|
||||
// Raise the elevator if it dips below elevatorTop
|
||||
oi->raise->Start();
|
||||
|
97
OI.cpp
97
OI.cpp
@ -12,91 +12,42 @@
|
||||
#include "Commands/Autonomous/ReleaseTote.h"
|
||||
OI::OI(){
|
||||
// Joysticks
|
||||
leftController=new Joystick(0);
|
||||
rightController=new Joystick(1);
|
||||
leftStick = new Joystick(0);
|
||||
rightStick = new Joystick(1);
|
||||
// Collector
|
||||
JoystickButton *left10=new JoystickButton(leftController, 10);
|
||||
JoystickButton *left12=new JoystickButton(leftController, 12);
|
||||
JoystickButton *left9=new JoystickButton(leftController, 9);
|
||||
left10->WhileHeld(new RollIn(GetLeftThrottle()));
|
||||
left12->WhileHeld(new RollOut(2.0));
|
||||
JoystickButton *left1 = new JoystickButton(leftStick, 1);
|
||||
JoystickButton *left2 = new JoystickButton(leftStick, 2);
|
||||
JoystickButton *left7 = new JoystickButton(leftStick, 7);
|
||||
left1->WhileHeld(new RollIn(GetLeftThrottle()));
|
||||
left2->WhileHeld(new RollOut(2.0));
|
||||
// 0.8 is the multiplier, so they roll at 80% power
|
||||
left9->WhileHeld(new RollVar(0.8));
|
||||
// Elevator
|
||||
raise = new Raise(3.5);
|
||||
lower = new Lower(3.0);
|
||||
JoystickButton *right9=new JoystickButton(rghtController, 9);
|
||||
JoystickButton *right11=new JoystickButton(rghtController, 11);
|
||||
right9->WhenPressed(lower);
|
||||
right9->CancelWhenPressed(raise);
|
||||
right11->WhenPressed(raise);
|
||||
right11->CancelWhenPressed(lower);
|
||||
JoystickButton *right4 = new JoystickButton(rightStick, 4);
|
||||
JoystickButton *right6 = new JoystickButton(rightStick, 6);
|
||||
right4->WhenPressed(lower);
|
||||
right4->CancelWhenPressed(raise);
|
||||
right6->WhenPressed(raise);
|
||||
right6->CancelWhenPressed(lower);
|
||||
// BinElevator
|
||||
JoystickButton *right10=new JoystickButton(rghtController, 10);
|
||||
JoystickButton *right12=new JoystickButton(rghtController, 12);
|
||||
//JoystickButton *right7=new JoystickButton(rghtController, 7);
|
||||
//JoystickButton *right8=new JoystickButton(rghtController, 8);
|
||||
JoystickButton *right3 = new JoystickButton(rightStick, 3);
|
||||
JoystickButton *right5 = new JoystickButton(rightStick, 5);
|
||||
//JoystickButton *right7 = new JoystickButton(rightStick, 7);
|
||||
//JoystickButton *right8 = new JoystickButton(rightStick, 8);
|
||||
//right7->WhenPressed(new BinOpenArms());
|
||||
//right8->WhenPressed(new BinCloseArms());
|
||||
binRaise = new BinRaise(3.0);
|
||||
binLower = new BinLower(2.0);
|
||||
right10->WhileHeld(binLower);
|
||||
right10->CancelWhenPressed(binRaise);
|
||||
right12->WhileHeld(binRaise);
|
||||
right12->CancelWhenPressed(binLower);
|
||||
right3->WhileHeld(binLower);
|
||||
right3->CancelWhenPressed(binRaise);
|
||||
right5->WhileHeld(binRaise);
|
||||
right5->CancelWhenPressed(binLower);
|
||||
// Cancel
|
||||
JoystickButton *right16=new JoystickButton(rghtController, 16);
|
||||
right16->CancelWhenPressed(raise);
|
||||
right16->CancelWhenPressed(lower);
|
||||
}
|
||||
float OI::GetLeftAxis(std::string stick, std::string axis){
|
||||
if(stick=="left"){
|
||||
if(axis=="x"){
|
||||
return leftController->GetRawAxis(0);
|
||||
}else if(axis=="y"){
|
||||
return -leftController->GetRawAxis(1);
|
||||
}else if(axis=="trigger"){
|
||||
//TODO: Figure out what axis this is
|
||||
return leftController->GetRawAxis(4);
|
||||
return -4;
|
||||
}
|
||||
}else if(stick=="right"){
|
||||
if(axis=="x"){
|
||||
return leftController->GetRawAxis(2);
|
||||
}else if(axis=="y"){
|
||||
return -leftController->GetRawAxis(3);
|
||||
}else if(axis=="trigger"){
|
||||
//TODO: Figure out what axis this is
|
||||
return leftController->GetRawAxis(5);
|
||||
return -4;
|
||||
}
|
||||
}
|
||||
//TODO: Fix this placeholder for NULL
|
||||
return -5;
|
||||
}
|
||||
bool OI::GetLeftButton(std::string button){
|
||||
if(button=="a"){
|
||||
return leftA->Get();
|
||||
}else if(button=="b"){
|
||||
return leftB->Get();
|
||||
}else if(button=="x"){
|
||||
return leftX->Get();
|
||||
}else if(button=="y"){
|
||||
return leftY->Get();
|
||||
}else if(button=="lb"){
|
||||
return leftLB->Get();
|
||||
}else if(button=="rb"){
|
||||
return leftRB->Get();
|
||||
}else if(button=="back"){
|
||||
return leftBack->Get();
|
||||
}else if(button=="start"){
|
||||
return leftStart->Get();
|
||||
}else if(button=="lpress"){
|
||||
return leftLPress->Get();
|
||||
}else if(button=="rpress"){
|
||||
return leftRPress->Get();
|
||||
}
|
||||
return false;
|
||||
JoystickButton *right12 = new JoystickButton(rightStick, 12);
|
||||
right12->CancelWhenPressed(raise);
|
||||
right12->CancelWhenPressed(lower);
|
||||
}
|
||||
Joystick* OI::GetRightStick(){
|
||||
return rghtController;
|
||||
|
11
OI.h
11
OI.h
@ -9,16 +9,17 @@
|
||||
*/
|
||||
class OI{
|
||||
private:
|
||||
Joystick *leftController, *rightController;
|
||||
Joystick *leftStick, //<! Left joystick
|
||||
*rightStick; //<! Right joystick
|
||||
public:
|
||||
/**
|
||||
* @brief Constructs OI
|
||||
*/
|
||||
OI();
|
||||
Command *raise, //!< Raise command
|
||||
*lower, //!< Lower command
|
||||
*binLower, //!< BinLower command
|
||||
*binRaise; //!< BinRaise command
|
||||
Command *raise, //<! Raise command
|
||||
*lower, //<! Lower command
|
||||
*binLower, //<! BinLower command
|
||||
*binRaise; //<! BinRaise command
|
||||
/**
|
||||
* @brief Gets the value of a throttle on the left controller
|
||||
*
|
||||
|
@ -24,9 +24,7 @@ class BinElevator{
|
||||
/**
|
||||
* @brief Runs the bin elevator
|
||||
*
|
||||
* @param power The power to run the bin elevator
|
||||
*
|
||||
* Ranges from -1.0 to 1.0
|
||||
* @param power The power to run the bin elevator (-1.0 to 1.0)
|
||||
*/
|
||||
void Run(double power);
|
||||
/**
|
||||
|
@ -33,25 +33,25 @@ class Collector: public Subsystem{
|
||||
/**
|
||||
* @brief Moves the collectors
|
||||
*
|
||||
* @param power The speed to run the collectors
|
||||
* @param power The power to run the collectors
|
||||
*/
|
||||
void MoveRollers(double power);
|
||||
/**
|
||||
* @brief Moves the left roller
|
||||
*
|
||||
* @param power The speed to run the left roller
|
||||
* @param power The power to run the left roller
|
||||
*/
|
||||
void MoveLeftRoller(double power);
|
||||
/**
|
||||
* @brief Moves the right roller
|
||||
*
|
||||
* @param power The speed to run the right roller
|
||||
* @param power The power to run the right roller
|
||||
*/
|
||||
void MoveRightRoller(double power);
|
||||
/**
|
||||
* @brief Moves the bottom rollers
|
||||
*
|
||||
* @param power The speed to run the bottom rollers
|
||||
* @param power The power to run the bottom rollers
|
||||
*/
|
||||
void MoveBottomRollers(double power);
|
||||
/**
|
||||
|
@ -13,7 +13,6 @@ void Drivetrain::InitDefaultCommand(){
|
||||
SetDefaultCommand(new Drive());
|
||||
}
|
||||
void Drivetrain::DriveMecanum(double x, double y, double z, double sensitivity, bool driveStraight){
|
||||
//TODO: Find the correct value for kP
|
||||
double kP = SmartDashboard::GetNumber("Gyro kP");
|
||||
double correctX = -(sensitivity*(pow(x, 3))+(1-sensitivity)*x);
|
||||
double correctY = -(sensitivity*(pow(y, 3))+(1-sensitivity)*y);
|
||||
|
@ -39,7 +39,7 @@ class Drivetrain: public Subsystem{
|
||||
* @param y Joystick y value (-1.0 to 1.0)
|
||||
* @param z Joystick z value (-1.0 to 1.0)
|
||||
* @param sensitivity Sensitivity (0.0 to 1.0)
|
||||
* @param driveStraight Overrides z value to correct for motor lag
|
||||
* @param driveStraight Overrides z value to correct for motor lag (default: false)
|
||||
*/
|
||||
void DriveMecanum(double x, double y, double z, double sensitivity, bool driveStraight = false);
|
||||
/**
|
||||
|
@ -24,8 +24,6 @@
|
||||
* -# @ref Autonomous
|
||||
* -# @ref CollectTote
|
||||
* -# @ref ReleaseTote
|
||||
* -# @ref CheckDrive
|
||||
* -# @ref CheckRobot
|
||||
*
|
||||
* Note: Recycling containers are referred to bins throughout the project
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user