Skip to content

Commit 884b5b9

Browse files
Update Robot.cpp
1 parent 3a088da commit 884b5b9

File tree

1 file changed

+16
-15
lines changed

1 file changed

+16
-15
lines changed

main/cpp/Robot.cpp

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,14 @@
99

1010
#include "Robot.h"
1111

12+
1213
void Robot::RobotInit() {
1314
compressor.Stop ();
15+
timer.Start();
1416
}
1517

1618
void Robot::RobotPeriodic() {
1719
//Vision
18-
//CHECK THIS BASIL
1920
UsbCamera floorCamera = CameraServer::GetInstance()->StartAutomaticCapture(0);
2021
UsbCamera driverCamera = CameraServer::GetInstance()->StartAutomaticCapture(1);
2122
driverCamera.SetResolution(320, 240);
@@ -27,11 +28,11 @@ void Robot::RobotPeriodic() {
2728
while (true) {
2829
if (cvSink.GrabFrame(mat) == 0) {
2930
outputStream.NotifyError(cvSink.GetError());
31+
}
32+
rectangle(mat, Point(100, 100), Point(400, 400), Scalar(255, 255, 255), 5);
33+
outputStream.PutFrame(mat);
3034
}
31-
rectangle(mat, Point(100, 100), Point(400, 400), Scalar(255, 255, 255), 5);
32-
outputStream.PutFrame(mat);
33-
}
34-
//END OF CHECK THIS BASIL
35+
3536
//Compressor
3637
if (fightStick.GetRawButton(8) == 1) {
3738
compressor.Start();
@@ -42,33 +43,33 @@ void Robot::RobotPeriodic() {
4243
//Drive
4344
if (flightStick.GetRawButton(2) == 1) { //Slow
4445
if (flightStick.GetRawAxis(1) > 0 || flightStick.GetRawAxis(1) < 0) {
45-
if (0<time.Get<(f/2)) {
46-
Drive.CurvatureDrive((flightStick.GetRawAxis(1)/2*sin((((2 * M_PI)/f)*time.Get()) - M_PI_2)+flightStick.GetRawAxis(1)/2) * -1 * speedSlow, flightStick.GetRawAxis(2) * turningSpeedSlow, flightStick.GetRawButton(1));
46+
if (0<timer.Get()<(f/2)) {
47+
Drive.CurvatureDrive(flightStick.GetRawAxis(1) / 2 *sin((((2 * M_PI) / f) * timer.Get() - M_PI_2) + flightStick.GetRawAxis(1) / 2) * -1 * speedSlow, flightStick.GetRawAxis(2) * turningSpeedSlow, flightStick.GetRawButton(1));
4748
} else {
4849
Drive.CurvatureDrive(flightStick.GetRawAxis(1) * -1 * speedSlow, flightStick.GetRawAxis(2) * turningSpeedSlow, flightStick.GetRawButton(1));
4950
}
5051
} else {
51-
time.Reset();
52+
timer.Reset();
5253
}
5354
} else if (flightStick.GetRawButton(11/*Will Change*/) == 1) { // Fast
5455
if (flightStick.GetRawAxis(1) > 0 || flightStick.GetRawAxis(1) < 0) {
55-
if (0<time.Get()<(f/2)) {
56-
Drive.CurvatureDrive((flightStick.GetRawAxis(1)/2*sin((((2 * M_PI)/f)*time.Get()) - M_PI_2)+flightStick.GetRawAxis(1)/2) * -1 * speedFast, flightStick.GetRawAxis(2) * turningSpeedFast, flightStick.GetRawButton(1));
56+
if (0<timer.Get()<(f/2)) {
57+
Drive.CurvatureDrive(flightStick.GetRawAxis(1)/2*sin((((2 * M_PI)/f)*timer.Get() - M_PI_2)+flightStick.GetRawAxis(1)/2) * -1 * speedFast, flightStick.GetRawAxis(2) * turningSpeedFast, flightStick.GetRawButton(1));
5758
} else {
5859
Drive.CurvatureDrive(flightStick.GetRawAxis(1) * -1 * speedFast, flightStick.GetRawAxis(2) * turningSpeedFast, flightStick.GetRawButton(1));
5960
}
6061
} else {
61-
time.Reset();
62+
timer.Reset();
6263
}
6364
} else { //Normal
6465
if (flightStick.GetRawAxis(1) > 0 || flightStick.GetRawAxis(1) < 0) {
65-
if (0<time.Get()<(f/2)) {
66-
Drive.CurvatureDrive((flightStick.GetRawAxis(1)/2*sin((((2 * M_PI)/f)*time.Get()) - M_PI_2)+flightStick.GetRawAxis(1)/2) * -1 * speedNormal, flightStick.GetRawAxis(2) * turningSpeedSlow, flightStick.GetRawButton(1));
66+
if (0<timer.Get()<(f/2)) {
67+
Drive.CurvatureDrive(flightStick.GetRawAxis(1)/2*sin((((2 * M_PI)/f)*timer.Get() - M_PI_2)+flightStick.GetRawAxis(1)/2) * -1 * speedNormal, flightStick.GetRawAxis(2) * turningSpeedSlow, flightStick.GetRawButton(1));
6768
} else {
6869
Drive.CurvatureDrive(flightStick.GetRawAxis(1) * -1 * speedNormal, flightStick.GetRawAxis(2) * turningSpeedSlow, flightStick.GetRawButton(1));
6970
}
7071
} else {
71-
time.Reset();
72+
timer.Reset();
7273
}
7374
}
7475
//HAB Lift(???)
@@ -123,7 +124,7 @@ void Robot::RobotPeriodic() {
123124
}
124125

125126
//Hatch Panel Launcher
126-
//They are set backwards if time is avaible would like to switch them around in both the code and wiring
127+
//They are set backwards if timerr is avaible would like to switch them around in both the code and wiring
127128
if (fightStick.GetRawButton(4) == 0) {
128129
s_panelLauncherBottom.Set(DoubleSolenoid::kForward);
129130
s_panelLauncherTop.Set(DoubleSolenoid::kForward);

0 commit comments

Comments
 (0)