Skip to content

Commit 4b71271

Browse files
committed
update power board code
1 parent cbd315f commit 4b71271

File tree

1 file changed

+48
-48
lines changed

1 file changed

+48
-48
lines changed

Power/src/main.cpp

Lines changed: 48 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,17 @@
55
#include <std_msgs/Int32.h>
66

77
// defines all MCU pins
8-
#define SRG_P_PIN 2
9-
#define SRG_S_PIN 3
10-
#define SWY_BW_PIN 4
11-
#define SWY_ST_PIN 5
12-
#define HVE_BW_P_PIN 6
13-
#define HVE_BW_S_PIN 7
14-
#define HVE_ST_S_PIN 8
15-
#define HVE_ST_P_PIN 9
8+
#define FRONT_L_PIN 2
9+
#define FRONT_R_PIN 3
10+
#define BACK_L_PIN 4
11+
#define BACK_R_PIN 5
12+
#define HEAVE_FRONT_L_PIN 6
13+
#define HEAVE_FRONT_R_PIN 7
14+
#define HEAVE_BACK_L_PIN 8
15+
#define HEAVE_BACK_R_PIN 9
1616

1717
#define MCU_KS 10
18-
#define WATER_DETECTED 1
18+
// #define WATER_DETECTED 1
1919

2020
#define TEENSY_LED 13
2121

@@ -32,14 +32,14 @@
3232
#define VBAT2_SENSE 23
3333

3434
// defines 8 thursters for ROS subscribing
35-
const uint8_t SRG_P = auv_msgs::ThrusterMicroseconds::SURGE_PORT;
36-
const uint8_t SRG_S = auv_msgs::ThrusterMicroseconds::SURGE_STAR;
37-
const uint8_t SWY_BW = auv_msgs::ThrusterMicroseconds::SWAY_BOW;
38-
const uint8_t SWY_ST = auv_msgs::ThrusterMicroseconds::SWAY_STERN;
39-
const uint8_t HVE_BW_P = auv_msgs::ThrusterMicroseconds::HEAVE_BOW_PORT;
40-
const uint8_t HVE_BW_S = auv_msgs::ThrusterMicroseconds::HEAVE_BOW_STAR;
41-
const uint8_t HVE_ST_S = auv_msgs::ThrusterMicroseconds::HEAVE_STERN_STAR;
42-
const uint8_t HVE_ST_P = auv_msgs::ThrusterMicroseconds::HEAVE_STERN_PORT;
35+
const uint8_t FRONT_L = auv_msgs::ThrusterMicroseconds::FRONT_LEFT;
36+
const uint8_t FRONT_R = auv_msgs::ThrusterMicroseconds::FRONT_RIGHT;
37+
const uint8_t BACK_L = auv_msgs::ThrusterMicroseconds::BACK_LEFT;
38+
const uint8_t BACK_R = auv_msgs::ThrusterMicroseconds::BACK_RIGHT;
39+
const uint8_t HEAVE_FRONT_L = auv_msgs::ThrusterMicroseconds::HEAVE_FRONT_LEFT;
40+
const uint8_t HEAVE_FRONT_R = auv_msgs::ThrusterMicroseconds::HEAVE_FRONT_RIGHT;
41+
const uint8_t HEAVE_BACK_L = auv_msgs::ThrusterMicroseconds::HEAVE_BACK_LEFT;
42+
const uint8_t HEAVE_BACK_R = auv_msgs::ThrusterMicroseconds::HEAVE_BACK_RIGHT;
4343

4444
// defines 2 battery voltage sensing and 8 thruster current sensing messages for ROS advertising
4545
std_msgs::Float32 batt1_voltage_msg;
@@ -71,14 +71,14 @@ float Bvoltages[2];
7171

7272
// updates thrusters' pwm signals from array
7373
void updateThrusters(const uint16_t microseconds[8]) {
74-
thrusters[SRG_P].writeMicroseconds(microseconds[SRG_P]);
75-
thrusters[SRG_S].writeMicroseconds(microseconds[SRG_S]);
76-
thrusters[SWY_BW].writeMicroseconds(microseconds[SWY_BW]);
77-
thrusters[SWY_ST].writeMicroseconds(microseconds[SWY_ST]);
78-
thrusters[HVE_BW_P].writeMicroseconds(microseconds[HVE_BW_P]);
79-
thrusters[HVE_BW_S].writeMicroseconds(microseconds[HVE_BW_S]);
80-
thrusters[HVE_ST_P].writeMicroseconds(microseconds[HVE_ST_P]);
81-
thrusters[HVE_ST_S].writeMicroseconds(microseconds[HVE_ST_S]);
74+
thrusters[FRONT_L].writeMicroseconds(microseconds[FRONT_L]);
75+
thrusters[FRONT_R].writeMicroseconds(microseconds[FRONT_R]);
76+
thrusters[BACK_L].writeMicroseconds(microseconds[BACK_L]);
77+
thrusters[BACK_R].writeMicroseconds(microseconds[BACK_R]);
78+
thrusters[HEAVE_FRONT_L].writeMicroseconds(microseconds[HEAVE_FRONT_L]);
79+
thrusters[HEAVE_FRONT_R].writeMicroseconds(microseconds[HEAVE_FRONT_R]);
80+
thrusters[HEAVE_BACK_R].writeMicroseconds(microseconds[HEAVE_BACK_R]);
81+
thrusters[HEAVE_BACK_L].writeMicroseconds(microseconds[HEAVE_BACK_L]);
8282
}
8383

8484
// updates microseconds array with values from ros
@@ -88,14 +88,14 @@ void commandCb(const auv_msgs::ThrusterMicroseconds& tc){
8888

8989
// attaches and arms thrusters
9090
void initThrusters() {
91-
thrusters[SRG_P].attach(SRG_P_PIN);
92-
thrusters[SRG_S].attach(SRG_S_PIN);
93-
thrusters[SWY_BW].attach(SWY_BW_PIN);
94-
thrusters[SWY_ST].attach(SWY_ST_PIN);
95-
thrusters[HVE_BW_P].attach(HVE_BW_P_PIN);
96-
thrusters[HVE_BW_S].attach(HVE_BW_S_PIN);
97-
thrusters[HVE_ST_S].attach(HVE_ST_S_PIN);
98-
thrusters[HVE_ST_P].attach(HVE_ST_P_PIN);
91+
thrusters[FRONT_L].attach(FRONT_L_PIN);
92+
thrusters[FRONT_R].attach(FRONT_R_PIN);
93+
thrusters[BACK_L].attach(BACK_L_PIN);
94+
thrusters[BACK_R].attach(BACK_R_PIN);
95+
thrusters[HEAVE_FRONT_L].attach(HEAVE_FRONT_L_PIN);
96+
thrusters[HEAVE_FRONT_R].attach(HEAVE_FRONT_R_PIN);
97+
thrusters[HEAVE_BACK_L].attach(HEAVE_BACK_L_PIN);
98+
thrusters[HEAVE_BACK_R].attach(HEAVE_BACK_R_PIN);
9999

100100
updateThrusters(offCommand);
101101
}
@@ -127,19 +127,19 @@ void powerSystem() {
127127
}
128128

129129
// permanently kills system by writing high to kill switch transistor and flashes led light
130-
void waterInterrupt() {
131-
delay(100);
132-
133-
if (digitalRead(WATER_DETECTED)) {
134-
// killSystem();
135-
while (true) {
136-
digitalWrite(TEENSY_LED, HIGH);
137-
delay(500);
138-
digitalWrite(TEENSY_LED, LOW);
139-
delay(500);
140-
}
141-
}
142-
}
130+
// void waterInterrupt() {
131+
// delay(100);
132+
133+
// if (digitalRead(WATER_DETECTED)) {
134+
// // killSystem();
135+
// while (true) {
136+
// digitalWrite(TEENSY_LED, HIGH);
137+
// delay(500);
138+
// digitalWrite(TEENSY_LED, LOW);
139+
// delay(500);
140+
// }
141+
// }
142+
// }
143143

144144
// senses currents of the 8 thrusters
145145
void senseCurrent(double Tcurrents[]) {
@@ -202,8 +202,8 @@ void setup() {
202202

203203
pinMode(MCU_KS, OUTPUT);
204204
pinMode(TEENSY_LED, OUTPUT);
205-
pinMode(WATER_DETECTED, INPUT_PULLUP);
206-
attachInterrupt(digitalPinToInterrupt(WATER_DETECTED), waterInterrupt, RISING);
205+
// pinMode(WATER_DETECTED, INPUT_PULLUP);
206+
// attachInterrupt(digitalPinToInterrupt(WATER_DETECTED), waterInterrupt, RISING);
207207
// pinMode(TC_1, INPUT);
208208
// pinMode(TC_2, INPUT);
209209
// pinMode(TC_3, INPUT);

0 commit comments

Comments
 (0)