Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
main.cpp@20:c728b8ffad97, 2015-02-27 (annotated)
- Committer:
- bbbobbbieo
- Date:
- Fri Feb 27 17:10:15 2015 +0000
- Revision:
- 20:c728b8ffad97
- Parent:
- 19:85eb7991e2ab
- Child:
- 21:df5a530208eb
- Child:
- 23:fe15b6147c1b
best guess now based more on history than current... like a prediction?
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| bbbobbbieo | 3:c7caa058fc50 | 1 | //#include "mbed.h" |
| bbbobbbieo | 1:21d40d90b2f0 | 2 | #include "TFC.h" |
| bbbobbbieo | 0:d57117b2188d | 3 | |
| bbbobbbieo | 0:d57117b2188d | 4 | DigitalOut myled(LED1); |
| bbbobbbieo | 0:d57117b2188d | 5 | |
| bbbobbbieo | 14:f43b386b8b5d | 6 | int main() |
| bbbobbbieo | 1:21d40d90b2f0 | 7 | { |
| bbbobbbieo | 7:455e7dd338ee | 8 | //run this before anything |
| bbbobbbieo | 2:d8a51492b646 | 9 | TFC_Init(); |
| bbbobbbieo | 14:f43b386b8b5d | 10 | |
| bbbobbbieo | 7:455e7dd338ee | 11 | //variables |
| bbbobbbieo | 4:7584ff0426f1 | 12 | float current_servo_position = 0; |
| bbbobbbieo | 6:44d1079f076c | 13 | float current_left_motor_speed = 0; |
| bbbobbbieo | 6:44d1079f076c | 14 | float current_right_motor_speed = 0; |
| mperella | 17:c643b6b4a96f | 15 | |
| mperella | 17:c643b6b4a96f | 16 | float dt = 0.00001; |
| mperella | 17:c643b6b4a96f | 17 | float integral = 0; |
| mperella | 17:c643b6b4a96f | 18 | float derivative = 0; |
| mperella | 17:c643b6b4a96f | 19 | float output = 0; |
| mperella | 17:c643b6b4a96f | 20 | |
| mperella | 17:c643b6b4a96f | 21 | // gains on prop, int, der |
| mperella | 17:c643b6b4a96f | 22 | // subject to change, need to fine tune |
| mperella | 17:c643b6b4a96f | 23 | float kp = 1.8960; |
| mperella | 17:c643b6b4a96f | 24 | float ki = 0.6170; |
| mperella | 17:c643b6b4a96f | 25 | float kd = 1.5590; |
| mperella | 17:c643b6b4a96f | 26 | |
| bbbobbbieo | 6:44d1079f076c | 27 | bool rear_motor_enable_flag = true; |
| bbbobbbieo | 7:455e7dd338ee | 28 | bool linescan_ping_pong = false; |
| bbbobbbieo | 9:2b028ee421ad | 29 | bool linescan_enable = true; |
| bbbobbbieo | 14:f43b386b8b5d | 30 | |
| bbbobbbieo | 11:d65d6d7fc85e | 31 | int black_values_list[128]; |
| bbbobbbieo | 11:d65d6d7fc85e | 32 | int black_value_count = 0; |
| bbbobbbieo | 11:d65d6d7fc85e | 33 | int black_center_value = 0; |
| bbbobbbieo | 11:d65d6d7fc85e | 34 | int sum_black = 0; |
| bbbobbbieo | 14:f43b386b8b5d | 35 | int violence_level = 0; |
| bbbobbbieo | 15:830209e846d5 | 36 | |
| bbbobbbieo | 20:c728b8ffad97 | 37 | int center_now = 64; |
| bbbobbbieo | 20:c728b8ffad97 | 38 | int center_past_1 = 64; |
| bbbobbbieo | 20:c728b8ffad97 | 39 | int center_past_2 = 64; |
| bbbobbbieo | 20:c728b8ffad97 | 40 | int center_past_3 = 64; |
| bbbobbbieo | 20:c728b8ffad97 | 41 | int center_past_4 = 64; |
| bbbobbbieo | 20:c728b8ffad97 | 42 | //int best_guess_center = 64; |
| bbbobbbieo | 20:c728b8ffad97 | 43 | |
| mperella | 17:c643b6b4a96f | 44 | int set_point = 64; |
| bbbobbbieo | 19:85eb7991e2ab | 45 | int previous_error = 0; |
| mperella | 17:c643b6b4a96f | 46 | int error = 0; |
| mperella | 17:c643b6b4a96f | 47 | |
| mperella | 17:c643b6b4a96f | 48 | |
| bbbobbbieo | 9:2b028ee421ad | 49 | //uint16_t MyImage0Buffer[2][128]; |
| bbbobbbieo | 9:2b028ee421ad | 50 | //uint16_t MyImage1Buffer[2][128]; |
| bbbobbbieo | 14:f43b386b8b5d | 51 | |
| bbbobbbieo | 7:455e7dd338ee | 52 | // major loop |
| bbbobbbieo | 14:f43b386b8b5d | 53 | while(1) { |
| bbbobbbieo | 14:f43b386b8b5d | 54 | |
| bbbobbbieo | 15:830209e846d5 | 55 | // manual servo control, unused |
| bbbobbbieo | 14:f43b386b8b5d | 56 | if (TFC_ReadPushButton(0) != 0 ) { |
| bbbobbbieo | 14:f43b386b8b5d | 57 | current_servo_position = current_servo_position-.005; |
| bbbobbbieo | 14:f43b386b8b5d | 58 | if(current_servo_position <= -0.4) |
| bbbobbbieo | 14:f43b386b8b5d | 59 | current_servo_position = -0.4; |
| bbbobbbieo | 14:f43b386b8b5d | 60 | TFC_SetServo(0, current_servo_position); |
| bbbobbbieo | 14:f43b386b8b5d | 61 | }// end check button0 |
| bbbobbbieo | 14:f43b386b8b5d | 62 | |
| bbbobbbieo | 15:830209e846d5 | 63 | else {} |
| bbbobbbieo | 14:f43b386b8b5d | 64 | |
| bbbobbbieo | 15:830209e846d5 | 65 | // manual servo control, unused |
| bbbobbbieo | 14:f43b386b8b5d | 66 | if (TFC_ReadPushButton(1) != 0 ) { |
| bbbobbbieo | 14:f43b386b8b5d | 67 | current_servo_position = current_servo_position+.005; |
| bbbobbbieo | 14:f43b386b8b5d | 68 | if(current_servo_position >= 0.4) |
| bbbobbbieo | 14:f43b386b8b5d | 69 | current_servo_position = 0.4; |
| bbbobbbieo | 14:f43b386b8b5d | 70 | TFC_SetServo(0, current_servo_position); |
| bbbobbbieo | 14:f43b386b8b5d | 71 | }// end check button1 |
| bbbobbbieo | 14:f43b386b8b5d | 72 | |
| bbbobbbieo | 15:830209e846d5 | 73 | else {} |
| bbbobbbieo | 14:f43b386b8b5d | 74 | |
| bbbobbbieo | 15:830209e846d5 | 75 | // initial motor stuff |
| bbbobbbieo | 14:f43b386b8b5d | 76 | if(rear_motor_enable_flag) { |
| bbbobbbieo | 14:f43b386b8b5d | 77 | TFC_HBRIDGE_ENABLE; |
| bbbobbbieo | 14:f43b386b8b5d | 78 | |
| bbbobbbieo | 15:830209e846d5 | 79 | //current_left_motor_speed = (TFC_ReadPot(0)); |
| bbbobbbieo | 15:830209e846d5 | 80 | //current_right_motor_speed = (TFC_ReadPot(1)); |
| bbbobbbieo | 14:f43b386b8b5d | 81 | |
| bbbobbbieo | 15:830209e846d5 | 82 | // checking behavior level |
| bbbobbbieo | 14:f43b386b8b5d | 83 | violence_level = int(TFC_GetDIP_Switch()); |
| bbbobbbieo | 14:f43b386b8b5d | 84 | |
| bbbobbbieo | 15:830209e846d5 | 85 | if (violence_level==2) { |
| bbbobbbieo | 16:11ba5d6f42ba | 86 | current_left_motor_speed = -.48; |
| bbbobbbieo | 16:11ba5d6f42ba | 87 | current_right_motor_speed = .48; |
| bbbobbbieo | 15:830209e846d5 | 88 | } |
| bbbobbbieo | 15:830209e846d5 | 89 | else if (violence_level==1) { |
| bbbobbbieo | 16:11ba5d6f42ba | 90 | current_left_motor_speed = -.35; |
| bbbobbbieo | 16:11ba5d6f42ba | 91 | current_right_motor_speed = .35; |
| bbbobbbieo | 14:f43b386b8b5d | 92 | } |
| bbbobbbieo | 15:830209e846d5 | 93 | else if (violence_level==0) { |
| bbbobbbieo | 15:830209e846d5 | 94 | current_left_motor_speed = 0; |
| bbbobbbieo | 15:830209e846d5 | 95 | current_right_motor_speed = 0; |
| bbbobbbieo | 15:830209e846d5 | 96 | } |
| bbbobbbieo | 15:830209e846d5 | 97 | else { |
| bbbobbbieo | 15:830209e846d5 | 98 | current_left_motor_speed = 0; |
| bbbobbbieo | 15:830209e846d5 | 99 | current_right_motor_speed = 0; |
| bbbobbbieo | 15:830209e846d5 | 100 | } |
| bbbobbbieo | 15:830209e846d5 | 101 | |
| bbbobbbieo | 14:f43b386b8b5d | 102 | |
| bbbobbbieo | 15:830209e846d5 | 103 | // protection block |
| bbbobbbieo | 15:830209e846d5 | 104 | if(current_left_motor_speed >= 0.5) |
| bbbobbbieo | 15:830209e846d5 | 105 | current_left_motor_speed= 0.5; |
| bbbobbbieo | 15:830209e846d5 | 106 | if(current_right_motor_speed >= 0.5) |
| bbbobbbieo | 15:830209e846d5 | 107 | current_right_motor_speed= 0.5; |
| bbbobbbieo | 15:830209e846d5 | 108 | if(current_left_motor_speed <= -0.5) |
| bbbobbbieo | 15:830209e846d5 | 109 | current_left_motor_speed= -0.5; |
| bbbobbbieo | 15:830209e846d5 | 110 | if(current_right_motor_speed <= -0.5) |
| bbbobbbieo | 15:830209e846d5 | 111 | current_right_motor_speed= -0.5; |
| bbbobbbieo | 14:f43b386b8b5d | 112 | |
| bbbobbbieo | 14:f43b386b8b5d | 113 | TFC_SetMotorPWM(current_left_motor_speed, current_right_motor_speed); |
| bbbobbbieo | 14:f43b386b8b5d | 114 | }// end motor enabled |
| bbbobbbieo | 14:f43b386b8b5d | 115 | else { |
| bbbobbbieo | 14:f43b386b8b5d | 116 | TFC_HBRIDGE_DISABLE; |
| bbbobbbieo | 14:f43b386b8b5d | 117 | }// end motor disabled |
| bbbobbbieo | 14:f43b386b8b5d | 118 | |
| bbbobbbieo | 15:830209e846d5 | 119 | // camera stuff |
| bbbobbbieo | 14:f43b386b8b5d | 120 | if (linescan_enable) { |
| bbbobbbieo | 14:f43b386b8b5d | 121 | if (TFC_LineScanImageReady !=0) { |
| bbbobbbieo | 14:f43b386b8b5d | 122 | |
| bbbobbbieo | 15:830209e846d5 | 123 | if (linescan_ping_pong) { |
| bbbobbbieo | 15:830209e846d5 | 124 | //checking channel 0 |
| bbbobbbieo | 15:830209e846d5 | 125 | |
| bbbobbbieo | 15:830209e846d5 | 126 | //checking center pixel, displays aprox value on leds |
| bbbobbbieo | 14:f43b386b8b5d | 127 | uint8_t shitnum = 1; |
| bbbobbbieo | 14:f43b386b8b5d | 128 | if (*(TFC_LineScanImage0+64) > 800) |
| bbbobbbieo | 14:f43b386b8b5d | 129 | shitnum = 15; |
| bbbobbbieo | 14:f43b386b8b5d | 130 | else if((*(TFC_LineScanImage0+64) > 450)) |
| bbbobbbieo | 14:f43b386b8b5d | 131 | shitnum = 7; |
| bbbobbbieo | 14:f43b386b8b5d | 132 | else if((*(TFC_LineScanImage0+64) > 400)) |
| bbbobbbieo | 14:f43b386b8b5d | 133 | shitnum = 3; |
| bbbobbbieo | 14:f43b386b8b5d | 134 | else |
| bbbobbbieo | 14:f43b386b8b5d | 135 | shitnum = 1; |
| bbbobbbieo | 14:f43b386b8b5d | 136 | TFC_SetBatteryLED(shitnum); |
| bbbobbbieo | 14:f43b386b8b5d | 137 | |
| bbbobbbieo | 15:830209e846d5 | 138 | |
| bbbobbbieo | 15:830209e846d5 | 139 | // checking for center line (single line) |
| bbbobbbieo | 14:f43b386b8b5d | 140 | for (uint16_t i=0; i<128; i++) { |
| bbbobbbieo | 14:f43b386b8b5d | 141 | if ((*(TFC_LineScanImage0+i) < 300)) { |
| bbbobbbieo | 14:f43b386b8b5d | 142 | black_values_list[black_value_count] = i; |
| bbbobbbieo | 14:f43b386b8b5d | 143 | black_value_count++; |
| bbbobbbieo | 14:f43b386b8b5d | 144 | } |
| bbbobbbieo | 14:f43b386b8b5d | 145 | } |
| bbbobbbieo | 14:f43b386b8b5d | 146 | |
| bbbobbbieo | 14:f43b386b8b5d | 147 | for(int i=0; i<black_value_count; i++) { |
| bbbobbbieo | 14:f43b386b8b5d | 148 | sum_black += black_values_list[i]; |
| bbbobbbieo | 14:f43b386b8b5d | 149 | } |
| bbbobbbieo | 14:f43b386b8b5d | 150 | |
| bbbobbbieo | 20:c728b8ffad97 | 151 | //update history |
| bbbobbbieo | 20:c728b8ffad97 | 152 | center_past_4= center_past_3; |
| bbbobbbieo | 20:c728b8ffad97 | 153 | center_past_3= center_past_2; |
| bbbobbbieo | 20:c728b8ffad97 | 154 | center_past_2= center_past_1; |
| bbbobbbieo | 20:c728b8ffad97 | 155 | center_past_1= center_now; |
| bbbobbbieo | 20:c728b8ffad97 | 156 | |
| bbbobbbieo | 15:830209e846d5 | 157 | // value of center of black (single line) |
| bbbobbbieo | 20:c728b8ffad97 | 158 | //black_center_value = sum_black / black_value_count; |
| bbbobbbieo | 20:c728b8ffad97 | 159 | center_now = sum_black / black_value_count; |
| bbbobbbieo | 20:c728b8ffad97 | 160 | |
| bbbobbbieo | 20:c728b8ffad97 | 161 | // best guess of center based on weighted average of history |
| bbbobbbieo | 20:c728b8ffad97 | 162 | black_center_value = (5*center_now + 10*center_past_1 + 15*center_past_2 +30*center_past_3 +40*center_past_4)/100; |
| bbbobbbieo | 15:830209e846d5 | 163 | |
| mperella | 17:c643b6b4a96f | 164 | /* ******* PID ALGORITHM ******* |
| mperella | 17:c643b6b4a96f | 165 | |
| mperella | 17:c643b6b4a96f | 166 | error = set_point - black_center_value; |
| mperella | 17:c643b6b4a96f | 167 | integral = integral + error*dt; |
| mperella | 17:c643b6b4a96f | 168 | derivative = (error - previous_error)/dt; |
| mperella | 17:c643b6b4a96f | 169 | output = kp*error + ki*integral + kd*derivative; |
| mperella | 17:c643b6b4a96f | 170 | previous error = error; |
| mperella | 17:c643b6b4a96f | 171 | |
| mperella | 17:c643b6b4a96f | 172 | GOTTA DO SOME TESTS/SIMULATIONS TO CALIBRATE SERVO ADJUSTMENTS |
| mperella | 17:c643b6b4a96f | 173 | |
| mperella | 17:c643b6b4a96f | 174 | |
| mperella | 17:c643b6b4a96f | 175 | ***************************** |
| mperella | 17:c643b6b4a96f | 176 | */ |
| bbbobbbieo | 14:f43b386b8b5d | 177 | |
| bbbobbbieo | 15:830209e846d5 | 178 | // need to turn left |
| bbbobbbieo | 15:830209e846d5 | 179 | if (black_center_value < 64) { |
| bbbobbbieo | 15:830209e846d5 | 180 | |
| bbbobbbieo | 16:11ba5d6f42ba | 181 | current_servo_position= float(.01875*black_center_value-(1.2)); |
| bbbobbbieo | 14:f43b386b8b5d | 182 | if(current_servo_position <= -0.4) |
| bbbobbbieo | 14:f43b386b8b5d | 183 | current_servo_position = -0.4; |
| bbbobbbieo | 14:f43b386b8b5d | 184 | TFC_SetServo(0, current_servo_position); |
| bbbobbbieo | 15:830209e846d5 | 185 | |
| bbbobbbieo | 15:830209e846d5 | 186 | |
| bbbobbbieo | 16:11ba5d6f42ba | 187 | //current_left_motor_speed = current_left_motor_speed + float(64-black_center_value)*.0025; |
| bbbobbbieo | 16:11ba5d6f42ba | 188 | //current_right_motor_speed = current_right_motor_speed + float(64-black_center_value)*.0025; |
| bbbobbbieo | 16:11ba5d6f42ba | 189 | if (violence_level !=0){ |
| bbbobbbieo | 19:85eb7991e2ab | 190 | current_left_motor_speed = current_left_motor_speed + float(float(64-black_center_value)*.025);// kinda reverse this... |
| bbbobbbieo | 16:11ba5d6f42ba | 191 | current_right_motor_speed = current_right_motor_speed + float(float(64-black_center_value)*.045);// push more forwards |
| bbbobbbieo | 16:11ba5d6f42ba | 192 | } |
| bbbobbbieo | 16:11ba5d6f42ba | 193 | |
| bbbobbbieo | 16:11ba5d6f42ba | 194 | // protection block |
| bbbobbbieo | 16:11ba5d6f42ba | 195 | if(current_left_motor_speed >= 0.5) |
| bbbobbbieo | 16:11ba5d6f42ba | 196 | current_left_motor_speed= 0.5; |
| bbbobbbieo | 16:11ba5d6f42ba | 197 | if(current_right_motor_speed >= 0.5) |
| bbbobbbieo | 16:11ba5d6f42ba | 198 | current_right_motor_speed= 0.5; |
| bbbobbbieo | 16:11ba5d6f42ba | 199 | if(current_left_motor_speed <= -0.5) |
| bbbobbbieo | 16:11ba5d6f42ba | 200 | current_left_motor_speed= -0.5; |
| bbbobbbieo | 16:11ba5d6f42ba | 201 | if(current_right_motor_speed <= -0.5) |
| bbbobbbieo | 16:11ba5d6f42ba | 202 | current_right_motor_speed= -0.5; |
| bbbobbbieo | 16:11ba5d6f42ba | 203 | |
| bbbobbbieo | 14:f43b386b8b5d | 204 | TFC_SetMotorPWM(current_left_motor_speed, current_right_motor_speed); |
| bbbobbbieo | 14:f43b386b8b5d | 205 | |
| bbbobbbieo | 7:455e7dd338ee | 206 | } |
| bbbobbbieo | 14:f43b386b8b5d | 207 | |
| bbbobbbieo | 15:830209e846d5 | 208 | // need to turn right |
| bbbobbbieo | 14:f43b386b8b5d | 209 | if (black_center_value > 64) { |
| bbbobbbieo | 14:f43b386b8b5d | 210 | |
| bbbobbbieo | 16:11ba5d6f42ba | 211 | current_servo_position= float(.01875*black_center_value-(1.2)); |
| bbbobbbieo | 14:f43b386b8b5d | 212 | if( current_servo_position >= +0.4) |
| bbbobbbieo | 14:f43b386b8b5d | 213 | current_servo_position = +0.4; |
| bbbobbbieo | 14:f43b386b8b5d | 214 | TFC_SetServo(0, current_servo_position); |
| bbbobbbieo | 15:830209e846d5 | 215 | |
| bbbobbbieo | 16:11ba5d6f42ba | 216 | //current_left_motor_speed = current_left_motor_speed - float(black_center_value-64)*.0025; |
| bbbobbbieo | 16:11ba5d6f42ba | 217 | //current_right_motor_speed = current_right_motor_speed - float(black_center_value-64)*.0025; |
| bbbobbbieo | 16:11ba5d6f42ba | 218 | if (violence_level !=0){ |
| bbbobbbieo | 16:11ba5d6f42ba | 219 | current_left_motor_speed = current_left_motor_speed - float(float(black_center_value-64)*.045);// push more forwards |
| bbbobbbieo | 19:85eb7991e2ab | 220 | current_right_motor_speed = current_right_motor_speed - float(float(black_center_value-64)*.025);// kinda reverse this... |
| bbbobbbieo | 16:11ba5d6f42ba | 221 | } |
| bbbobbbieo | 15:830209e846d5 | 222 | |
| bbbobbbieo | 16:11ba5d6f42ba | 223 | // protection block |
| bbbobbbieo | 16:11ba5d6f42ba | 224 | if(current_left_motor_speed >= 0.5) |
| bbbobbbieo | 16:11ba5d6f42ba | 225 | current_left_motor_speed= 0.5; |
| bbbobbbieo | 16:11ba5d6f42ba | 226 | if(current_right_motor_speed >= 0.5) |
| bbbobbbieo | 16:11ba5d6f42ba | 227 | current_right_motor_speed= 0.5; |
| bbbobbbieo | 16:11ba5d6f42ba | 228 | if(current_left_motor_speed <= -0.5) |
| bbbobbbieo | 16:11ba5d6f42ba | 229 | current_left_motor_speed= -0.5; |
| bbbobbbieo | 16:11ba5d6f42ba | 230 | if(current_right_motor_speed <= -0.5) |
| bbbobbbieo | 16:11ba5d6f42ba | 231 | current_right_motor_speed= -0.5; |
| bbbobbbieo | 16:11ba5d6f42ba | 232 | |
| bbbobbbieo | 14:f43b386b8b5d | 233 | TFC_SetMotorPWM(current_left_motor_speed, current_right_motor_speed); |
| bbbobbbieo | 15:830209e846d5 | 234 | |
| bbbobbbieo | 14:f43b386b8b5d | 235 | } |
| bbbobbbieo | 14:f43b386b8b5d | 236 | |
| bbbobbbieo | 15:830209e846d5 | 237 | // clearing values for next image processing round |
| bbbobbbieo | 14:f43b386b8b5d | 238 | black_value_count = 0; |
| bbbobbbieo | 14:f43b386b8b5d | 239 | black_center_value = 0; |
| bbbobbbieo | 14:f43b386b8b5d | 240 | sum_black = 0; |
| bbbobbbieo | 14:f43b386b8b5d | 241 | |
| bbbobbbieo | 15:830209e846d5 | 242 | // end image processing |
| bbbobbbieo | 14:f43b386b8b5d | 243 | |
| bbbobbbieo | 14:f43b386b8b5d | 244 | linescan_ping_pong = false; |
| bbbobbbieo | 14:f43b386b8b5d | 245 | } // end checking channel 0 |
| bbbobbbieo | 15:830209e846d5 | 246 | |
| bbbobbbieo | 15:830209e846d5 | 247 | else { //checking channel 1 |
| bbbobbbieo | 14:f43b386b8b5d | 248 | linescan_ping_pong = true; |
| bbbobbbieo | 14:f43b386b8b5d | 249 | } |
| bbbobbbieo | 14:f43b386b8b5d | 250 | |
| bbbobbbieo | 7:455e7dd338ee | 251 | TFC_LineScanImageReady ==0; // since we used it, we reset the flag |
| bbbobbbieo | 14:f43b386b8b5d | 252 | }// end imageready |
| bbbobbbieo | 14:f43b386b8b5d | 253 | }// end linescan stuff |
| bbbobbbieo | 0:d57117b2188d | 254 | } |
| bbbobbbieo | 0:d57117b2188d | 255 | } |
| bbbobbbieo | 8:946806df7347 | 256 | |
| bbbobbbieo | 8:946806df7347 | 257 | |
| bbbobbbieo | 15:830209e846d5 | 258 | // shit code down here |