-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDrive.cpp
65 lines (59 loc) · 1.72 KB
/
Drive.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include "Drive.h"
Drive::Drive(Controllers* driverInput, int leftMotor, int rightMotor, int leftSolenoidNum, int rightSolenoidNum)
{
this->driverInput = driverInput;
leftDrive = new Victor(leftMotor);
rightDrive = new Victor(rightMotor);
myRobot = new RobotDrive(leftDrive, rightDrive);
myRobot->SetExpiration(0.1);
myRobot->SetSafetyEnabled(false);
this->leftSolenoid = new Solenoid(2);//leftSolenoidNum);
this->rightSolenoid = new Solenoid(4);//rightSolenoidNum);
}
void Drive::SetDriveCommand(float leftDriveCmd){
LeftDriveCommand = leftDriveCmd;
RightDriveCommand = rightDriveCmd;
}
void Drive::SetHighGear(){
SmartDashboard::init();
if (HighGear) {
leftSolenoid->Set(false);
rightSolenoid->Set(true);
SmartDashboard::PutString("Gear", "High Gear");
}
else {
leftSolenoid->Set(true);
rightSolenoid->Set(false);
SmartDashboard::PutString("Gear", "Low Gear");
}
}
void Drive::SetHighGear(bool high){
SmartDashboard::init();
if (high) {
leftSolenoid->Set(false);
rightSolenoid->Set(true);
SmartDashboard::PutString("Gear", "High Gear");
}
else {
leftSolenoid->Set(true);
rightSolenoid->Set(false);
SmartDashboard::PutString("Gear", "Low Gear");
}
}
void Drive::GetInputs(){
HighGear = driverInput->IsHighGearButtonPressed();
BackwardButton = driverInput ->IsBackwardDirectionPressed();
//LeftDriveMotorOutput = driverInput->GetLeftDriveInput();
//RightDriveMotorOutput = driverInput->GetRightDriveInput();
}
void Drive::ExecStep()
{
this->SetHighGear();
this->SetDriveCommand(LeftDriveMotorOutput);
this->SetOutputs();
}
void Drive::SetOutputs(){
myRobot->ArcadeDrive(driverInput->GetDriverJoystick());
//myRobot->ArcadeDrive(LeftDriveMotorOutput, RightDriveMotorOutput);
Drive::SetHighGear();
}