-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTurretCode.cpp
More file actions
57 lines (46 loc) · 1.73 KB
/
TurretCode.cpp
File metadata and controls
57 lines (46 loc) · 1.73 KB
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
#include "Include4Turret.h"
using namespace frc;
using namespace nt;
frc::Joystick Pilot_Controller{0};
void Robot::TeleopPeriodic()
{
double y = Pilot_Controller.GetRawAxis(1);
double s = Pilot_Controller.GetRawAxis(4);
LeftFrontMotor.Set(ctre::phoenix::motorcontrol::ControlMode::PercentOutput, -y + s);
LeftBackMotor.Set(ctre::phoenix::motorcontrol::ControlMode::PercentOutput, -y + s);
RightFrontMotor.Set(ctre::phoenix::motorcontrol::ControlMode::PercentOutput, y + s);
RightBackMotor.Set(ctre::phoenix::motorcontrol::ControlMode::PercentOutput, y + s);
double tx = table->GetNumber("tx",0.0);
double ty = table->GetNumber("ty",0.0);
double ta = table->GetNumber("ta",0.0);
double tv = table->GetNumber("tv",0.0);
if (tv >= 1 )
{
if ((tx > 1.0) || (tx < -1.0))
{
TurretLeftMotor.Set(ctre::phoenix::motorcontrol::ControlMode::PercentOutput, -0.02*tx);
TurretRightMotor.Set(ctre::phoenix::motorcontrol::ControlMode::PercentOutput,-0.02*tx );
}
else if ((tx > -1.0) && (tx < 1.0))
{
TurretLeftMotor.Set(ctre::phoenix::motorcontrol::ControlMode::PercentOutput, 0 );
TurretRightMotor.Set(ctre::phoenix::motorcontrol::ControlMode::PercentOutput,0 );
}
}
else if (tv = 0)
{
TurretLeftMotor.Set(ctre::phoenix::motorcontrol::ControlMode::PercentOutput, 0 );
TurretRightMotor.Set(ctre::phoenix::motorcontrol::ControlMode::PercentOutput,0 );
}
else
{
TurretLeftMotor.Set(ctre::phoenix::motorcontrol::ControlMode::PercentOutput, 0 );
TurretRightMotor.Set(ctre::phoenix::motorcontrol::ControlMode::PercentOutput,0 );
}
}
#ifndef RUNNING_FRC_TESTS
int main()
{
return frc::StartRobot<Robot>();
}
#endif