Help to 3pi at at Rhombus path

Dear All

Have a nice day

Please advice what are the modification to be done when 3pi traveling bellow image. In my program our robot rotate inside the rhombus with simple Maze solver

Question 2 Code belong to simple Maze solver
As per the bellow code 3pi stop when 3 inner sensor get in the black but it has break how does it break without motor stop and I want to set the robot travel 10cm once all five sensor in the dark SO please advice where I should insert the code

// Check for the ending spot.
    // If all three middle sensors are on dark black, we have
    // solved the maze.
    if (sensors[1] > 600 && sensors[2] > 600 && sensors[3] > 600)

Please help
Thanks in advance


Please provide more details on what you are trying to do and what strategies have you tried so far. In addition, it might help to post the code you have been working on.

Regarding your second question, the break statement is used to exit from the nearest loop (or switch) statement; break does not stop the motors on the 3pi. To stop the motors, you should use set_motors(0,0). I suggest looking at turn.c for the 3pi-mazesolver example in the Pololu AVR C/C++ library to see the difference between setting the speed of the 3pi motors and using break to exit the switch statement. Since you seem new to it, I recommend strengthening your understanding of C/C++ programming. There should be plenty of resources and tutorials out there.

If you want to stop the 3pi when all five of its sensors detect black, you could use the following code:

if (sensors[0] > 600 && sensors[1] > 600 && sensors[2] > 600 && sensors[3] > 600 && sensors[4] > 600)

- Amanda

Dear Amanda Thanks for the reply and advice

We are getting ready for school robot competition it has rhombus path as showing in my first post image

We modify the following codes as per our motor speed and our robot 90 degree and 180 degree get very sharp turn but at the rhombus start it turn 90 degree

OrangutanMotors::setSpeeds(-100, 100);
  case 'R':
    // Turn right.
    OrangutanMotors::setSpeeds(100, -100);
  case 'B':
    // Turn around.
    OrangutanMotors::setSpeeds(100, -100);
  case 'S':
    // Don't do anything!

The strategies what we have taken

We change turn right delay one quarter of 90 degree as per the following codes then rhombus path following approximately Ok but at the intersection of angle the robot move to out of the line due to drift delay

// Turn right.
    OrangutanMotors::setSpeeds(80, -80);

finally we change following code to reduce drift the robot at the 90 degree then robot stop at the intersection since we are using 3cm width black path

// Drive straight a bit.  This helps us in case we entered the
    // intersection at an angle.
    // Note that we are slowing down - this prevents the robot
    // from tipping forward too much.
    OrangutanMotors::setSpeeds(50, 50);

Please advice to have success the project

Dear Amanda

It would be much appreciated if you can provide us a one more strategies to follow a rhombus in the Mazeline follower

Thanks in advance

It really sounds like you need to add some code to help distinguish between the rhombus part and the rest of your course. Also, it sounds like you are just modifying the code in turn.c, which affects all turns in the program, so you would need to add some conditions separating the speeds and delays for the rhombus segment from the regular turn segments. How you go about doing that is up to you.

- Amanda

1 Like

Dear Amanda Thanks for the reply and advice

We noticed that the sensor output at the rhombus start as same as a intersection. So it is so hard to think condition which can be applied for the turn section . Since you all have good experience can you please advice a condition that we will be able to code it

Please advice

Thanks in advanced

I do not have any specific suggestions.

- Amanda