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:
- 52:79f21d15ede1
- Parent:
- 51:3148875bb9e5
- Child:
- 53:dbb63b181faf
--- a/main/main.cpp Fri Apr 17 16:50:10 2020 +0000 +++ b/main/main.cpp Fri Apr 17 19:07:29 2020 +0000 @@ -478,7 +478,18 @@ // if it does, check the number of nodes between before and after // which ever is shorter, set the 0 of those nodes -// int short_length = dead_end_removal(point[d_node], point[curr_node]); + //robot.stop(); +// char buf1[2], buf2[2]; +// sprintf(buf1,"%d",point[d_node]); +// sprintf(buf2,"%d",point[curr_index]); +// robot.lcd_print(buf1,2); +// wait(2); +// robot.lcd_clear(); +// robot.lcd_print(buf2,2); +// wait(2); +// robot.lcd_clear(); +// +// int short_length = dead_end_removal(point[d_node], point[curr_index]); // char dir_diff; // // for(int j = short_length; j > 0; j--) { @@ -617,9 +628,7 @@ // dead end removal between start and final node // add the inverse of the result to end of the looped_path // then separate into before and after, simplify both and compare - robot.stop(); - int index1, index2; int d_index, before_index, after_index; bool before = false; @@ -627,9 +636,9 @@ bool desired_discovered = false; for(int k = 0; k <= path_length; k++) { - if(looped_path[k] == point[point1]) { desired_discovered = true; d_index = k; } // maybe set a variable - if(desired_discovered == false && looped_path[k] == point[point2]) { before = true; before_index = k; } - if(desired_discovered == true && looped_path[k] == point[point2]) { after_index = k; break; } + if(looped_path[k] == point1) { desired_discovered = true; d_index = k; } // maybe set a variable + if(desired_discovered == false && looped_path[k] == point2) { before = true; before_index = k; } + if(desired_discovered == true && looped_path[k] == point2) { after_index = k; break; } } if(before){ @@ -657,11 +666,11 @@ int length = index2 - index1; - char buffer[3]; - sprintf(buffer,"%d", length); - robot.lcd_print(buffer,3); - wait(2); - robot.lcd_clear(); +// char buffer[3]; +// sprintf(buffer,"%d", length); +// robot.lcd_print(buffer,3); +// wait(2); +// robot.lcd_clear(); // for every node in path, check if repeated // if rpeated, move everyting before the first occurence to the final occurence @@ -700,15 +709,15 @@ i++; } - leds = 0b1111; - for(int m = 0; m <= length; m++) { - leds = ~leds; - char buffer[3]; - sprintf(buffer,"%d", shortest[m]); - robot.lcd_print(buffer,3); - wait(2); - robot.lcd_clear(); - } +// leds = 0b1111; +// for(int m = 0; m <= length; m++) { +// leds = ~leds; +// char buffer[3]; +// sprintf(buffer,"%d", shortest[m]); +// robot.lcd_print(buffer,3); +// wait(2); +// robot.lcd_clear(); +// } return length; // print these to check // add inverted sub path to the real path and increment the path length by real_len -1 @@ -994,12 +1003,12 @@ wait(0.2); leds = 0b0110; wait(0.2); - na = dead_end_removal( point[3], point[2] ); + na = dead_end_removal( point[2], point[1] ); leds = 0b1001; wait(0.2); leds = 0b0110; wait(0.2); - na = dead_end_removal( point[2], point[3] ); + na = dead_end_removal( point[4], 100 ); while( button_enter.read() == 1 ) { leds = 0b1001; wait(0.2);