5
5
#include < std_msgs/Int32.h>
6
6
7
7
// 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
16
16
17
17
#define MCU_KS 10
18
- #define WATER_DETECTED 1
18
+ // #define WATER_DETECTED 1
19
19
20
20
#define TEENSY_LED 13
21
21
32
32
#define VBAT2_SENSE 23
33
33
34
34
// 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 ;
43
43
44
44
// defines 2 battery voltage sensing and 8 thruster current sensing messages for ROS advertising
45
45
std_msgs::Float32 batt1_voltage_msg;
@@ -71,14 +71,14 @@ float Bvoltages[2];
71
71
72
72
// updates thrusters' pwm signals from array
73
73
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 ]);
82
82
}
83
83
84
84
// updates microseconds array with values from ros
@@ -88,14 +88,14 @@ void commandCb(const auv_msgs::ThrusterMicroseconds& tc){
88
88
89
89
// attaches and arms thrusters
90
90
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 );
99
99
100
100
updateThrusters (offCommand);
101
101
}
@@ -127,19 +127,19 @@ void powerSystem() {
127
127
}
128
128
129
129
// 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
+ // }
143
143
144
144
// senses currents of the 8 thrusters
145
145
void senseCurrent (double Tcurrents[]) {
@@ -202,8 +202,8 @@ void setup() {
202
202
203
203
pinMode (MCU_KS, OUTPUT);
204
204
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);
207
207
// pinMode(TC_1, INPUT);
208
208
// pinMode(TC_2, INPUT);
209
209
// pinMode(TC_3, INPUT);
0 commit comments