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.
Dependencies: mbed 3875_Individualproject
Diff: main/main.cpp
- Revision:
- 47:745c8846a92d
- Parent:
- 46:c770365cf5a6
--- a/main/main.cpp Thu Apr 16 06:25:18 2020 +0000 +++ b/main/main.cpp Thu Apr 16 16:25:02 2020 +0000 @@ -650,6 +650,73 @@ wait(1/50); } + + //// basic requirement is to add a valid path from the curr node to the start node +// // if possible traverse this path back to the start then end +// +// // create a sub array of nodes between start and curr node +// // remove all dead ends and repeated nodes +// // add that array to the end of the path +// +// char sub_path[100]; +// char prev_nodes[100]; +// int prev_length = 0; +// int sub_length = 0; +// int index1; +// int index2; +// +// for(int i = 0; i <= path_length; i++) { +// sub_path[i] = looped_path[i]; +// if( looped_path[i] == point[curr_index] ) { sub_length = i; break; } +// } +// +// bool error = true; +// +// while (error) { +// for(int i = 0; i <= sub_length; i++) { +// bool in_prev = false; +// for( int l = 0; l<=prev_length; l++ ) { +// if( sub_path[i] == prev_nodes[l] ) { in_prev = true; } +// } +// if( in_prev ) { +// index1 = i; +// for(int j = 0; j <= sub_length; j++){ +// if(sub_path[j] == sub_path[index1]) { +// index2 = j; +// break; +// } +// } +// break; +// } else if( sub_path[i] != NULL ) { +// prev_length++; +// prev_nodes[prev_length] = sub_path[i]; +// } +// } +// +// // set all nodes between the indexes to null +// for( int k = index1+1; k <= index2; k++ ) { +// sub_path[k] = NULL; +// } +// int real_len = 0; +// for( int x = 0; x <= sub_length; x++ ) { +// if( sub_path[x] != NULL ) { real_len++; } +// } +// +// if( prev_length == real_len ) { error = false; } +// +// } +// +// leds = 0b1111; +// for(int m = 0; m <= sub_length; m++) { +// leds = ~leds; +// char buffer[1]; +// sprintf(buffer,"%d", sub_path[m]); +// robot.lcd_print(buffer,1); +// wait(3); +// robot.lcd_clear(); +// } +// // print these to check +// // add inverted sub path to the real path and increment the path length by real_len -1 } void follow_line()