Posted 12 November 2020
Back in October I added a TIMER5 timer interrupt to my autonomous wall-following robot (WAll-E2) code to manage sensor updates. Since then I have made the timer interrupt the sole timing source for all sensor and tracking updates, and upped the update rate from 5Hz to 10Hz. In addition, I’ve been making some improvements to Wall-E2’s obstacle detection/response abilities, and this post describes the results of these enhancements.
Wall-E2’s job is to autonomously track walls forever. This implies the ability not only track walls, but to deal with obstacles as they occur, and recharge its batteries at one or more provided charging stations as needed. Wall-tracking per se has been the subject of several previous posts, and is now reasonably well managed using the ‘find parallel’ technique described here. This post deals with the effort to detect and respond to obstacles as they occur. Here’s a recent run in my office ‘sandbox’
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 |
Initializing Left & Right Distance Arrays... Left Right 340 8190 329 8190 330 8190 In RotateToParallelOrientation(Left) Parallel Orientation Achieved at 3453 with SteeringVal = 0.01 WallOffsetTrackPID Parameters (Kp,Ki,Kd) = (100,30,30) Msec LFront LCtr LRear Front FrontVar Rear Steer Output SetPt LSpd RSpd 3464 326 334 316 175 4474.00 508 0.01 34.93 -0.30 40 109 3473 331 341 323 175 4474.00 508 -0.01 34.93 -0.30 40 109 3554 329 342 326 172 4286.29 8190 0.03 34.93 -0.30 40 109 3651 326 354 325 181 4164.85 1192 -0.01 24.80 -0.30 50 99 3750 329 354 349 127 4520.47 1114 -0.20 24.80 -0.30 50 99 3850 307 387 336 102 5186.04 1197 -0.29 -75.00 -0.30 150 0 3946 306 342 361 96 5933.30 1156 -0.55 -75.00 -0.30 150 0 4043 293 325 335 105 6564.30 1272 -0.29 -2.29 -0.25 77 72 4141 282 310 305 139 6862.29 8190 -0.23 -2.29 -0.10 77 72 4235 272 296 287 174 6912.94 914 -0.19 8.02 0.04 66 83 4330 267 284 285 172 6889.58 920 -0.18 8.02 0.16 66 83 4427 260 283 267 165 6772.68 967 -0.06 16.33 0.17 58 91 4521 249 286 270 147 6565.69 1069 -0.21 16.33 0.14 58 91 4620 248 277 268 134 6196.07 1056 -0.20 -75.00 0.23 150 0 4717 238 261 248 133 5544.52 1166 -0.10 -75.00 0.30 150 0 4812 230 243 249 126 4582.67 1046 -0.19 -48.43 0.30 123 26 4910 220 243 236 122 3231.83 974 -0.16 -48.43 0.30 123 26 5006 218 232 213 121 1415.66 1029 0.05 43.82 0.30 31 118 5105 218 246 205 119 1363.33 1169 0.13 43.82 0.30 31 118 5200 215 237 221 115 1303.73 1136 -0.06 -73.26 0.30 148 1 5300 217 227 218 113 1215.34 1190 -0.01 -21.19 0.30 96 53 5396 219 235 205 110 1098.33 1228 0.14 -21.19 0.30 96 53 5491 228 244 215 106 974.86 8190 0.19 43.48 0.30 31 118 5587 239 260 218 103 868.73 8190 0.21 43.48 0.30 31 118 5688 244 254 235 97 807.43 8190 0.09 -57.15 0.30 132 17 5783 253 268 246 94 766.78 8190 0.07 -57.15 0.30 132 17 5882 260 260 246 92 731.99 8190 0.14 -7.63 0.30 82 67 5982 282 278 257 88 697.85 8190 0.25 -7.63 0.22 82 67 6081 287 279 256 85 608.15 8190 0.30 50.64 0.21 24 125 6178 294 297 276 80 664.40 8190 0.18 50.64 0.03 24 125 6277 316 305 287 77 719.44 8190 0.11 -46.88 -0.05 121 28 6373 311 315 289 74 774.14 8190 0.22 -46.88 -0.15 121 28 6471 311 334 292 73 840.70 8190 0.25 75.00 -0.30 0 150 6569 327 344 311 68 894.32 8190 0.16 75.00 -0.30 0 150 6670 340 348 308 62 816.19 8190 0.32 75.00 -0.30 0 150 6772 342 360 333 54 737.65 8190 0.09 -31.20 -0.30 106 43 6868 354 350 333 53 657.72 8190 0.21 -31.20 -0.30 106 43 6967 338 358 326 51 634.07 8190 0.12 51.06 -0.30 23 126 7063 346 368 333 50 636.22 8190 0.13 51.06 -0.30 23 126 7161 334 346 345 44 638.78 8190 -0.11 -49.37 -0.30 124 25 7260 334 371 333 39 658.55 8190 0.01 -49.37 -0.30 124 25 7360 336 350 330 32 693.11 8190 0.06 75.00 -0.30 0 150 7457 332 357 319 25 732.13 8190 0.13 75.00 -0.30 0 150 7556 344 355 332 23 757.01 8191 0.12 62.97 -0.30 12 137 bObstacleAhead TRUE in TRACKLEFT at 7656 with frontdist 18, variance = 787.12 In SpinTurn(CW, 90.00) Msec Hdg pHdg Rate TRate Spd 7751 6.06 1.38 52.1 20.0 87 7848 1.23 6.06 51.0 20.0 50 7947 -5.41 1.23 68.5 20.0 50 8045 -12.14 -5.41 70.7 20.0 50 8144 -17.56 -12.14 55.5 20.0 50 8244 -21.25 -17.56 38.0 20.0 50 8341 -23.40 -21.25 22.6 20.0 50 8438 -24.34 -23.40 9.9 20.0 90 8537 -25.11 -24.34 8.0 20.0 130 8636 -28.17 -25.11 31.4 20.0 90 8735 -35.01 -28.17 71.1 20.0 50 8835 -41.34 -35.01 65.0 20.0 50 8935 -44.53 -41.34 32.6 20.0 50 9036 -46.09 -44.53 15.8 20.0 90 9135 -47.11 -46.09 10.6 20.0 130 9233 -50.33 -47.11 33.3 20.0 90 9333 -56.48 -50.33 63.0 20.0 50 Slowing down to 10.00 deg/sec at -56.48 deg 9430 -62.64 -56.48 65.1 10.0 50 9529 -65.95 -62.64 34.4 10.0 50 9626 -66.79 -65.95 8.7 10.0 90 9723 -67.14 -66.79 3.7 10.0 130 9823 -68.64 -67.14 15.5 10.0 90 9919 -72.84 -68.64 44.8 10.0 50 10018 -76.92 -72.84 42.1 10.0 50 10116 -79.19 -76.92 23.8 10.0 50 10213 -79.30 -79.19 1.2 10.0 90 10313 -79.37 -79.30 0.7 10.0 130 10414 -80.87 -79.37 15.3 10.0 90 10417: Exiting SpinTurn() at -80.87 deg In RotateToParallelOrientation(Left) Parallel Orientation Achieved at 11293 with SteeringVal = 0.00 WallOffsetTrackPID Parameters (Kp,Ki,Kd) = (100,30,30) Msec LFront LCtr LRear Front FrontVar Rear Steer Output SetPt LSpd RSpd 11304 49 69 49 101 808.15 574 0.00 -63.93 0.30 138 11 11313 45 66 46 101 808.15 574 -0.01 -63.93 0.30 138 11 11395 44 64 47 109 891.88 627 -0.03 -63.93 0.30 138 11 11492 43 65 43 162 1291.60 673 0.00 -28.83 0.30 103 46 11591 47 100 44 216 2143.29 728 0.03 -28.83 0.30 103 46 11689 47 70 81 94 2055.42 758 -0.34 -75.00 0.30 150 0 11786 52 71 45 69 1960.80 749 0.07 -75.00 0.30 150 0 11882 56 75 45 67 1851.13 701 0.11 75.00 0.30 0 150 11979 63 76 43 63 1762.12 489 0.20 75.00 0.30 0 150 12079 62 84 56 58 1678.46 534 0.06 -41.04 0.30 116 33 12176 73 89 71 54 1594.01 745 0.02 -41.04 0.30 116 33 12275 79 90 73 50 1519.21 790 0.06 -26.76 0.30 101 48 12372 85 97 74 47 1480.52 774 0.11 -26.76 0.30 101 48 12473 95 109 78 42 1477.60 619 0.17 16.85 0.30 58 91 12569 108 113 87 35 1515.29 570 0.21 16.85 0.30 58 91 12666 113 120 98 33 1561.57 639 0.15 -24.60 0.30 99 50 Hit Wall Offset Limit (30 cm) at 1769472 with frontdist = 29, Setpoint = 0.00 In StepTurn(Tracking Left) In SpinTurn(CW, 90.00) Msec Hdg pHdg Rate TRate Spd 12862 -109.12 -107.73 15.9 20.0 167 12961 -116.70 -109.12 78.1 20.0 127 13061 -127.75 -116.70 113.9 20.0 87 13158 -142.57 -127.75 155.6 20.0 50 13257 -155.69 -142.57 136.5 20.0 50 13355 -165.76 -155.69 106.5 20.0 50 Slowing down to 10.00 deg/sec at -165.76 deg 13453 -172.39 -165.76 69.2 10.0 50 13551 -176.13 -172.39 38.6 10.0 50 13650 -176.98 -176.13 8.9 10.0 90 13747 -177.02 -176.98 0.4 10.0 130 13845 -178.80 -177.02 18.5 10.0 90 13946 175.39 -178.80 3604.6 10.0 50 14041 169.71 175.39 61.9 10.0 50 14043: Exiting SpinTurn() at 169.71 deg In RotateToParallelOrientation(Left) Parallel Orientation Achieved at 14687 with SteeringVal = 0.01 WallOffsetTrackPID Parameters (Kp,Ki,Kd) = (100,30,30) Msec LFront LCtr LRear Front FrontVar Rear Steer Output SetPt LSpd RSpd 14698 191 208 190 251 10269.92 289 0.01 -75.00 0.30 150 0 14706 196 205 195 251 10269.92 289 -0.06 -75.00 0.30 150 0 14788 198 213 196 246 10313.22 355 0.02 -75.00 0.30 150 0 14884 207 219 198 240 10143.41 402 0.09 -2.10 0.30 77 72 14983 210 226 197 232 9731.76 451 0.13 -2.10 0.30 77 72 15078 216 228 209 231 9169.12 488 0.07 -34.79 0.30 109 40 15174 223 240 214 226 8389.68 547 0.09 -34.79 0.30 109 40 15270 225 243 215 226 7483.51 576 0.10 -17.39 0.30 92 57 15366 223 244 229 224 6445.87 624 -0.06 -17.39 0.30 92 57 15462 228 245 232 221 5279.39 657 -0.01 -71.32 0.30 146 3 15558 234 254 229 217 4146.39 705 0.05 -71.32 0.30 146 3 15655 248 260 220 218 3116.80 748 0.28 75.00 0.30 0 150 15749 272 266 238 218 2207.54 794 0.34 75.00 0.30 0 150 15843 282 288 248 211 1580.34 839 0.30 17.16 0.12 57 92 15938 293 287 264 200 1231.91 877 0.29 17.16 0.13 57 92 16038 301 303 266 194 947.68 895 0.27 15.06 -0.03 59 90 16137 304 307 281 192 667.96 916 0.23 15.06 -0.07 59 90 16232 305 320 297 187 675.37 984 0.08 -34.10 -0.20 109 40 16329 321 327 294 183 719.94 1012 0.27 -34.10 -0.27 109 40 16429 326 344 301 181 748.10 1030 0.25 75.00 -0.30 0 150 16525 328 345 318 175 773.36 1061 0.10 75.00 -0.30 0 150 16623 340 350 323 171 785.28 1139 0.17 20.96 -0.30 54 95 16719 344 351 327 165 797.68 1142 0.17 20.96 -0.30 54 95 16820 355 364 357 161 809.43 1160 -0.01 -26.17 -0.30 101 48 16914 356 372 351 157 816.35 1215 0.05 -26.17 -0.30 101 48 17007 371 376 338 153 826.46 1232 0.33 75.00 -0.30 0 150 17104 365 378 350 151 828.07 1275 0.15 75.00 -0.30 0 150 17200 362 363 359 146 837.66 8190 0.03 -55.29 -0.30 130 19 17295 360 371 353 143 851.33 8190 0.07 -55.29 -0.30 130 19 17392 361 387 354 136 892.80 8190 0.07 51.82 -0.30 23 126 17488 364 368 354 134 916.39 8190 0.10 51.82 -0.30 23 126 17584 352 380 353 129 948.67 8190 -0.01 8.69 -0.30 66 83 17680 349 368 360 128 954.63 8190 -0.11 8.69 -0.30 66 83 17776 370 381 356 126 945.54 8190 0.06 61.77 -0.30 13 136 17872 362 375 362 123 929.23 8190 0.00 61.77 -0.30 13 136 17972 347 377 363 122 903.09 8190 -0.04 1.55 -0.30 73 76 18070 348 395 372 122 843.49 8190 -0.24 1.55 -0.30 73 76 18167 352 370 362 120 760.07 8190 -0.17 -20.06 -0.30 95 54 18264 332 368 353 115 694.64 8190 -0.21 -20.06 -0.30 95 54 18362 312 336 339 111 661.03 8190 -0.20 7.24 -0.30 67 82 18460 297 323 327 105 644.80 8190 -0.30 7.24 -0.23 67 82 18560 283 312 313 100 627.13 8190 -0.28 -34.24 -0.12 109 40 18655 285 302 299 96 615.78 8190 -0.14 -34.24 -0.02 109 40 18754 264 298 287 90 613.99 8190 -0.19 11.13 0.02 63 86 18850 259 276 255 86 606.39 8190 0.04 11.13 0.24 63 86 18950 252 284 259 84 601.15 8190 -0.09 9.38 0.16 65 84 19046 240 280 260 81 595.10 8190 -0.20 9.38 0.20 65 84 19144 238 252 248 78 595.94 8190 -0.10 -39.82 0.30 114 35 19240 217 253 242 76 593.76 8190 -0.13 -39.82 0.30 114 35 19338 218 246 230 71 598.99 8190 -0.09 -33.99 0.30 108 41 19438 216 236 221 67 608.08 8190 -0.10 -42.19 0.30 117 32 19535 205 225 214 61 621.04 8190 -0.09 -42.19 0.30 117 32 19634 208 222 203 55 647.83 8190 0.06 24.09 0.30 50 99 19733 208 221 203 50 677.59 8190 0.05 24.09 0.30 50 99 19832 210 230 201 48 711.95 8190 0.18 23.73 0.30 51 98 19932 224 232 214 45 739.29 8190 0.10 -44.87 0.30 119 30 20032 224 231 213 40 776.88 8190 0.10 -21.47 0.30 96 53 20130 228 235 210 37 803.67 8190 0.18 -21.47 0.30 96 53 20231 240 244 216 32 829.84 8190 0.15 -1.92 0.30 76 73 Hit Wall Offset Limit 20330 at 1835008 with frontdist = -26214, Setpoint = 0.00 In StepTurn(Tracking Left) In SpinTurn(CW, 90.00) Msec Hdg pHdg Rate TRate Spd 20427 170.01 171.69 18.9 20.0 167 20528 162.73 170.01 74.4 20.0 127 20628 149.44 162.73 136.8 20.0 87 20724 133.31 149.44 171.6 20.0 50 20824 118.14 133.31 156.0 20.0 50 20921 107.84 118.14 108.3 20.0 50 Slowing down to 10.00 deg/sec at 107.84 deg 21018 100.75 107.84 75.0 10.0 50 21114 96.88 100.75 41.2 10.0 50 21211 95.61 96.88 13.7 10.0 50 21304 95.40 95.61 2.2 10.0 90 21401 95.27 95.40 1.4 10.0 130 21500 92.77 95.27 26.0 10.0 90 21595 86.00 92.77 73.4 10.0 50 21597: Exiting SpinTurn() at 86.00 deg In RotateToParallelOrientation(Left) Parallel Orientation Achieved at 21983 with SteeringVal = -0.01 WallOffsetTrackPID Parameters (Kp,Ki,Kd) = (100,30,30) Msec LFront LCtr LRear Front FrontVar Rear Steer Output SetPt LSpd RSpd 21994 161 185 162 108 5323.48 265 -0.01 -75.00 0.30 150 0 22002 164 182 160 108 5323.48 265 0.05 -75.00 0.30 150 0 22086 166 184 159 78 5270.27 295 0.07 -75.00 0.30 150 0 22184 175 185 165 58 5243.36 352 0.10 9.55 0.30 65 84 22280 183 190 172 175 5373.00 388 0.11 9.55 0.30 65 84 22375 197 204 176 91 5247.15 436 0.21 20.28 0.30 54 95 22470 197 215 182 108 5081.33 467 0.15 20.28 0.30 54 95 22564 207 226 189 151 4952.56 518 0.18 -25.08 0.30 100 49 22663 218 233 204 52 4842.48 555 0.14 -25.08 0.30 100 49 22761 236 245 213 141 4580.68 601 0.18 -16.44 0.30 91 58 bObstacleAhead TRUE in TRACKLEFT at 22858 with frontdist 13, variance = 4694.59 In SpinTurn(CW, 90.00) Msec Hdg pHdg Rate TRate Spd 22952 71.13 73.50 26.9 20.0 87 23052 63.70 71.13 76.5 20.0 50 23147 54.57 63.70 98.3 20.0 50 23246 48.04 54.57 67.2 20.0 50 23343 43.69 48.04 46.2 20.0 50 23441 40.42 43.69 34.1 20.0 50 23540 38.54 40.42 19.5 20.0 90 23638 37.63 38.54 9.7 20.0 130 23734 34.63 37.63 31.7 20.0 90 23833 32.15 34.63 25.5 20.0 50 23931 30.65 32.15 15.7 20.0 90 24031 30.52 30.65 1.4 20.0 130 24127 29.88 30.52 6.8 20.0 170 24225 28.04 29.88 19.3 20.0 210 24324 24.16 28.04 40.3 20.0 170 24419 20.53 24.16 39.3 20.0 130 24515 11.17 20.53 98.9 20.0 90 Slowing down to 10.00 deg/sec at 11.17 deg 24611 0.33 11.17 115.7 10.0 50 24711 -8.59 0.33 92.5 10.0 50 24713: Exiting SpinTurn() at -8.59 deg In RotateToParallelOrientation(Left) Parallel Orientation Achieved at 27962 with SteeringVal = -79.86 WallOffsetTrackPID Parameters (Kp,Ki,Kd) = (100,30,30) Msec LFront LCtr LRear Front FrontVar Rear Steer Output SetPt LSpd RSpd 27973 313 8191 8190 230 14.32 369 -78.77 -75.00 -0.30 150 0 bStuck TRUE in TRACKLEFT at 27981 with frontdist 230, variance = 14.32 ---- ExecuteStuckRecoveryManeuver Using front distance for backup with front/reardist = 230/36 28059 231 369 28153 248 350 28249 250 327 28346 254 282 28443 255 232 finished backup with frontdist/reardist = 28444 255/23 In SpinTurn(CW, 90.00) Msec Hdg pHdg Rate TRate Spd 30450 20.77 20.77 0.0 20.0 167 30543 19.58 20.77 13.1 20.0 207 30640 9.56 19.58 106.9 20.0 167 30736 -2.24 9.56 125.2 20.0 127 30830 -14.60 -2.24 134.4 20.0 87 30922 -22.53 -14.60 88.6 20.0 50 31019 -33.56 -22.53 118.1 20.0 50 Slowing down to 10.00 deg/sec at -33.56 deg 31117 -43.11 -33.56 99.6 10.0 50 31214 -49.46 -43.11 66.5 10.0 50 31310 -52.74 -49.46 35.0 10.0 50 31409 -53.79 -52.74 10.8 10.0 50 31510 -53.85 -53.79 0.6 10.0 90 31607 -54.34 -53.85 5.2 10.0 130 31704 -56.91 -54.34 27.5 10.0 90 31802 -62.72 -56.91 60.3 10.0 50 31805: Exiting SpinTurn() at -62.72 deg Using front distance for fwd travel with front/reardist = 62/34 33807 62 340 33862 61 329 33959 59 346 34058 57 354 34157 52 377 34254 49 434 34354 41 453 finished forward travel with frontdist/reardist = 41/45 In SpinTurn(CCW, 90.00) Msec Hdg pHdg Rate TRate Spd 36356 -64.92 -64.92 0.0 20.0 167 36419 -64.63 -64.92 4.8 20.0 207 36517 -56.67 -64.63 83.0 20.0 167 36616 -41.04 -56.67 163.3 20.0 127 36712 -25.33 -41.04 166.6 20.0 87 36808 -8.73 -25.33 177.6 20.0 50 Slowing down to 10.00 deg/sec at -8.73 deg 36902 7.93 -8.73 182.0 10.0 50 36998 19.87 7.93 128.6 10.0 50 37000: Exiting SpinTurn() at 19.87 deg I received: 63 ENTERING COMMAND MODE: 0 = 180 deg CCW Turn 1 = 180 deg CW Turn A = Back to Auto Mode S = Stop F = Forward R = Reverse Faster 8 Left 4 5 6 Right 2 Slower |
In the above telemetry printout, the first obstacle encounter occurs at 7.65 sec, corresponding to about 4 sec into the video. The obstacle is recognized at 18 cm, well inside the desired offset distance of 30 cm. I believe this occurred because the robot had just started turning back toward the near wall with a target steering value of -WALL_OFFSET_TRACK_SETPOINT_LIMIT (-0.3, the maximum toward-wall steering value) which meant that the normal forward obstacle detection limit of WALL_OFFSET_TGTDIST_CM (30cm in this case) wasn’t in force and the backup limit of MIN_FRONT_OBSTACLE_DIST_CM (20cm in this case) triggered instead. This causes the following code block to execute:
1 2 3 4 5 6 7 8 9 10 11 12 |
if (bObstacleAhead)//bObstacleAheada updated in timer1 ISR { //mySerial.printf("bStuck or bObstacleAhead TRUE in TRACKLEFT with frontdist %d, variance = %6.2f\n", frontdistval, frontvar); mySerial.printf("bObstacleAhead TRUE in TRACKLEFT at %lu with frontdist %d, variance = %6.2f\n", millis(), frontdistval, frontvar); InitFrontDistArray(); //added 08/12/20 to prevent multiple 'stuck' detections SpinTurn(false, 90);//turn 90 deg right PrevOpMode = MODE_NONE; //this will force wall offset recapture break; //don't execute the rest - just go back to GetOpMode() } |
As can be seen in the above code snippet, this causes the robot to make a 90º ‘spin turn’ to the right, and then restart wall tracking.
At about 12.6 sec (about 10 sec into the movie) we see it detect the upcoming wall at about 30 cm (due to a bug in the code, the printed values are incorrect). This causes the following code block to execute:
1 2 3 4 5 6 7 8 9 10 11 12 |
else if (WallTrackSetPoint > -WALL_OFFSET_TRACK_SETPOINT_LIMIT && frontdistval <= WALL_OFFSET_TGTDIST_CM) { //DEBUG!! mySerial.printf("Hit Wall Offset Limit (%d cm) at %lu with frontdist = %d, Setpoint = %2.2f\n", WALL_OFFSET_TGTDIST_CM, millis(), frontdistval, WallTrackSetPoint); //DEBUG!! //02/26/20 StepTurn() is now a blocking fcn - doesn't return until step-turn is complete StepTurn(TRACKING_LEFT); PrevOpMode = MODE_NONE; //this will force wall offset recapture break; //skip rest of processing } |
This code executes a 90º ‘step turn’ (identical to a ‘spin turn’) to the right, and drops back into wall tracking mode.
At about 16 sec into the movie and 20 sec after program start, the robot again detects an upcoming obstacle at about 30cm, and again executes a 90º ‘step turn’ to the right to follow the new wall.
About 1.5 sec later, the robot detects one of the chair legs (I think it was the one nearest the wall in the movie) and tries to get away using another 90º ‘spin turn’, but then exhibits some abnormal behavior. When it attempts to find the parallel orientation to the new (non-existent) wall, it exits RotateToParallelOrientation(Left) with SteeringVal = -79.86, a very strange result. I believe this is because Wall-E2 detected the ‘stuck’ condition while it was attempting to complete the parallel orientation procedure, in this ‘while’ loop
1 2 |
while (abs(ToFSteeringVal) > ToFArray_PARALLEL_FIND_SETPOINT && !bIsStuck && !bObstacleAhead) { |
So, it exited abnormally, thus the odd SteeringVal number, and then re-detected it in the main tracking loop because the front distance history array isn’t re-initialized after the first detection. This, apparently, is a ‘feature’, not a bug – who knew! ;-).
After the second ‘stuck’ condition detection, the robot attempts to disengage using the ExecuteStuckRecoveryManeuver(), which, in this case tries to back up and then execute an ‘end-around’ maneuver to get past the chair leg. It finished the backup portion of the maneuver successfully with 23cm remaining rearward, and then executed a 90º ‘spin turn’. Then it went forward 21cm using the front distance sensor (not shown in the video), and halted when I took over manual control.
All in all, this was a very successful ‘sandbox’ run. Lots of good data with clear indications of where things are working well and where things need to be modified/fixed.
- A bug in the telemetry display code for the ‘Wall Offset Limit’ detection printout (fixed).
- In the situation at 7.65 sec where the obstacle detection occurred at 18cm vs 30cm, the robot should recognize that it needs to back up to the wall offset target before making the spin turn (done).
- And, of course, porting all this new stuff to the right-side tracking sections
16 November 2020 Update:
Tonight I got the first cut done at porting the TRACKNG_LEFT algorithms over to the TRACKING_RIGHT case, and made what appears to be a successful right-side sandbox run, as shown in the following short video
And here is the telemetry from the run:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 |
In RotateToParallelOrientation(Right) 6266 298 352 372 -0.67 127.00 0 254 6466 280 307 306 -0.26 59.72 67 186 Parallel Orientation Achieved at 6538 with SteeringVal = 0.01 WallOffsetTrackPID Parameters (Kp,Ki,Kd) = (100,30,30) Msec RFront RCtr RRear Front FrontVarSteer Output SetPt LSpd RSpd 6549 281 294 280 227 8728.96 0.01 -2.15 0.06 72 77 6554 281 294 280 227 8728.96 0.01 -2.15 0.06 72 77 6635 310 311 276 240 8520.67 0.34 -2.15 -0.11 72 77 6729 327 325 292 244 8381.43 0.35 75.00 -0.25 150 0 6828 342 337 295 240 8290.90 0.47 75.00 -0.30 150 0 6921 357 355 316 230 8240.07 0.41 75.00 -0.30 150 0 7018 360 338 328 222 8224.66 0.32 75.00 -0.30 150 0 7114 352 359 326 213 8233.74 0.26 16.46 -0.30 91 58 7211 349 356 335 206 8247.12 0.14 16.46 -0.30 91 58 7305 336 357 341 202 8234.86 -0.05 -61.79 -0.30 13 136 7402 334 349 342 199 8165.47 -0.08 -61.79 -0.30 13 136 7499 338 371 343 197 8004.15 -0.14 -4.31 -0.30 70 79 7593 345 353 335 195 7715.00 0.10 -4.31 -0.30 70 79 7695 344 359 332 192 7260.35 0.13 75.00 -0.30 150 0 7786 350 359 329 189 6597.09 0.21 75.00 -0.30 150 0 7881 347 374 338 182 5682.62 0.03 11.97 -0.30 86 63 7979 348 355 352 177 4460.83 -0.04 11.97 -0.30 86 63 8078 340 353 349 172 2874.73 -0.09 -5.40 -0.30 69 80 8170 343 362 352 170 2504.54 -0.09 -5.40 -0.30 69 80 8266 343 345 360 165 2110.81 -0.17 -1.01 -0.30 73 76 8360 352 364 342 162 1719.27 0.10 -1.01 -0.30 73 76 8460 341 369 353 158 1311.16 -0.12 43.53 -0.30 118 31 8557 354 370 351 156 926.95 0.03 43.53 -0.30 118 31 8651 344 361 359 152 772.95 -0.15 16.98 -0.30 91 58 8748 333 359 367 150 853.82 -0.34 16.98 -0.30 91 58 8845 334 342 360 147 895.27 -0.26 -17.90 -0.30 57 92 8940 329 362 351 143 927.53 -0.22 -17.90 -0.30 57 92 9037 317 357 342 139 900.06 -0.25 19.25 -0.30 94 55 9134 317 347 343 134 837.40 -0.26 19.25 -0.30 94 55 9231 315 338 332 131 767.64 -0.17 48.64 -0.30 123 26 9329 299 331 327 128 720.97 -0.28 48.64 -0.30 123 26 9426 287 334 334 125 688.38 -0.34 -43.48 -0.30 31 118 9526 288 322 334 110 719.70 -0.46 -43.48 -0.22 31 118 9621 274 313 315 109 749.19 -0.37 -22.20 -0.13 52 97 9720 264 299 301 115 743.06 -0.37 -22.20 0.01 52 97 9818 253 279 283 111 736.87 -0.26 -4.61 0.21 70 79 9914 245 270 268 110 716.83 -0.23 -4.61 0.30 70 79 10012 232 266 265 104 699.06 -0.37 -75.00 0.30 0 150 10109 224 253 248 100 679.92 -0.24 -75.00 0.30 0 150 10205 218 244 243 96 659.09 -0.25 -13.27 0.30 61 88 10301 204 221 225 91 655.60 -0.21 -13.27 0.30 61 88 10397 198 221 212 89 651.66 -0.15 -10.62 0.30 64 85 10496 199 213 207 84 658.13 -0.08 -10.62 0.30 64 85 10595 169 214 204 82 653.91 -0.23 -74.21 0.30 0 149 10691 196 198 203 81 646.92 -0.07 -74.21 0.30 0 149 10789 202 215 201 81 628.52 0.00 40.89 0.30 115 34 10889 214 226 199 79 609.31 0.15 31.44 0.30 106 43 10985 208 228 202 75 588.31 0.06 31.44 0.30 106 43 11083 225 233 206 70 575.19 0.19 2.11 0.30 77 72 11183 222 225 219 67 556.60 0.06 -62.61 0.30 12 137 11281 232 236 223 64 535.88 0.05 -62.61 0.30 12 137 11377 253 238 221 62 513.85 0.34 75.00 0.30 150 0 11475 281 278 231 61 488.39 0.43 75.00 0.22 150 0 11573 279 277 245 57 471.88 0.36 19.90 0.23 94 55 11672 287 291 261 51 463.43 0.26 19.90 0.09 94 55 11769 299 299 273 46 459.76 0.15 -47.68 0.01 27 122 11870 301 295 288 42 457.37 0.01 -44.80 0.05 30 119 11969 302 300 280 36 498.81 0.23 -44.80 0.00 30 119 12065 303 313 283 33 535.29 0.20 75.00 -0.13 150 0 12164 325 318 307 30 544.00 0.23 75.00 -0.18 150 0 12260 338 332 315 24 563.76 0.23 65.78 -0.30 140 9 bObstacleAhead TRUE in TRACKRIGHT at 12358 with frontdist 19, variance = 580.36 backing up to 30 using front distance sensor backed up successfully to 33 using front distance sensor In SpinTurn(CCW, 90.00) Msec Hdg PrevHdg Rate Set Out Spd 13039 0.17 -1.08 12.95 45.00 200.00 0 13136 5.51 0.17 56.96 45.00 200.00 0 13234 11.65 5.51 64.88 45.00 200.00 0 13331 15.61 11.65 42.26 45.00 200.00 0 13428 16.21 15.61 6.30 45.00 -200.00 200 13528 18.80 16.21 26.83 45.00 200.00 0 13626 28.55 18.80 102.85 45.00 200.00 0 13725 33.06 28.55 46.58 45.00 200.00 0 13825 33.04 33.06 0.16 45.00 -200.00 200 13921 35.82 33.04 29.69 45.00 -200.00 255 14021 48.68 35.82 132.80 45.00 200.00 55 14117 64.01 48.68 165.27 45.00 200.00 0 14213 75.93 64.01 128.49 45.00 -13.74 13 14310 84.24 75.93 88.53 45.00 -13.74 26 14313: Exiting SpinTurn() at 84.24 deg In RotateToParallelOrientation(Right) Parallel Orientation Achieved at 14504 with SteeringVal = 0.10 WallOffsetTrackPID Parameters (Kp,Ki,Kd) = (100,30,30) Msec LFront LCtr LRear Front FrontVar Rear Steer Output SetPt LSpd RSpd 14516 391 398 376 108 11084.51 0.10 5.98 -0.30 80 69 14521 391 398 376 108 11084.51 0.10 5.98 -0.30 80 69 14605 388 400 384 106 8356.08 0.04 5.98 -0.30 80 69 14704 380 395 384 105 5067.11 0.15 66.33 -0.30 141 8 14801 402 394 383 100 1142.00 0.19 66.33 -0.30 141 8 14883 398 404 393 98 1092.24 0.04 8.35 -0.30 83 66 14980 377 402 397 97 1019.28 -0.20 8.35 -0.30 83 66 15076 384 412 399 95 935.28 -0.15 -34.20 -0.30 40 109 15174 378 392 395 92 837.84 -0.17 -34.20 -0.30 40 109 15271 370 402 395 90 748.36 -0.15 23.25 -0.30 98 51 15369 384 391 387 87 664.72 -0.03 23.25 -0.30 98 51 15464 378 394 389 86 579.21 -0.15 23.70 -0.30 98 51 15563 374 394 388 82 504.21 -0.14 23.70 -0.30 98 51 15662 360 392 393 79 448.40 -0.29 -32.27 -0.30 42 107 15760 347 391 383 75 398.56 -0.36 -32.27 -0.30 42 107 15859 325 375 376 71 354.21 -0.40 -34.57 -0.30 40 109 15958 325 341 365 68 324.42 -0.40 -34.57 -0.30 40 109 16056 331 337 347 65 296.47 -0.14 75.00 -0.30 150 0 16154 332 343 327 62 284.88 0.05 75.00 -0.30 150 0 16253 330 353 332 60 275.08 0.07 75.00 -0.30 150 0 16351 329 337 341 58 284.24 -0.12 75.00 -0.30 150 0 16447 324 345 350 55 326.19 -0.28 -75.00 -0.30 0 150 16545 317 352 367 54 343.76 -0.40 -75.00 -0.30 0 150 16648 314 349 354 51 364.72 -0.38 -28.16 -0.30 46 103 16746 306 334 343 43 390.02 -0.34 -28.16 -0.30 46 103 16843 297 328 325 39 412.51 -0.28 39.84 -0.28 114 35 16941 286 321 314 33 442.75 -0.21 39.84 -0.21 114 35 17039 287 310 312 28 476.95 -0.25 3.39 -0.10 78 71 Hit Wall Offset Limit (30 cm) at 17138 with frontdist = 25, Setpoint = -0.10 In StepTurn(Tracking Right) In SpinTurn(CCW, 90.00) Msec Hdg PrevHdg Rate Set Out Spd 17236 67.82 67.35 5.02 45.00 -200.00 255 17335 75.00 67.82 75.00 45.00 -200.00 255 17438 91.46 75.00 164.54 45.00 200.00 55 17537 113.79 91.46 235.10 45.00 200.00 0 17633 134.03 113.79 217.56 45.00 200.00 0 17732 146.96 134.03 134.52 45.00 200.00 0 17831 151.31 146.96 45.43 45.00 -200.00 200 17835: Exiting SpinTurn() at 151.31 deg In RotateToParallelOrientation(Right) 18134 126 157 159 -0.38 86.02 40 213 Parallel Orientation Achieved at 18321 with SteeringVal = -0.02 WallOffsetTrackPID Parameters (Kp,Ki,Kd) = (100,30,30) Msec LFront LCtr LRear Front FrontVar Rear Steer Output SetPt LSpd RSpd 18332 131 154 128 321 5983.33 -0.02 45.43 0.30 120 29 18337 131 154 128 321 5983.33 -0.02 45.43 0.30 120 29 18418 135 158 133 206 6668.69 0.02 45.43 0.30 120 29 18512 144 154 140 208 7308.87 -0.01 -20.50 0.30 54 95 18611 146 157 140 313 9298.40 0.06 -20.50 0.30 54 95 18706 150 161 143 311 11046.16 0.01 -16.37 0.30 58 91 18800 153 163 146 308 12536.56 0.07 -16.37 0.30 58 91 18897 157 165 144 270 13305.75 0.13 25.12 0.30 100 49 18991 162 179 156 268 13898.79 0.06 25.12 0.30 100 49 19087 162 177 159 266 14304.01 0.03 -51.69 0.30 23 126 19182 162 173 161 261 14450.51 0.01 -51.69 0.30 23 126 19278 173 180 162 213 14096.38 0.11 9.74 0.30 84 65 19376 179 189 162 191 13513.93 0.17 9.74 0.30 84 65 19472 186 203 174 187 12789.90 0.12 -10.80 0.30 64 85 19569 194 196 183 184 11946.82 0.11 -10.80 0.30 64 85 19665 197 201 184 177 11022.66 0.13 -10.31 0.30 64 85 19761 204 202 185 174 9907.81 0.19 -10.31 0.30 64 85 19858 211 215 198 172 8758.23 0.13 -13.82 0.30 61 88 19953 212 216 207 166 7632.49 0.05 -13.82 0.30 61 88 20050 218 228 205 179 6549.61 0.13 -14.33 0.30 60 89 20147 232 232 213 178 5714.13 0.19 -14.33 0.30 60 89 20242 234 238 221 176 4935.26 0.13 -14.84 0.30 60 89 20336 249 243 227 172 4144.19 0.13 -14.84 0.30 60 89 20432 252 260 235 171 3394.58 0.17 0.77 0.30 75 74 20531 265 269 238 171 3167.90 0.27 28.68 0.30 103 46 20626 270 280 247 165 2857.96 0.23 28.68 0.20 103 46 20722 280 275 255 160 2505.05 0.25 -4.32 0.25 70 79 20818 281 281 269 153 2629.37 0.12 -4.32 0.19 70 79 20918 286 290 269 147 2771.09 0.17 -15.11 0.10 59 90 21017 289 273 275 144 2412.00 0.14 -15.11 0.27 59 90 21114 303 304 283 141 1992.57 0.20 35.61 -0.04 110 39 21209 307 313 289 138 1521.46 0.18 35.61 -0.13 110 39 21306 302 314 298 131 1317.75 0.04 -26.85 -0.14 48 101 21402 310 321 303 129 1074.44 0.07 -26.85 -0.21 48 101 21500 326 310 308 127 791.55 0.18 73.99 -0.10 148 1 21599 319 341 309 123 499.21 0.10 73.99 -0.30 148 1 21696 317 335 315 112 484.99 0.02 -11.05 -0.30 63 86 21790 319 334 318 109 531.44 0.01 -11.05 -0.30 63 86 21890 317 328 322 105 582.61 -0.05 7.64 -0.28 82 67 21985 325 322 326 102 631.94 -0.01 7.64 -0.22 82 67 22080 328 341 327 99 690.09 0.01 55.57 -0.30 130 19 22176 329 335 328 98 740.19 -0.02 55.57 -0.30 130 19 22275 333 343 324 176 750.18 -0.04 18.35 -0.30 93 56 22368 320 348 335 175 769.94 -0.18 18.35 -0.30 93 56 22465 316 352 329 174 756.59 -0.09 13.98 -0.30 88 61 22563 313 331 337 170 736.67 -0.28 13.98 -0.30 88 61 22658 309 328 332 167 715.82 -0.32 -65.14 -0.28 9 140 22753 305 329 328 164 699.31 -0.30 -65.14 -0.29 9 140 22851 286 314 320 159 677.04 -0.22 29.62 -0.14 104 45 22944 287 302 308 155 649.19 -0.18 29.62 -0.02 104 45 23043 285 306 310 151 629.75 -0.25 -20.95 -0.06 54 95 23141 282 312 296 145 614.81 -0.14 -20.95 -0.12 54 95 23236 269 291 295 141 607.63 -0.16 8.30 0.09 83 66 23333 278 299 287 137 605.30 -0.08 8.30 0.01 83 66 23429 307 286 284 134 605.04 0.11 75.00 0.14 150 0 23527 502 292 280 128 608.91 1.64 75.00 0.08 150 0 23626 781 316 285 127 613.53 5.28 75.00 -0.16 150 0 23721 791 326 290 128 615.44 4.93 75.00 -0.26 150 0 23821 564 319 308 131 614.25 3.09 -75.00 -0.19 0 150 23918 402 325 329 109 641.78 0.77 -75.00 -0.25 0 150 24013 558 352 317 107 669.23 2.03 -45.64 -0.30 29 120 24113 703 467 317 126 649.74 3.33 75.00 -0.30 150 0 24213 850 709 481 118 632.92 3.69 75.00 -0.30 150 0 24311 811 842 622 115 611.13 1.99 75.00 -0.30 150 0 24407 797 835 649 94 636.27 1.87 -75.00 -0.30 0 150 24502 817 732 591 89 670.60 2.44 -75.00 -0.30 0 150 24601 830 801 642 83 725.71 1.88 75.00 -0.30 150 0 24696 248 281 290 78 781.84 8190 -0.42 75.00 0.19 0 150 24795 272 264 266 75 823.44 8190 0.06 -75.00 0.30 150 0 24892 327 273 258 71 853.43 8191 0.69 -75.00 0.27 150 0 24988 542 379 269 68 878.24 8190 2.73 75.00 -0.30 0 150 25086 676 673 348 63 902.54 8190 3.28 75.00 -0.30 0 150 25185 696 713 571 93 822.56 8190 1.25 -75.00 -0.30 150 0 25280 696 711 633 89 753.12 8191 0.63 -75.00 -0.30 150 0 25379 667 717 667 88 685.37 574 0.33 -75.00 -0.30 150 0 25479 673 650 667 60 686.83 8191 0.06 30.00 -0.30 45 105 25577 742 736 643 61 681.45 8190 0.99 30.00 -0.30 45 105 25674 796 782 673 54 690.36 8190 1.23 75.00 -0.30 0 150 25773 830 810 694 48 710.01 8190 1.29 75.00 -0.30 0 150 25869 582 643 721 37 756.88 -1.08 -75.00 -0.30 0 150 25966 545 579 615 34 807.42 -0.70 -75.00 -0.30 0 150 26066 493 523 553 33 837.20 -0.56 75.00 -0.30 150 0 26166 468 488 499 22 879.26 -0.31 75.00 -0.30 150 0 26262 446 499 502 25 859.92 -0.64 75.00 -0.30 150 0 26361 441 523 508 23 900.38 -0.67 -74.26 -0.30 0 149 26459 467 519 544 22 927.31 -0.90 -74.26 -0.30 0 149 bObstacleAhead TRUE in TRACKRIGHT at 26556 with frontdist 15, variance = 874.38 backing up to 30 using front distance sensor backed up successfully to 35 using front distance sensor In SpinTurn(CCW, 90.00) Msec Hdg PrevHdg Rate Set Out Spd |
Here’s an Excel plot of the Right side center distance and L/R motor speeds vs time.
Comparing the times from the video and the telemetry, it appears the video time is about 3-3.5 sec lower than the telemetry values. In the video, Wall-E2 detects the first upcoming wall at about 9 sec, and this corresponds with the telemetry at 12.358 where the wall is detected with front distance of 19cm. The reason the wall didn’t get detected earlier is the robot was currently tracking back toward the wall with a steering value of -0.3, and this causes the wall detection value to be reduced to suppress false positives.
The robot then takes 2 sec to back up to 33 cm and turn 90 deg CCW, and then it starts tracking the right-side wall again. It detects the next wall at 17.1 sec (14 sec in video) and 30 cm (the steering value at that point was 0.10, so no reduction in upcoming obstacle detection distance). Because the detection occurred at 30 cm, the robot doesn’t need to back up; it just makes another 90 deg spin turn CCW and starts tracking the right-side wall again. The last segment clearly shows that Wall-E2 is capable of tracking to and capturing the desired offset of 30 cm.
All in all, a very successful right-side sandbox run.
Stay tuned!
Frank
Pingback: Wall Tracking Trials Using Office ‘Sandbox’ Part II | Paynter's Palace