DeepSpace  2019
ClimbManager.cpp
Go to the documentation of this file.
2 #include "Robot.h"
3 #include <iostream>
4 #include <frc/commands/Scheduler.h>
5 
7 
10  this->CurrentClimbState = this->ClimbState::kInactive;
11 }
12 
13 // Called just before this Command runs the first time
15 
16 // Called repeatedly when this Command is scheduled to run
18 
19  // If operator is holding left on D-pad and hits the left trigger
20  if ( (this->pJoyOp->GetPOV() == 270) && (this->pJoyOp->GetStickButtonPressed(GenericHID::kRightHand)) ) {
21 
22  // If we're already running Auto climb
24 
25  // Cancel the auto climb
27  Log("Auto climb is being cancled");
28  UpdateRumble();
29  } else {
30 
31  // Otherwise, Start auto climb command
33  Log("Auto climb starting");
34  UpdateRumble();
35  }
36  }
37  // If operator is holding right on D-pad and hits the left trigger
38  else if ( (this->pJoyOp->GetPOV() == 90) && (this->pJoyOp->GetStickButtonPressed(GenericHID::kRightHand)) ) {
39 
40  // If we're already in manual climb mode
42 
43  // Stop manual climb
45  Log("Manual climb is being cancled");
46  UpdateRumble();
47  } else {
48 
49  // Otherwise, Start manual climb commands
50  this->CurrentClimbState = this->ClimbState::kActive;
51  Log("Manual climb starting");
52  UpdateRumble();
53  }
54  }
55 
56 }
57 
58 // Make this return true when this Command no longer needs to run execute()
60 
61 // Called once after isFinished returns true
63 
64  // Good measure
65  ClimbManager::CurrentClimbState = ClimbManager::ClimbState::kInactive ;
66 }
67 
68 // Called when another command which requires one or more of the same
69 // subsystems is scheduled to run
71 
72  // Good measure
73  ClimbManager::CurrentClimbState = ClimbManager::ClimbState::kInactive ;
74 }
75 
77 
78  // Reset rumble, since we know it's changing
79  this->pJoyOp->SetRumble(frc::GenericHID::RumbleType::kLeftRumble, 0.0);
80  this->pJoyOp->SetRumble(frc::GenericHID::RumbleType::kRightRumble, 0.0);
81 
82  // Rumble depending on which mode we're in
85  this->pJoyOp->SetRumble(frc::GenericHID::RumbleType::kLeftRumble, 0.5);
86  break;
88  this->pJoyOp->SetRumble(frc::GenericHID::RumbleType::kRightRumble, 0.5);
89  break;
90  default:
91  break;
92  }
93 }
void Interrupted() override
Runs once if the command is forced to stop.
frc::XboxController * GetJoystickOperator(void)
Definition: OI.cpp:14
void Log(std::string message)
Main robot class that is called by wpilib.
Definition: logging.cpp:9
bool IsFinished() override
void End() override
Runs once when IsFinished() returns true.
void UpdateRumble(void)
Updates whether the controller should be rumbleing or not.
ClimbManager()
Class constructor.
Definition: ClimbManager.cpp:8
frc::XboxController * pJoyOp
Definition: ClimbManager.h:23
static OI * m_oi
Pointer for the Operator Interface (OI)
Definition: Robot.h:68
void Execute() override
Called in a loop during Teleop.
static ClimbState CurrentClimbState
Definition: ClimbManager.h:15
void Initialize() override
Runs once on initalization.