Skip to content

Commit 5346fa1

Browse files
committed
Merge branch 'master' of https://github.com/eshsrobotics/vex
2 parents 43e476c + d0d978c commit 5346fa1

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

2024/Team_P_bot_code/include/hardware.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,11 @@ const int CLAMP_PORT = 11 - 1;
5959
// timeout time the clamp kept pushing into the ground. Because of this, the
6060
// timeout time when the clamp is going downwards is lower than when the clamp
6161
// is moving upwards.
62-
const double OPEN_CLAMP_TIMEOUT_SEC = 0.40;
62+
const double OPEN_CLAMP_TIMEOUT_SEC = 4.0;
6363

64-
const double CLOSE_CLAMP_TIMEOUT_SEC = 0.40;
64+
const double CLOSE_CLAMP_TIMEOUT_SEC = 4.0;
6565

66-
const double CLAMP_VELOCITY_PCT = 100.00;
66+
const double CLAMP_VELOCITY_PCT = 80.00;
6767

6868
// Intake motor port
6969
const int INTAKE_PORT = 8 - 1;

2024/Team_P_bot_code/src/hardware.cpp

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,13 @@
22

33
#include "hardware.h"
44
#include <algorithm>
5+
#include <map>
6+
57

68
using namespace vex;
79
using std::max;
810
using std::min;
11+
using std::map;
912

1013
brain Brain;
1114
controller Controller;
@@ -106,8 +109,15 @@ void robotlift(int lift) {
106109
void updateClampState(bool close) {
107110
static ClampState clampStatus = ClampState::Start;
108111
static double startTimeSec = 0;
112+
map<ClampState, const char*> stateNames = {
113+
{ClampState::Start, "Start"},
114+
{ClampState::Opening, "Opening"},
115+
{ClampState::FullyOpen, "Fully open"},
116+
{ClampState::Closing, "Closing"},
117+
{ClampState::FullyClosed, "FullyClosed"}
118+
};
109119
Controller.Screen.setCursor(1,1);
110-
Controller.Screen.print("Limit = %d", ClampLimit.value());
120+
Controller.Screen.print("%s: Limit = %d ", stateNames[clampStatus], ClampLimit.value());
111121
switch(clampStatus) {
112122
case ClampState::Start:
113123
startTimeSec = Brain.timer(vex::timeUnits::sec);
@@ -119,7 +129,7 @@ void updateClampState(bool close) {
119129
break;
120130

121131
case ClampState::Opening:
122-
Clamp.spin(vex::directionType::rev, CLAMP_VELOCITY_PCT, pct);
132+
Clamp.spin(vex::directionType::fwd, CLAMP_VELOCITY_PCT, pct);
123133
if (Brain.timer(vex::timeUnits::sec) >= OPEN_CLAMP_TIMEOUT_SEC + startTimeSec || ClampLimit.value() > 0) {
124134
clampStatus = ClampState::FullyOpen;
125135
} else if (close == true) {
@@ -130,7 +140,7 @@ void updateClampState(bool close) {
130140
break;
131141

132142
case ClampState::Closing:
133-
Clamp.spin(vex::directionType::fwd, CLAMP_VELOCITY_PCT, pct);
143+
Clamp.spin(vex::directionType::rev, CLAMP_VELOCITY_PCT, pct);
134144
if (Brain.timer(vex::timeUnits::sec) >= CLOSE_CLAMP_TIMEOUT_SEC + startTimeSec) {
135145
clampStatus = ClampState::FullyClosed;
136146
} else if (close == false) {

0 commit comments

Comments
 (0)