most functionality to splashdwon, find neutral and start mission. short timeouts still in code for testing, will adjust to go directly to sit_idle after splashdown
Dependencies: mbed MODSERIAL FATFileSystem
ConfigFileIO/ConfigFileIO.cpp@82:0981b9ada820, 2019-02-15 (annotated)
- Committer:
- joel_ssc
- Date:
- Fri Feb 15 16:00:17 2019 +0000
- Revision:
- 82:0981b9ada820
- Parent:
- 79:3688c3a0d7f4
- Child:
- 86:ba3a118b0080
intermediate stage of file leg system
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
tnhnrl | 57:ec69651c8c21 | 1 | #include "ConfigFileIO.hpp" |
tnhnrl | 57:ec69651c8c21 | 2 | #include "StaticDefs.hpp" |
tnhnrl | 57:ec69651c8c21 | 3 | |
tnhnrl | 57:ec69651c8c21 | 4 | //configuration file io, both to read, set, and save |
tnhnrl | 57:ec69651c8c21 | 5 | |
tnhnrl | 57:ec69651c8c21 | 6 | ConfigFileIO::ConfigFileIO() { |
tnhnrl | 73:f6f378311c8d | 7 | } |
tnhnrl | 57:ec69651c8c21 | 8 | |
tnhnrl | 76:c802e1da4179 | 9 | void ConfigFileIO::saveBattData(float batt_p_gain, float batt_i_gain, float batt_d_gain, int batt_zeroOffset, float batt_filter_freq, float batt_deadband) { |
tnhnrl | 57:ec69651c8c21 | 10 | ConfigFile write_Batt_txt; //write to the config file |
tnhnrl | 57:ec69651c8c21 | 11 | |
tnhnrl | 57:ec69651c8c21 | 12 | char PGain_buffer[128]; |
tnhnrl | 57:ec69651c8c21 | 13 | sprintf(PGain_buffer,"# configuration file for battery mover parameters\n\n#Gains\nPGain"); |
tnhnrl | 57:ec69651c8c21 | 14 | |
tnhnrl | 57:ec69651c8c21 | 15 | char string_pgain[128]; |
tnhnrl | 73:f6f378311c8d | 16 | sprintf(string_pgain, "%f", batt_p_gain); |
tnhnrl | 57:ec69651c8c21 | 17 | write_Batt_txt.setValue(PGain_buffer, string_pgain); |
tnhnrl | 57:ec69651c8c21 | 18 | |
tnhnrl | 57:ec69651c8c21 | 19 | char string_igain[128]; |
tnhnrl | 73:f6f378311c8d | 20 | sprintf(string_igain, "%f", batt_i_gain); |
tnhnrl | 57:ec69651c8c21 | 21 | write_Batt_txt.setValue("IGain", string_igain); |
tnhnrl | 57:ec69651c8c21 | 22 | |
tnhnrl | 57:ec69651c8c21 | 23 | char string_dgain[128]; |
tnhnrl | 73:f6f378311c8d | 24 | sprintf(string_dgain, "%f", batt_d_gain); |
tnhnrl | 57:ec69651c8c21 | 25 | write_Batt_txt.setValue("DGain", string_dgain); |
tnhnrl | 73:f6f378311c8d | 26 | |
tnhnrl | 73:f6f378311c8d | 27 | char string_zeroCounts[128]; |
tnhnrl | 76:c802e1da4179 | 28 | sprintf(string_zeroCounts, "%d", batt_zeroOffset); |
tnhnrl | 73:f6f378311c8d | 29 | write_Batt_txt.setValue("\n#string pot parameters\nzeroCounts", string_zeroCounts); |
tnhnrl | 73:f6f378311c8d | 30 | |
tnhnrl | 79:3688c3a0d7f4 | 31 | //modified this from hard-coded values to set to whatever is in the file on startup |
tnhnrl | 79:3688c3a0d7f4 | 32 | char string_batt_travel_limit[128]; |
tnhnrl | 79:3688c3a0d7f4 | 33 | sprintf(string_batt_travel_limit, "%f", batt().getTravelLimit()); |
tnhnrl | 79:3688c3a0d7f4 | 34 | write_Batt_txt.setValue("PistonTravelLimit", string_batt_travel_limit); |
tnhnrl | 79:3688c3a0d7f4 | 35 | |
tnhnrl | 57:ec69651c8c21 | 36 | write_Batt_txt.setValue("slope", "0.12176"); |
tnhnrl | 73:f6f378311c8d | 37 | |
tnhnrl | 73:f6f378311c8d | 38 | char string_filter_freq[128]; |
tnhnrl | 73:f6f378311c8d | 39 | sprintf(string_filter_freq, "%f", batt_filter_freq); |
tnhnrl | 73:f6f378311c8d | 40 | write_Batt_txt.setValue("filterWn", string_filter_freq); |
tnhnrl | 73:f6f378311c8d | 41 | |
tnhnrl | 73:f6f378311c8d | 42 | char string_deadband[128]; |
tnhnrl | 73:f6f378311c8d | 43 | sprintf(string_deadband, "%f", batt_deadband); |
tnhnrl | 73:f6f378311c8d | 44 | write_Batt_txt.setValue("deadband", string_deadband); |
tnhnrl | 57:ec69651c8c21 | 45 | |
tnhnrl | 57:ec69651c8c21 | 46 | //SAVE THE DATA! |
tnhnrl | 74:d281aaef9766 | 47 | xbee().printf("Saving BATTERY MOVER PID data!"); |
tnhnrl | 57:ec69651c8c21 | 48 | |
tnhnrl | 57:ec69651c8c21 | 49 | if (!write_Batt_txt.write("/local/batt.txt")) { |
tnhnrl | 74:d281aaef9766 | 50 | xbee().printf("\n\rERROR: (SAVE)Failure to write batt.txt file."); |
tnhnrl | 57:ec69651c8c21 | 51 | } |
tnhnrl | 57:ec69651c8c21 | 52 | else { |
tnhnrl | 74:d281aaef9766 | 53 | xbee().printf("\n\rFile batt.txt successful written.\n\r"); |
tnhnrl | 57:ec69651c8c21 | 54 | } |
tnhnrl | 57:ec69651c8c21 | 55 | } |
joel_ssc | 82:0981b9ada820 | 56 | void ConfigFileIO::saveLogVersData(int logversion, int diagversion) { |
joel_ssc | 82:0981b9ada820 | 57 | ConfigFile write_logvers_txt; //write to the config file |
joel_ssc | 82:0981b9ada820 | 58 | |
joel_ssc | 82:0981b9ada820 | 59 | char string_log[128]; |
joel_ssc | 82:0981b9ada820 | 60 | sprintf(string_log, "%d", logversion); |
joel_ssc | 82:0981b9ada820 | 61 | write_logvers_txt.setValue("LogFileVers", string_log); |
joel_ssc | 82:0981b9ada820 | 62 | |
joel_ssc | 82:0981b9ada820 | 63 | char string_diag[128]; |
joel_ssc | 82:0981b9ada820 | 64 | sprintf(string_diag, "%i", diagversion); |
joel_ssc | 82:0981b9ada820 | 65 | write_logvers_txt.setValue("DiagFileVers", string_diag); |
joel_ssc | 82:0981b9ada820 | 66 | |
joel_ssc | 82:0981b9ada820 | 67 | |
joel_ssc | 82:0981b9ada820 | 68 | |
joel_ssc | 82:0981b9ada820 | 69 | //SAVE THE DATA! |
joel_ssc | 82:0981b9ada820 | 70 | xbee().printf("Saving logfile version numbers !"); |
joel_ssc | 82:0981b9ada820 | 71 | |
joel_ssc | 82:0981b9ada820 | 72 | if (!write_logvers_txt.write("/local/logvers.txt")) { |
joel_ssc | 82:0981b9ada820 | 73 | xbee().printf("\n\rERROR: (SAVE)Failure to write logvers.txt file."); |
joel_ssc | 82:0981b9ada820 | 74 | } |
joel_ssc | 82:0981b9ada820 | 75 | else { |
joel_ssc | 82:0981b9ada820 | 76 | xbee().printf("\n\rFile logvvrs.txt successful written.\n\r"); |
joel_ssc | 82:0981b9ada820 | 77 | } |
joel_ssc | 82:0981b9ada820 | 78 | } |
tnhnrl | 57:ec69651c8c21 | 79 | |
tnhnrl | 73:f6f378311c8d | 80 | void ConfigFileIO::savePitchData(float pitch_p_gain, float pitch_i_gain, float pitch_d_gain, float pitch_zeroOffset, float pitch_filter_freq, float pitch_deadband) { |
tnhnrl | 57:ec69651c8c21 | 81 | ConfigFile write_pitch_txt; //write to the config file |
tnhnrl | 57:ec69651c8c21 | 82 | |
tnhnrl | 57:ec69651c8c21 | 83 | char PGain_buffer[128]; |
tnhnrl | 57:ec69651c8c21 | 84 | sprintf(PGain_buffer,"# pitch outer loop parameters\n\n#Gains\nPGain"); |
tnhnrl | 57:ec69651c8c21 | 85 | |
tnhnrl | 57:ec69651c8c21 | 86 | char string_pgain[128]; |
tnhnrl | 73:f6f378311c8d | 87 | sprintf(string_pgain, "%f", pitch_p_gain); |
tnhnrl | 57:ec69651c8c21 | 88 | write_pitch_txt.setValue(PGain_buffer, string_pgain); |
tnhnrl | 57:ec69651c8c21 | 89 | |
tnhnrl | 57:ec69651c8c21 | 90 | char string_igain[128]; |
tnhnrl | 73:f6f378311c8d | 91 | sprintf(string_igain, "%f", pitch_i_gain); |
tnhnrl | 57:ec69651c8c21 | 92 | write_pitch_txt.setValue("IGain", string_igain); |
tnhnrl | 57:ec69651c8c21 | 93 | |
tnhnrl | 57:ec69651c8c21 | 94 | char string_dgain[128]; |
tnhnrl | 73:f6f378311c8d | 95 | sprintf(string_dgain, "%f", pitch_d_gain); |
tnhnrl | 57:ec69651c8c21 | 96 | write_pitch_txt.setValue("DGain", string_dgain); |
tnhnrl | 73:f6f378311c8d | 97 | |
tnhnrl | 73:f6f378311c8d | 98 | char string_filter_freq[128]; |
tnhnrl | 73:f6f378311c8d | 99 | sprintf(string_filter_freq, "%f", pitch_filter_freq); |
tnhnrl | 73:f6f378311c8d | 100 | write_pitch_txt.setValue("\n#Pitch sensor filter parameters\nfilterWn", string_filter_freq); |
tnhnrl | 73:f6f378311c8d | 101 | |
tnhnrl | 73:f6f378311c8d | 102 | char string_deadband[128]; |
tnhnrl | 73:f6f378311c8d | 103 | sprintf(string_deadband, "%f", pitch_deadband); |
tnhnrl | 73:f6f378311c8d | 104 | write_pitch_txt.setValue("deadband", string_deadband); |
tnhnrl | 57:ec69651c8c21 | 105 | |
tnhnrl | 57:ec69651c8c21 | 106 | char string_zeroOffset[128]; |
tnhnrl | 73:f6f378311c8d | 107 | sprintf(string_zeroOffset, "%f", pitch_zeroOffset); |
tnhnrl | 57:ec69651c8c21 | 108 | //bce setting was 41 mm during LASR experiments |
tnhnrl | 57:ec69651c8c21 | 109 | write_pitch_txt.setValue("\n#Offset for neutral (default: 41)\nzeroOffset", string_zeroOffset); |
tnhnrl | 57:ec69651c8c21 | 110 | |
tnhnrl | 57:ec69651c8c21 | 111 | //SAVE THE DATA! |
tnhnrl | 74:d281aaef9766 | 112 | xbee().printf("Saving Buoyancy Engine Neutral Buoyancy Positions!"); |
tnhnrl | 57:ec69651c8c21 | 113 | |
tnhnrl | 57:ec69651c8c21 | 114 | if (!write_pitch_txt.write("/local/pitch.txt")) { |
tnhnrl | 74:d281aaef9766 | 115 | xbee().printf("\n\rERROR: (SAVE)Failure to write depth.txt file."); |
tnhnrl | 57:ec69651c8c21 | 116 | } |
tnhnrl | 57:ec69651c8c21 | 117 | else { |
tnhnrl | 74:d281aaef9766 | 118 | xbee().printf("\n\rFile pitch.txt successful written.\n\r"); |
tnhnrl | 57:ec69651c8c21 | 119 | } |
tnhnrl | 57:ec69651c8c21 | 120 | } |
tnhnrl | 57:ec69651c8c21 | 121 | |
tnhnrl | 76:c802e1da4179 | 122 | void ConfigFileIO::saveBCEData(float bce_p_gain, float bce_i_gain, float bce_d_gain, int bce_zeroOffset, float bce_filter_freq, float bce_deadband) { |
tnhnrl | 57:ec69651c8c21 | 123 | ConfigFile write_BCE_txt; //write to the config file |
tnhnrl | 57:ec69651c8c21 | 124 | |
tnhnrl | 57:ec69651c8c21 | 125 | char PGain_buffer[128]; |
tnhnrl | 57:ec69651c8c21 | 126 | sprintf(PGain_buffer,"# configuration file for BCE parameters\n\n#Gains\nPGain"); |
tnhnrl | 57:ec69651c8c21 | 127 | |
tnhnrl | 57:ec69651c8c21 | 128 | char string_pgain[128]; |
tnhnrl | 73:f6f378311c8d | 129 | sprintf(string_pgain, "%f", bce_p_gain); |
tnhnrl | 57:ec69651c8c21 | 130 | write_BCE_txt.setValue(PGain_buffer, string_pgain); |
tnhnrl | 57:ec69651c8c21 | 131 | |
tnhnrl | 57:ec69651c8c21 | 132 | char string_igain[128]; |
tnhnrl | 73:f6f378311c8d | 133 | sprintf(string_igain, "%f", bce_i_gain); |
tnhnrl | 57:ec69651c8c21 | 134 | write_BCE_txt.setValue("IGain", string_igain); |
tnhnrl | 57:ec69651c8c21 | 135 | |
tnhnrl | 57:ec69651c8c21 | 136 | char string_dgain[128]; |
tnhnrl | 73:f6f378311c8d | 137 | sprintf(string_dgain, "%f", bce_d_gain); |
tnhnrl | 57:ec69651c8c21 | 138 | write_BCE_txt.setValue("DGain", string_dgain); |
tnhnrl | 73:f6f378311c8d | 139 | |
tnhnrl | 73:f6f378311c8d | 140 | char string_zeroCounts[128]; |
tnhnrl | 76:c802e1da4179 | 141 | sprintf(string_zeroCounts, "%d", bce_zeroOffset); |
tnhnrl | 73:f6f378311c8d | 142 | write_BCE_txt.setValue("\n#string pot parameters\nzeroCounts", string_zeroCounts); |
tnhnrl | 73:f6f378311c8d | 143 | |
tnhnrl | 79:3688c3a0d7f4 | 144 | //modified this from hard-coded values to set to whatever is in the file on startup |
tnhnrl | 79:3688c3a0d7f4 | 145 | char string_bce_travel_limit[128]; |
tnhnrl | 79:3688c3a0d7f4 | 146 | sprintf(string_bce_travel_limit, "%f", batt().getTravelLimit()); |
tnhnrl | 79:3688c3a0d7f4 | 147 | write_BCE_txt.setValue("PistonTravelLimit", string_bce_travel_limit); |
tnhnrl | 79:3688c3a0d7f4 | 148 | |
tnhnrl | 57:ec69651c8c21 | 149 | write_BCE_txt.setValue("slope", "0.12176"); |
tnhnrl | 73:f6f378311c8d | 150 | |
tnhnrl | 73:f6f378311c8d | 151 | char string_filter_freq[128]; |
tnhnrl | 73:f6f378311c8d | 152 | sprintf(string_filter_freq, "%f", bce_filter_freq); |
tnhnrl | 73:f6f378311c8d | 153 | write_BCE_txt.setValue("filterWn", string_filter_freq); |
tnhnrl | 73:f6f378311c8d | 154 | |
tnhnrl | 73:f6f378311c8d | 155 | char string_deadband[128]; |
tnhnrl | 73:f6f378311c8d | 156 | sprintf(string_deadband, "%f", bce_deadband); |
tnhnrl | 73:f6f378311c8d | 157 | write_BCE_txt.setValue("deadband", string_deadband); |
tnhnrl | 57:ec69651c8c21 | 158 | |
tnhnrl | 57:ec69651c8c21 | 159 | //SAVE THE DATA! |
tnhnrl | 74:d281aaef9766 | 160 | xbee().printf("Saving BCE PID data!"); |
tnhnrl | 57:ec69651c8c21 | 161 | |
tnhnrl | 57:ec69651c8c21 | 162 | if (!write_BCE_txt.write("/local/bce.txt")) { |
tnhnrl | 74:d281aaef9766 | 163 | xbee().printf("\n\rERROR: (SAVE)Failure to write bce.txt file."); |
tnhnrl | 57:ec69651c8c21 | 164 | } |
tnhnrl | 57:ec69651c8c21 | 165 | else { |
tnhnrl | 74:d281aaef9766 | 166 | xbee().printf("\n\rFile bce.txt successful written.\n\r"); |
tnhnrl | 57:ec69651c8c21 | 167 | } |
tnhnrl | 57:ec69651c8c21 | 168 | } |
tnhnrl | 57:ec69651c8c21 | 169 | |
tnhnrl | 73:f6f378311c8d | 170 | void ConfigFileIO::saveDepthData(float depth_p_gain, float depth_i_gain, float depth_d_gain, float depth_zeroOffset, float depth_filter_freq, float depth_deadband) { |
tnhnrl | 57:ec69651c8c21 | 171 | ConfigFile write_depth_txt; //write to the config file |
tnhnrl | 57:ec69651c8c21 | 172 | |
tnhnrl | 57:ec69651c8c21 | 173 | char PGain_buffer[128]; |
tnhnrl | 57:ec69651c8c21 | 174 | sprintf(PGain_buffer,"# depth outer loop parameters\n\n#Gains\nPGain"); |
tnhnrl | 57:ec69651c8c21 | 175 | |
tnhnrl | 57:ec69651c8c21 | 176 | char string_pgain[128]; |
tnhnrl | 73:f6f378311c8d | 177 | sprintf(string_pgain, "%f", depth_p_gain); |
tnhnrl | 57:ec69651c8c21 | 178 | write_depth_txt.setValue(PGain_buffer, string_pgain); |
tnhnrl | 57:ec69651c8c21 | 179 | |
tnhnrl | 57:ec69651c8c21 | 180 | char string_igain[128]; |
tnhnrl | 73:f6f378311c8d | 181 | sprintf(string_igain, "%f", depth_i_gain); |
tnhnrl | 57:ec69651c8c21 | 182 | write_depth_txt.setValue("IGain", string_igain); |
tnhnrl | 57:ec69651c8c21 | 183 | |
tnhnrl | 57:ec69651c8c21 | 184 | char string_dgain[128]; |
tnhnrl | 73:f6f378311c8d | 185 | sprintf(string_dgain, "%f", depth_d_gain); |
tnhnrl | 57:ec69651c8c21 | 186 | write_depth_txt.setValue("DGain", string_dgain); |
tnhnrl | 73:f6f378311c8d | 187 | |
tnhnrl | 73:f6f378311c8d | 188 | char string_filter_freq[128]; |
tnhnrl | 73:f6f378311c8d | 189 | sprintf(string_filter_freq, "%f", depth_filter_freq); |
tnhnrl | 73:f6f378311c8d | 190 | write_depth_txt.setValue("\n#Depth sensor filter parameters\nfilterWn", string_filter_freq); |
tnhnrl | 73:f6f378311c8d | 191 | |
tnhnrl | 73:f6f378311c8d | 192 | char string_deadband[128]; |
tnhnrl | 73:f6f378311c8d | 193 | sprintf(string_deadband, "%f", depth_deadband); |
tnhnrl | 73:f6f378311c8d | 194 | write_depth_txt.setValue("deadband", string_deadband); |
tnhnrl | 57:ec69651c8c21 | 195 | |
tnhnrl | 57:ec69651c8c21 | 196 | char string_zeroOffset[128]; |
tnhnrl | 73:f6f378311c8d | 197 | sprintf(string_zeroOffset, "%f", depth_zeroOffset); |
tnhnrl | 57:ec69651c8c21 | 198 | //bce setting was 240 mm during LASR experiments |
tnhnrl | 57:ec69651c8c21 | 199 | write_depth_txt.setValue("\n#Offset for neutral (default: 240)\nzeroOffset", string_zeroOffset); |
tnhnrl | 57:ec69651c8c21 | 200 | |
tnhnrl | 57:ec69651c8c21 | 201 | //SAVE THE DATA! |
tnhnrl | 74:d281aaef9766 | 202 | xbee().printf("Saving Buoyancy Engine Neutral Buoyancy Positions!"); |
tnhnrl | 57:ec69651c8c21 | 203 | |
tnhnrl | 57:ec69651c8c21 | 204 | if (!write_depth_txt.write("/local/depth.txt")) { |
tnhnrl | 74:d281aaef9766 | 205 | xbee().printf("\n\rERROR: (SAVE)Failure to write depth.txt file."); |
tnhnrl | 57:ec69651c8c21 | 206 | } |
tnhnrl | 57:ec69651c8c21 | 207 | else { |
tnhnrl | 74:d281aaef9766 | 208 | xbee().printf("\n\rFile depth.txt successful written.\n\r"); |
tnhnrl | 57:ec69651c8c21 | 209 | } |
tnhnrl | 57:ec69651c8c21 | 210 | } |
tnhnrl | 57:ec69651c8c21 | 211 | |
tnhnrl | 57:ec69651c8c21 | 212 | //write rudder (servo driver) file rudder.txt |
tnhnrl | 57:ec69651c8c21 | 213 | void ConfigFileIO::saveRudderData(float setMinDeg, float setMaxDeg, float setCenterPWM, float setMinPWM, float setMaxPWM) { |
tnhnrl | 57:ec69651c8c21 | 214 | ConfigFile rudder_txt; |
tnhnrl | 57:ec69651c8c21 | 215 | |
tnhnrl | 57:ec69651c8c21 | 216 | char header[128]; |
tnhnrl | 57:ec69651c8c21 | 217 | sprintf(header,"# rudder (servo) inner loop (heading outer loop uses this)"); |
tnhnrl | 57:ec69651c8c21 | 218 | |
tnhnrl | 57:ec69651c8c21 | 219 | char string_min_deg[128]; |
tnhnrl | 57:ec69651c8c21 | 220 | sprintf(string_min_deg, "%f", setMinDeg); |
tnhnrl | 57:ec69651c8c21 | 221 | rudder_txt.setValue("setMinDeg", string_min_deg); |
tnhnrl | 57:ec69651c8c21 | 222 | |
tnhnrl | 57:ec69651c8c21 | 223 | char string_max_deg[128]; |
tnhnrl | 57:ec69651c8c21 | 224 | sprintf(string_max_deg, "%f", setMaxDeg); |
tnhnrl | 57:ec69651c8c21 | 225 | rudder_txt.setValue("setMaxDeg", string_max_deg); |
tnhnrl | 57:ec69651c8c21 | 226 | |
tnhnrl | 57:ec69651c8c21 | 227 | char string_ctr_pwm[128]; |
tnhnrl | 57:ec69651c8c21 | 228 | sprintf(string_ctr_pwm, "%f", setCenterPWM); |
tnhnrl | 57:ec69651c8c21 | 229 | rudder_txt.setValue("setCenterPWM", string_ctr_pwm); |
tnhnrl | 57:ec69651c8c21 | 230 | |
tnhnrl | 57:ec69651c8c21 | 231 | char string_min_pwm[128]; |
tnhnrl | 57:ec69651c8c21 | 232 | sprintf(string_min_pwm, "%f", setMinPWM); |
tnhnrl | 57:ec69651c8c21 | 233 | rudder_txt.setValue("setMinPWM", string_min_pwm); |
tnhnrl | 57:ec69651c8c21 | 234 | |
tnhnrl | 57:ec69651c8c21 | 235 | char string_max_pwm[128]; |
tnhnrl | 57:ec69651c8c21 | 236 | sprintf(string_max_pwm, "%f", setMaxPWM); |
tnhnrl | 57:ec69651c8c21 | 237 | rudder_txt.setValue("setMaxPWM", string_max_pwm); |
tnhnrl | 57:ec69651c8c21 | 238 | |
tnhnrl | 57:ec69651c8c21 | 239 | //SAVE THE DATA! |
tnhnrl | 74:d281aaef9766 | 240 | xbee().printf("Saving RUDDER DATA!"); |
tnhnrl | 57:ec69651c8c21 | 241 | |
tnhnrl | 57:ec69651c8c21 | 242 | if (!rudder_txt.write("/local/rudder.txt")) { |
tnhnrl | 74:d281aaef9766 | 243 | xbee().printf("\n\rERROR: (SAVE)Failure to write rudder.txt file."); |
tnhnrl | 57:ec69651c8c21 | 244 | } |
tnhnrl | 57:ec69651c8c21 | 245 | else { |
tnhnrl | 74:d281aaef9766 | 246 | xbee().printf("\n\rFile rudder.txt successful written.\n\r"); |
tnhnrl | 57:ec69651c8c21 | 247 | } |
tnhnrl | 57:ec69651c8c21 | 248 | } |
tnhnrl | 57:ec69651c8c21 | 249 | |
tnhnrl | 57:ec69651c8c21 | 250 | int ConfigFileIO::load_BCE_config() { |
tnhnrl | 57:ec69651c8c21 | 251 | ConfigFile cfg; |
tnhnrl | 57:ec69651c8c21 | 252 | int count = 0; |
tnhnrl | 57:ec69651c8c21 | 253 | if (!cfg.read("/local/bce.txt")) { |
tnhnrl | 57:ec69651c8c21 | 254 | error("File Read Error"); |
tnhnrl | 57:ec69651c8c21 | 255 | } |
tnhnrl | 57:ec69651c8c21 | 256 | char value[BUFSIZ]; |
tnhnrl | 57:ec69651c8c21 | 257 | |
tnhnrl | 57:ec69651c8c21 | 258 | if (cfg.getValue("PGain", &value[0] , sizeof(value))) { |
tnhnrl | 57:ec69651c8c21 | 259 | bce().setControllerP(atof(value)); |
tnhnrl | 57:ec69651c8c21 | 260 | count++; |
tnhnrl | 57:ec69651c8c21 | 261 | } |
tnhnrl | 57:ec69651c8c21 | 262 | if (cfg.getValue("IGain", &value[0] ,sizeof(value))) { |
tnhnrl | 57:ec69651c8c21 | 263 | bce().setControllerI(atof(value)); |
tnhnrl | 57:ec69651c8c21 | 264 | count++; |
tnhnrl | 57:ec69651c8c21 | 265 | } |
tnhnrl | 57:ec69651c8c21 | 266 | if (cfg.getValue("DGain", &value[0] , sizeof(value))) { |
tnhnrl | 57:ec69651c8c21 | 267 | bce().setControllerD(atof(value)); |
tnhnrl | 57:ec69651c8c21 | 268 | count++; |
tnhnrl | 57:ec69651c8c21 | 269 | } |
tnhnrl | 57:ec69651c8c21 | 270 | if (cfg.getValue("zeroCounts", &value[0],sizeof(value))) { |
tnhnrl | 57:ec69651c8c21 | 271 | bce().setZeroCounts(atoi(value)); |
tnhnrl | 57:ec69651c8c21 | 272 | count++; |
tnhnrl | 57:ec69651c8c21 | 273 | } |
tnhnrl | 57:ec69651c8c21 | 274 | if (cfg.getValue("PistonTravelLimit", &value[0], sizeof(value))) { |
tnhnrl | 57:ec69651c8c21 | 275 | bce().setTravelLimit(atof(value)); |
tnhnrl | 57:ec69651c8c21 | 276 | count++; |
tnhnrl | 57:ec69651c8c21 | 277 | } |
tnhnrl | 57:ec69651c8c21 | 278 | if (cfg.getValue("slope", &value[0], sizeof(value))) { |
tnhnrl | 57:ec69651c8c21 | 279 | bce().setPotSlope(atof(value)); |
tnhnrl | 57:ec69651c8c21 | 280 | count++; |
tnhnrl | 57:ec69651c8c21 | 281 | } |
tnhnrl | 57:ec69651c8c21 | 282 | if (cfg.getValue("filterWn", &value[0], sizeof(value))) { |
tnhnrl | 57:ec69651c8c21 | 283 | bce().setFilterFrequency(atof(value)); |
tnhnrl | 57:ec69651c8c21 | 284 | count++; |
tnhnrl | 57:ec69651c8c21 | 285 | } |
tnhnrl | 57:ec69651c8c21 | 286 | if (cfg.getValue("deadband", &value[0], sizeof(value))) { |
tnhnrl | 57:ec69651c8c21 | 287 | bce().setDeadband(atof(value)); |
tnhnrl | 57:ec69651c8c21 | 288 | count++; |
tnhnrl | 57:ec69651c8c21 | 289 | } |
tnhnrl | 57:ec69651c8c21 | 290 | |
tnhnrl | 57:ec69651c8c21 | 291 | return count; |
tnhnrl | 57:ec69651c8c21 | 292 | } |
tnhnrl | 57:ec69651c8c21 | 293 | |
tnhnrl | 57:ec69651c8c21 | 294 | //write to heading.txt |
tnhnrl | 73:f6f378311c8d | 295 | void ConfigFileIO::saveHeadingData(float heading_p_gain, float heading_i_gain, float heading_d_gain, float heading_zeroOffset, float heading_filter_freq, float heading_deadband) { |
tnhnrl | 57:ec69651c8c21 | 296 | ConfigFile heading_txt; |
tnhnrl | 57:ec69651c8c21 | 297 | |
tnhnrl | 57:ec69651c8c21 | 298 | char PGain_buffer[128]; |
tnhnrl | 57:ec69651c8c21 | 299 | sprintf(PGain_buffer,"# HEADING (rudder outer loop) parameters\n\n#Gains\nPGain"); |
tnhnrl | 57:ec69651c8c21 | 300 | |
tnhnrl | 57:ec69651c8c21 | 301 | //convert input numbers into text and save them to text file |
tnhnrl | 57:ec69651c8c21 | 302 | char string_pgain[128]; |
tnhnrl | 57:ec69651c8c21 | 303 | sprintf(string_pgain, "%f", heading_p_gain); |
tnhnrl | 57:ec69651c8c21 | 304 | heading_txt.setValue(PGain_buffer, string_pgain); |
tnhnrl | 57:ec69651c8c21 | 305 | |
tnhnrl | 57:ec69651c8c21 | 306 | char string_igain[128]; |
tnhnrl | 57:ec69651c8c21 | 307 | sprintf(string_igain, "%f", heading_i_gain); |
tnhnrl | 57:ec69651c8c21 | 308 | heading_txt.setValue("IGain", string_igain); |
tnhnrl | 57:ec69651c8c21 | 309 | |
tnhnrl | 57:ec69651c8c21 | 310 | char string_dgain[128]; |
tnhnrl | 57:ec69651c8c21 | 311 | sprintf(string_dgain, "%f", heading_d_gain); |
tnhnrl | 57:ec69651c8c21 | 312 | heading_txt.setValue("DGain", string_dgain); |
tnhnrl | 74:d281aaef9766 | 313 | |
tnhnrl | 74:d281aaef9766 | 314 | char string_heading_freq[128]; |
tnhnrl | 74:d281aaef9766 | 315 | sprintf(string_heading_freq, "%f", heading_filter_freq); |
tnhnrl | 74:d281aaef9766 | 316 | heading_txt.setValue("\n# HEADING sensor filter parameters\nfilterWn", string_heading_freq); |
tnhnrl | 74:d281aaef9766 | 317 | |
tnhnrl | 74:d281aaef9766 | 318 | char string_heading_db[128]; |
tnhnrl | 74:d281aaef9766 | 319 | sprintf(string_heading_db, "%f", heading_deadband); |
tnhnrl | 74:d281aaef9766 | 320 | heading_txt.setValue("deadband",string_heading_db); |
tnhnrl | 57:ec69651c8c21 | 321 | |
tnhnrl | 57:ec69651c8c21 | 322 | char string_zeroOffset[128]; |
tnhnrl | 73:f6f378311c8d | 323 | sprintf(string_zeroOffset, "%f", heading_zeroOffset); |
tnhnrl | 74:d281aaef9766 | 324 | heading_txt.setValue("\n#HEADING offset\nzeroOffset", string_zeroOffset); |
tnhnrl | 57:ec69651c8c21 | 325 | |
tnhnrl | 57:ec69651c8c21 | 326 | //SAVE THE DATA! |
tnhnrl | 74:d281aaef9766 | 327 | xbee().printf("(ConfigFileIO) Saving HEADING parameters!"); |
tnhnrl | 57:ec69651c8c21 | 328 | |
tnhnrl | 57:ec69651c8c21 | 329 | if (!heading_txt.write("/local/heading.txt")) { |
tnhnrl | 74:d281aaef9766 | 330 | xbee().printf("\n\rERROR: (SAVE) Failure to write heading.txt file."); |
tnhnrl | 57:ec69651c8c21 | 331 | } |
tnhnrl | 57:ec69651c8c21 | 332 | else { |
tnhnrl | 74:d281aaef9766 | 333 | xbee().printf("\n\rFile heading.txt successful written.\n\r"); |
tnhnrl | 57:ec69651c8c21 | 334 | } |
tnhnrl | 57:ec69651c8c21 | 335 | } |
joel_ssc | 82:0981b9ada820 | 336 | int ConfigFileIO::load_LogVers_config(int print_diag) { // I could copy this mode to read one line of a leg_mission file. One line or multiple lines? |
tnhnrl | 57:ec69651c8c21 | 337 | ConfigFile cfg; |
tnhnrl | 57:ec69651c8c21 | 338 | int count = 0; |
joel_ssc | 82:0981b9ada820 | 339 | int version = 0; |
joel_ssc | 82:0981b9ada820 | 340 | if (!cfg.read("/local/logvers.txt")) { // "/local/leg_mission.txt" |
joel_ssc | 82:0981b9ada820 | 341 | error("Lognames version file logvers.txt File Read Error"); |
joel_ssc | 82:0981b9ada820 | 342 | } |
joel_ssc | 82:0981b9ada820 | 343 | char value[BUFSIZ]; |
joel_ssc | 82:0981b9ada820 | 344 | |
joel_ssc | 82:0981b9ada820 | 345 | |
joel_ssc | 82:0981b9ada820 | 346 | if (cfg.getValue("LogFileVers", &value[0] , sizeof(value))) { |
joel_ssc | 82:0981b9ada820 | 347 | version = atoi(value); |
joel_ssc | 82:0981b9ada820 | 348 | char buf[256]; |
joel_ssc | 82:0981b9ada820 | 349 | sprintf(buf, "LOG%03d.csv", version); |
joel_ssc | 82:0981b9ada820 | 350 | logFilesStruct.logFileName = buf; |
joel_ssc | 82:0981b9ada820 | 351 | logFilesStruct.logversion = version; |
joel_ssc | 82:0981b9ada820 | 352 | count++; |
joel_ssc | 82:0981b9ada820 | 353 | } |
joel_ssc | 82:0981b9ada820 | 354 | if (cfg.getValue("DiagFileVers", &value[0] , sizeof(value))) { |
joel_ssc | 82:0981b9ada820 | 355 | version = atoi(value); |
joel_ssc | 82:0981b9ada820 | 356 | char buf[256]; |
joel_ssc | 82:0981b9ada820 | 357 | |
joel_ssc | 82:0981b9ada820 | 358 | sprintf(buf, "in configfileIO: diag file version number is %d\n", version); |
joel_ssc | 82:0981b9ada820 | 359 | if(print_diag == 1) {mbedLogger().appendDiagFile(buf,3);} |
joel_ssc | 82:0981b9ada820 | 360 | // buf[256]= {0}; |
joel_ssc | 82:0981b9ada820 | 361 | sprintf(buf, "in ConfigFileIO: diag file string is DIAG%03d.txt", version); |
joel_ssc | 82:0981b9ada820 | 362 | if(print_diag == 1) {mbedLogger().appendDiagFile(buf,3);} |
joel_ssc | 82:0981b9ada820 | 363 | // buf[256]= {0}; |
joel_ssc | 82:0981b9ada820 | 364 | sprintf(buf, "DIAG%03d.txt", version); |
joel_ssc | 82:0981b9ada820 | 365 | logFilesStruct.diagFileName = buf; |
joel_ssc | 82:0981b9ada820 | 366 | logFilesStruct.diagversion = version; |
joel_ssc | 82:0981b9ada820 | 367 | sprintf(buf, "in ConfigFileIO: diag info pulled from struct: filename = %s diagvernum = %d\n", logFilesStruct.diagFileName, |
joel_ssc | 82:0981b9ada820 | 368 | logFilesStruct.diagversion); |
joel_ssc | 82:0981b9ada820 | 369 | if(print_diag==1) {mbedLogger().appendDiagFile(buf,3);} |
joel_ssc | 82:0981b9ada820 | 370 | count++; |
joel_ssc | 82:0981b9ada820 | 371 | } |
joel_ssc | 82:0981b9ada820 | 372 | return count; |
joel_ssc | 82:0981b9ada820 | 373 | } |
joel_ssc | 82:0981b9ada820 | 374 | int ConfigFileIO::load_BATT_config() { // I could copy this mode to read one line of a leg_mission file. One line or multiple lines? |
joel_ssc | 82:0981b9ada820 | 375 | ConfigFile cfg; |
joel_ssc | 82:0981b9ada820 | 376 | int count = 0; |
joel_ssc | 82:0981b9ada820 | 377 | if (!cfg.read("/local/batt.txt")) { // "/local/leg_mission.txt" |
tnhnrl | 57:ec69651c8c21 | 378 | error("BATT File Read Error"); |
tnhnrl | 57:ec69651c8c21 | 379 | } |
tnhnrl | 57:ec69651c8c21 | 380 | char value[BUFSIZ]; |
tnhnrl | 57:ec69651c8c21 | 381 | |
tnhnrl | 57:ec69651c8c21 | 382 | |
tnhnrl | 57:ec69651c8c21 | 383 | if (cfg.getValue("PGain", &value[0] , sizeof(value))) { |
joel_ssc | 82:0981b9ada820 | 384 | batt().setControllerP(atof(value)); // but I want values in a legStructLoaded, not a function |
tnhnrl | 57:ec69651c8c21 | 385 | count++; |
tnhnrl | 57:ec69651c8c21 | 386 | } |
tnhnrl | 57:ec69651c8c21 | 387 | if (cfg.getValue("IGain", &value[0] ,sizeof(value))) { |
tnhnrl | 57:ec69651c8c21 | 388 | batt().setControllerI(atof(value)); |
tnhnrl | 57:ec69651c8c21 | 389 | count++; |
tnhnrl | 57:ec69651c8c21 | 390 | } |
tnhnrl | 57:ec69651c8c21 | 391 | if (cfg.getValue("DGain", &value[0] , sizeof(value))) { |
tnhnrl | 57:ec69651c8c21 | 392 | batt().setControllerD(atof(value)); |
tnhnrl | 57:ec69651c8c21 | 393 | count++; |
tnhnrl | 57:ec69651c8c21 | 394 | } |
tnhnrl | 57:ec69651c8c21 | 395 | if (cfg.getValue("zeroCounts", &value[0],sizeof(value))) { |
tnhnrl | 57:ec69651c8c21 | 396 | batt().setZeroCounts(atoi(value)); |
tnhnrl | 57:ec69651c8c21 | 397 | count++; |
tnhnrl | 57:ec69651c8c21 | 398 | } |
tnhnrl | 57:ec69651c8c21 | 399 | if (cfg.getValue("PistonTravelLimit", &value[0], sizeof(value))) { |
tnhnrl | 57:ec69651c8c21 | 400 | batt().setTravelLimit(atof(value)); |
tnhnrl | 57:ec69651c8c21 | 401 | count++; |
tnhnrl | 57:ec69651c8c21 | 402 | } |
tnhnrl | 57:ec69651c8c21 | 403 | if (cfg.getValue("slope", &value[0], sizeof(value))) { |
tnhnrl | 57:ec69651c8c21 | 404 | batt().setPotSlope(atof(value)); |
tnhnrl | 57:ec69651c8c21 | 405 | count++; |
tnhnrl | 57:ec69651c8c21 | 406 | } |
tnhnrl | 57:ec69651c8c21 | 407 | if (cfg.getValue("filterWn", &value[0], sizeof(value))) { |
tnhnrl | 57:ec69651c8c21 | 408 | batt().setFilterFrequency(atof(value)); |
tnhnrl | 57:ec69651c8c21 | 409 | count++; |
tnhnrl | 57:ec69651c8c21 | 410 | } |
tnhnrl | 57:ec69651c8c21 | 411 | if (cfg.getValue("deadband", &value[0], sizeof(value))) { |
tnhnrl | 57:ec69651c8c21 | 412 | batt().setDeadband(atof(value)); |
tnhnrl | 57:ec69651c8c21 | 413 | count++; |
tnhnrl | 57:ec69651c8c21 | 414 | } |
tnhnrl | 57:ec69651c8c21 | 415 | |
tnhnrl | 57:ec69651c8c21 | 416 | return count; |
tnhnrl | 57:ec69651c8c21 | 417 | } |
tnhnrl | 57:ec69651c8c21 | 418 | |
tnhnrl | 57:ec69651c8c21 | 419 | int ConfigFileIO::load_DEPTH_config() { |
tnhnrl | 57:ec69651c8c21 | 420 | ConfigFile cfg; |
tnhnrl | 57:ec69651c8c21 | 421 | int count = 0; |
tnhnrl | 57:ec69651c8c21 | 422 | if (!cfg.read("/local/depth.txt")) { |
tnhnrl | 57:ec69651c8c21 | 423 | error("DEPTH File Read Error"); |
tnhnrl | 57:ec69651c8c21 | 424 | } |
tnhnrl | 57:ec69651c8c21 | 425 | char value[BUFSIZ]; |
tnhnrl | 57:ec69651c8c21 | 426 | |
tnhnrl | 57:ec69651c8c21 | 427 | if (cfg.getValue("PGain", &value[0] , sizeof(value))) { |
tnhnrl | 57:ec69651c8c21 | 428 | depthLoop().setControllerP(atof(value)); |
tnhnrl | 57:ec69651c8c21 | 429 | count++; |
tnhnrl | 57:ec69651c8c21 | 430 | } |
tnhnrl | 57:ec69651c8c21 | 431 | if (cfg.getValue("IGain", &value[0] ,sizeof(value))) { |
tnhnrl | 57:ec69651c8c21 | 432 | depthLoop().setControllerI(atof(value)); |
tnhnrl | 57:ec69651c8c21 | 433 | count++; |
tnhnrl | 57:ec69651c8c21 | 434 | } |
tnhnrl | 57:ec69651c8c21 | 435 | if (cfg.getValue("DGain", &value[0] , sizeof(value))) { |
tnhnrl | 57:ec69651c8c21 | 436 | depthLoop().setControllerD(atof(value)); |
tnhnrl | 57:ec69651c8c21 | 437 | count++; |
tnhnrl | 57:ec69651c8c21 | 438 | } |
tnhnrl | 57:ec69651c8c21 | 439 | if (cfg.getValue("filterWn", &value[0], sizeof(value))) { |
tnhnrl | 57:ec69651c8c21 | 440 | depthLoop().setFilterFrequency(atof(value)); |
tnhnrl | 57:ec69651c8c21 | 441 | count++; |
tnhnrl | 57:ec69651c8c21 | 442 | } |
tnhnrl | 57:ec69651c8c21 | 443 | if (cfg.getValue("deadband", &value[0], sizeof(value))) { |
tnhnrl | 57:ec69651c8c21 | 444 | depthLoop().setDeadband(atof(value)); |
tnhnrl | 57:ec69651c8c21 | 445 | count++; |
tnhnrl | 57:ec69651c8c21 | 446 | } |
tnhnrl | 57:ec69651c8c21 | 447 | if (cfg.getValue("zeroOffset", &value[0], sizeof(value))) { |
tnhnrl | 57:ec69651c8c21 | 448 | depthLoop().setOutputOffset(atof(value)); |
tnhnrl | 57:ec69651c8c21 | 449 | count++; |
tnhnrl | 57:ec69651c8c21 | 450 | } |
tnhnrl | 57:ec69651c8c21 | 451 | return count; |
tnhnrl | 57:ec69651c8c21 | 452 | } |
tnhnrl | 57:ec69651c8c21 | 453 | |
tnhnrl | 57:ec69651c8c21 | 454 | int ConfigFileIO::load_PITCH_config() { |
tnhnrl | 57:ec69651c8c21 | 455 | ConfigFile cfg; |
tnhnrl | 57:ec69651c8c21 | 456 | int count = 0; |
tnhnrl | 57:ec69651c8c21 | 457 | if (!cfg.read("/local/pitch.txt")){ |
tnhnrl | 57:ec69651c8c21 | 458 | error("PITCH File Read Error"); |
tnhnrl | 57:ec69651c8c21 | 459 | } |
tnhnrl | 57:ec69651c8c21 | 460 | char value[BUFSIZ]; |
tnhnrl | 57:ec69651c8c21 | 461 | |
tnhnrl | 57:ec69651c8c21 | 462 | if (cfg.getValue("PGain", &value[0] , sizeof(value))) { |
tnhnrl | 57:ec69651c8c21 | 463 | pitchLoop().setControllerP(atof(value)); |
tnhnrl | 57:ec69651c8c21 | 464 | count++; |
tnhnrl | 57:ec69651c8c21 | 465 | } |
tnhnrl | 57:ec69651c8c21 | 466 | if (cfg.getValue("IGain", &value[0] ,sizeof(value))) { |
tnhnrl | 57:ec69651c8c21 | 467 | pitchLoop().setControllerI(atof(value)); |
tnhnrl | 57:ec69651c8c21 | 468 | count++; |
tnhnrl | 57:ec69651c8c21 | 469 | } |
tnhnrl | 57:ec69651c8c21 | 470 | if (cfg.getValue("DGain", &value[0] , sizeof(value))) { |
tnhnrl | 57:ec69651c8c21 | 471 | pitchLoop().setControllerD(atof(value)); |
tnhnrl | 57:ec69651c8c21 | 472 | count++; |
tnhnrl | 57:ec69651c8c21 | 473 | } |
tnhnrl | 57:ec69651c8c21 | 474 | if (cfg.getValue("filterWn", &value[0], sizeof(value))) { |
tnhnrl | 57:ec69651c8c21 | 475 | pitchLoop().setFilterFrequency(atof(value)); |
tnhnrl | 57:ec69651c8c21 | 476 | count++; |
tnhnrl | 57:ec69651c8c21 | 477 | } |
tnhnrl | 57:ec69651c8c21 | 478 | if (cfg.getValue("deadband", &value[0], sizeof(value))) { |
tnhnrl | 57:ec69651c8c21 | 479 | pitchLoop().setDeadband(atof(value)); |
tnhnrl | 57:ec69651c8c21 | 480 | count++; |
tnhnrl | 57:ec69651c8c21 | 481 | } |
tnhnrl | 57:ec69651c8c21 | 482 | |
tnhnrl | 57:ec69651c8c21 | 483 | if (cfg.getValue("zeroOffset", &value[0], sizeof(value))) { |
tnhnrl | 57:ec69651c8c21 | 484 | pitchLoop().setOutputOffset(atof(value)); |
tnhnrl | 57:ec69651c8c21 | 485 | count++; |
tnhnrl | 57:ec69651c8c21 | 486 | } |
tnhnrl | 57:ec69651c8c21 | 487 | return count; |
tnhnrl | 57:ec69651c8c21 | 488 | } |
tnhnrl | 57:ec69651c8c21 | 489 | |
tnhnrl | 57:ec69651c8c21 | 490 | int ConfigFileIO::load_HEADING_config() { |
tnhnrl | 57:ec69651c8c21 | 491 | ConfigFile cfg; |
tnhnrl | 57:ec69651c8c21 | 492 | int count = 0; |
tnhnrl | 57:ec69651c8c21 | 493 | if (!cfg.read("/local/heading.txt")){ |
tnhnrl | 57:ec69651c8c21 | 494 | error("HEADING File Read Error"); |
tnhnrl | 57:ec69651c8c21 | 495 | } |
tnhnrl | 57:ec69651c8c21 | 496 | char value[BUFSIZ]; |
tnhnrl | 57:ec69651c8c21 | 497 | |
tnhnrl | 57:ec69651c8c21 | 498 | if (cfg.getValue("PGain", &value[0] , sizeof(value))) { |
tnhnrl | 57:ec69651c8c21 | 499 | headingLoop().setControllerP(atof(value)); |
tnhnrl | 57:ec69651c8c21 | 500 | count++; |
tnhnrl | 57:ec69651c8c21 | 501 | } |
tnhnrl | 57:ec69651c8c21 | 502 | if (cfg.getValue("IGain", &value[0] ,sizeof(value))) { |
tnhnrl | 57:ec69651c8c21 | 503 | headingLoop().setControllerI(atof(value)); |
tnhnrl | 57:ec69651c8c21 | 504 | count++; |
tnhnrl | 57:ec69651c8c21 | 505 | } |
tnhnrl | 57:ec69651c8c21 | 506 | if (cfg.getValue("DGain", &value[0] , sizeof(value))) { |
tnhnrl | 57:ec69651c8c21 | 507 | headingLoop().setControllerD(atof(value)); |
tnhnrl | 57:ec69651c8c21 | 508 | count++; |
tnhnrl | 57:ec69651c8c21 | 509 | } |
tnhnrl | 57:ec69651c8c21 | 510 | if (cfg.getValue("filterWn", &value[0], sizeof(value))) { |
tnhnrl | 57:ec69651c8c21 | 511 | headingLoop().setFilterFrequency(atof(value)); |
tnhnrl | 57:ec69651c8c21 | 512 | count++; |
tnhnrl | 57:ec69651c8c21 | 513 | } |
tnhnrl | 57:ec69651c8c21 | 514 | if (cfg.getValue("deadband", &value[0], sizeof(value))) { |
tnhnrl | 57:ec69651c8c21 | 515 | headingLoop().setDeadband(atof(value)); |
tnhnrl | 57:ec69651c8c21 | 516 | count++; |
tnhnrl | 57:ec69651c8c21 | 517 | } |
tnhnrl | 57:ec69651c8c21 | 518 | |
tnhnrl | 57:ec69651c8c21 | 519 | if (cfg.getValue("zeroOffset", &value[0], sizeof(value))) { |
tnhnrl | 57:ec69651c8c21 | 520 | headingLoop().setOutputOffset(atof(value)); |
tnhnrl | 57:ec69651c8c21 | 521 | count++; |
tnhnrl | 57:ec69651c8c21 | 522 | } |
tnhnrl | 57:ec69651c8c21 | 523 | return count; |
tnhnrl | 57:ec69651c8c21 | 524 | } |
tnhnrl | 57:ec69651c8c21 | 525 | |
tnhnrl | 57:ec69651c8c21 | 526 | int ConfigFileIO::load_RUDDER_config() { |
tnhnrl | 57:ec69651c8c21 | 527 | ConfigFile cfg; |
tnhnrl | 57:ec69651c8c21 | 528 | int count = 0; |
tnhnrl | 57:ec69651c8c21 | 529 | if (!cfg.read("/local/rudder.txt")){ |
tnhnrl | 57:ec69651c8c21 | 530 | error("RUDDER File Read Error"); |
tnhnrl | 57:ec69651c8c21 | 531 | } |
tnhnrl | 57:ec69651c8c21 | 532 | char value[BUFSIZ]; |
tnhnrl | 57:ec69651c8c21 | 533 | |
tnhnrl | 57:ec69651c8c21 | 534 | //float values below |
tnhnrl | 57:ec69651c8c21 | 535 | if (cfg.getValue("setMinDeg", &value[0] , sizeof(value))) { |
tnhnrl | 57:ec69651c8c21 | 536 | rudder().setMinDeg(atof(value)); |
tnhnrl | 57:ec69651c8c21 | 537 | count++; |
tnhnrl | 57:ec69651c8c21 | 538 | } |
tnhnrl | 57:ec69651c8c21 | 539 | if (cfg.getValue("setMaxDeg", &value[0] ,sizeof(value))) { |
tnhnrl | 57:ec69651c8c21 | 540 | rudder().setMaxDeg(atof(value)); |
tnhnrl | 57:ec69651c8c21 | 541 | count++; |
tnhnrl | 57:ec69651c8c21 | 542 | } |
tnhnrl | 57:ec69651c8c21 | 543 | |
tnhnrl | 57:ec69651c8c21 | 544 | //integer values below |
tnhnrl | 57:ec69651c8c21 | 545 | if (cfg.getValue("setCenterPWM", &value[0] , sizeof(value))) { |
tnhnrl | 57:ec69651c8c21 | 546 | rudder().setCenterPWM(atof(value)); |
tnhnrl | 57:ec69651c8c21 | 547 | count++; |
tnhnrl | 57:ec69651c8c21 | 548 | } |
tnhnrl | 57:ec69651c8c21 | 549 | if (cfg.getValue("setMinPWM", &value[0], sizeof(value))) { |
tnhnrl | 57:ec69651c8c21 | 550 | rudder().setMinPWM(atof(value)); |
tnhnrl | 57:ec69651c8c21 | 551 | count++; |
tnhnrl | 57:ec69651c8c21 | 552 | } |
tnhnrl | 57:ec69651c8c21 | 553 | if (cfg.getValue("setMaxPWM", &value[0], sizeof(value))) { |
tnhnrl | 57:ec69651c8c21 | 554 | rudder().setMaxPWM(atof(value)); |
tnhnrl | 57:ec69651c8c21 | 555 | count++; |
tnhnrl | 57:ec69651c8c21 | 556 | } |
tnhnrl | 57:ec69651c8c21 | 557 | return count; |
tnhnrl | 57:ec69651c8c21 | 558 | } |