Coding Issue, getting the robot to demonstrate the solution

Hello I’ve been having issues getting the 3pi to demonstrate the solution correctly

The robot explores the maze correctly, using a slightly modified version of the demo maze exploration code. And as far as I can tell, it records the correct solution: ie the turns that the robot should make are correctly displayed on the lcd screen, so I’m assuming my maze length and turn storage is working correctly

But, when demonstrating a solution (L,S,[end of maze]) the robot will get to the first junction, carry straight on instead of turning left, and exits the “for” loop which it should repeat (as it makes the finish noise which is inserted after the loop for debugging purposes)

I have tried comparing my code to the example code, but apart from variable names I cannot spot any differences that should affect the output from the robot.
The variable “solution” is a char array and stores the route. The variable “juncnum” is a unsigned char and stores the number of junctions.

{
		set_motors(0,0);
		display_solution();
		play_from_program_space(finish);
		delay_ms(200);

		while(!button_is_pressed(BUTTON_B));
		while(button_is_pressed(BUTTON_B));
		delay_ms(1000);
		int i;
		for(i=0;i<juncnum;i++);
		{
			linefollow();
			set_motors(50,50);
			delay_ms(50);
			set_motors(40,40);
			delay_ms(200);
			turn(solution[i]);				
		}
		play_from_program_space(finish);
		linefollow();
}

Is there a way I can output the maze length (the unsigned char “juncnum”) to the LCD screen to check this is not the cause of the issue? I have tried simply outputting the variable to the screen but this didn’t work.

Can anyone think why the robot would not turn the correct way even though the LCD displays the correct solution?
And would a youtube video help in this diagnosis?

Here is a zip of my code, I’ve stripped back some of the functionality to the bare basics
5LhrMazeSolDemo.zip (114 KB)

Hello.

Does the example code work fine for you? I would recommend generating a diff between the two projects to find exactly what all the differences are. If you still do not see what the problem is, start with the example code, and add the differences back in one by one testing it each time until you find what change introduces the problem.

- Ryan

Cheers Ryan, yes the example code works just fine.

I’ve been looking at a comparison between the two, still can’t figure out what’s up. But I’ll get back to you guys if I do.