Skip to content

Commit 3243756

Browse files
author
Ezra Boley
committed
Stupidly large commit, added the semaphores that almost saved the pod. Alas, it was too late and all was lost
1 parent 3779f3c commit 3243756

File tree

17 files changed

+220
-118
lines changed

17 files changed

+220
-118
lines changed

embedded/app/include/state_machine.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
#define NUM_STATES 11
1313
#define FAULT "fault"
1414

15-
#define NON_RUN_FAULT_NAME FAULT"NonRun"
16-
#define RUN_FAULT_NAME FAULT"Run"
15+
#define NON_RUN_FAULT_NAME "nonRunFault"
16+
#define RUN_FAULT_NAME "runFault"
1717
#define IDLE_NAME "idle"
1818
#define PUMPDOWN_NAME "pumpdown"
1919
#define PROPULSION_NAME "propulsion"

embedded/app/include/states.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#define PS2_BOTTOM_LIMIT_CRAWLPOST -15
2020
#define PS2_TOP_LIMIT_IDLE 150
2121
#define PS2_TOP_LIMIT_PRE 300
22-
#define PS2_TOP_LIMIT_CRAWLPOST 100
22+
#define PS2_TOP_LIMIT_CRAWLPOST 160
2323

2424

2525
#define PS3_BOTTOM_LIMIT_IDLE -10
@@ -43,8 +43,8 @@
4343
#define SEC_PS2_BOTTOM_LIMIT_PRE 0
4444
#define SEC_PS2_BOTTOM_LIMIT_CRAWLPOST 0
4545
#define SEC_PS2_TOP_LIMIT_PRE 150
46-
#define SEC_PS2_TOP_LIMIT_CRAWLPOST 20
47-
#define SEC_PS2_TOP_LIMIT_IDLE 15
46+
#define SEC_PS2_TOP_LIMIT_CRAWLPOST 150
47+
#define SEC_PS2_TOP_LIMIT_IDLE 150
4848

4949
#define SEC_PS3_BOTTOM_LIMIT_IDLE -15
5050
#define SEC_PS3_BOTTOM_LIMIT -15

embedded/app/include/transitions.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,5 @@ int genPostRun(void);
2121

2222
int genStopped(void);
2323

24+
int genNonRunFault(void);
2425
#endif

embedded/app/main/badgerloop_HV.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,10 @@ int init() {
4646

4747
SetupMotor();
4848
/* initMotor(); */
49-
initPressureSensors();
49+
/* initPressureSensors();*/
5050
/* Allocate needed memory for state machine and create graph */
5151
buildStateMachine();
52-
52+
printf("Ezra\n");
5353
/* Init telemetry */
5454
SetupHVTelemetry((char *) DASHBOARD_IP, DASHBOARD_PORT);
5555
SetupHVTCPServer();
@@ -87,6 +87,7 @@ int main() {
8787
printf("signallingDone\n");
8888
}
8989
if (data->flags->brakeInit) {
90+
printf("Cancelling brake\n");
9091
signalLV((char *)"primBrakeOff");
9192
usleep(1000);
9293
signalLV((char *)"secBrakeOff");

embedded/app/main/badgerloop_LV.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ int init() {
2424
/* Init Data */
2525
initData();
2626

27+
initPressureMonitor();
2728
initProcIox(true);
2829
initLVIox(true);
2930

3031
/* Init all peripherals */
3132
/* SetupIMU(); GOODBYE MY SWEET SUMMER CHILD */
3233
initRetros();
33-
initPressureMonitor();
3434
initNav();
3535

3636
/* Init telemetry services */

embedded/app/src/state_machine.c

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
#include <string.h>
1616
#include <stdlib.h>
1717
#include <stdbool.h>
18-
1918
static void initState(state_t* state, char* name, stateTransition_t *(*action)(), int numTrans);
2019
static void initTransition(stateTransition_t *transition, state_t *target, int (*action)() );
2120

@@ -150,7 +149,7 @@ static int initPumpdown(state_t *pumpdown) {
150149

151150
static int initPropulsion(state_t *propulsion) {
152151

153-
initTransition(propulsion->transitions[0], findState(BRAKING_NAME), genTranAction);
152+
initTransition(propulsion->transitions[0], findState(BRAKING_NAME), genBraking);
154153
initTransition(propulsion->transitions[1], findState(RUN_FAULT_NAME), genRunFault);
155154
addTransition(PROPULSION_NAME, propulsion->transitions[0]);
156155
addTransition(PROPULSION_NAME, propulsion->transitions[1]);
@@ -162,7 +161,7 @@ static int initPropulsion(state_t *propulsion) {
162161

163162
static int initBraking(state_t *braking) {
164163

165-
initTransition(braking->transitions[0], findState(STOPPED_NAME), genTranAction);
164+
initTransition(braking->transitions[0], findState(STOPPED_NAME), genStopped);
166165
initTransition(braking->transitions[1], findState(RUN_FAULT_NAME), genRunFault);
167166
addTransition(BRAKING_NAME, braking->transitions[0]);
168167
addTransition(BRAKING_NAME, braking->transitions[1]);
@@ -174,7 +173,7 @@ static int initBraking(state_t *braking) {
174173
}
175174

176175
static int initServPrecharge(state_t *servPrecharge) {
177-
initTransition(servPrecharge->transitions[0], findState(RUN_FAULT_NAME), genTranAction);
176+
initTransition(servPrecharge->transitions[0], findState(RUN_FAULT_NAME), genRunFault);
178177
addTransition(SERV_PRECHARGE_NAME, servPrecharge->transitions[0]);
179178
servPrecharge->fault = servPrecharge->transitions[0];
180179

@@ -186,17 +185,18 @@ static int initServPrecharge(state_t *servPrecharge) {
186185
static int initCrawl(state_t *crawl) {
187186

188187
initTransition(crawl->transitions[0], findState(POST_RUN_NAME), genPostRun);
189-
initTransition(crawl->transitions[1], findState(RUN_FAULT_NAME), genTranAction);
188+
initTransition(crawl->transitions[1], findState(RUN_FAULT_NAME), genRunFault);
190189
addTransition(CRAWL_NAME, crawl->transitions[0]);
191-
addTransition(CRAWL_NAME, crawl->fault = crawl->transitions[1]);
190+
addTransition(CRAWL_NAME, crawl->transitions[1] );
192191

192+
crawl->fault = crawl->transitions[1];
193193
crawl->next = crawl->transitions[0];
194194
crawl->begin = genCrawl;
195195
return 0;
196196
}
197197

198198
static int initStopped(state_t *stopped) {
199-
initTransition(stopped->transitions[0], findState(RUN_FAULT_NAME), genTranAction);
199+
initTransition(stopped->transitions[0], findState(RUN_FAULT_NAME), genRunFault);
200200
addTransition(STOPPED_NAME, stopped->transitions[0]);
201201
stopped->fault = stopped->transitions[0];
202202
stopped->next = NULL;
@@ -205,7 +205,7 @@ static int initStopped(state_t *stopped) {
205205
}
206206

207207
static int initPostRun(state_t *postRun) {
208-
initTransition(postRun->transitions[1], findState(RUN_FAULT_NAME), genTranAction);
208+
initTransition(postRun->transitions[0], findState(RUN_FAULT_NAME), genRunFault);
209209
addTransition(POST_RUN_NAME, postRun->transitions[0]);
210210
postRun->fault = postRun->transitions[0];
211211
postRun->next = NULL;
@@ -214,10 +214,11 @@ static int initPostRun(state_t *postRun) {
214214
}
215215

216216
static int initSafeToApproach(state_t *safeToApproach) {
217-
initTransition(safeToApproach->transitions[0], findState(NON_RUN_FAULT_NAME), genTranAction);
218-
addTransition(SAFE_TO_APPROACH_NAME,
219-
safeToApproach->fault = safeToApproach->transitions[0]);
220-
safeToApproach->next = NULL;
217+
initTransition(safeToApproach->transitions[0], findState(NON_RUN_FAULT_NAME), genNonRunFault);
218+
addTransition(SAFE_TO_APPROACH_NAME, safeToApproach->transitions[0]);
219+
safeToApproach->fault = safeToApproach->transitions[0];
220+
safeToApproach->next = NULL;
221+
safeToApproach->begin = genTranAction;
221222
return 0;
222223
}
223224

@@ -262,10 +263,12 @@ void runStateMachine(void) {
262263
if (strcmp(stateMachine.overrideStateName, BLANK_NAME) != 0) {
263264
state_t *tempState = findState(stateMachine.overrideStateName);
264265
if (tempState != NULL) {
266+
printf("TEMP STATE NAME: %s\n", tempState->name);
265267
stateTransition_t *trans = findTransition(stateMachine.currState, stateMachine.overrideStateName);
266268
if (trans != NULL) {
267269
trans->action();
268270
} else {
271+
printf("begin func\n");
269272
tempState->begin();
270273
}
271274
stateMachine.currState = tempState;
@@ -277,7 +280,7 @@ void runStateMachine(void) {
277280
/* execute the state and check if we should be transitioning */
278281
stateTransition_t *transition = stateMachine.currState->action();
279282
if (transition != NULL) {
280-
printf("transAction->%s\n", transition->target->name);
283+
/* printf("transAction->%s\n", transition->target->name);*/
281284
if (transition->action() == 0) {
282285
printf("here we are\n");
283286
stateMachine.currState = transition->target;
@@ -324,9 +327,9 @@ void buildStateMachine(void) {
324327
initPumpdown(stateMachine.allStates[1]);
325328
initPropulsion(stateMachine.allStates[2]);
326329
initBraking(stateMachine.allStates[3]);
327-
initStopped(stateMachine.allStates[4]);
328-
initServPrecharge(stateMachine.allStates[5]);
329-
initCrawl(stateMachine.allStates[6]);
330+
initServPrecharge(stateMachine.allStates[4]);
331+
initCrawl(stateMachine.allStates[5]);
332+
initStopped(stateMachine.allStates[6]);
330333
initPostRun(stateMachine.allStates[7]);
331334
initSafeToApproach(stateMachine.allStates[8]);
332335

0 commit comments

Comments
 (0)