Tracing a square path

After moving the robot in different directions, let's make the rover trace a square path. To do this, our robot will move as follows: forward -> right turn -> forward -> right turn -> forward -> right turn -> forward -> stop:

Inside the LaptopControlRover program, we will create another if condition. Inside this if condition, we will write a program to make the robot trace a square path. The if condition will look as follows:

if(keypressed == 'r' || keypressed == 'R'){forward(); //first forward movementdelay(2000);rightturn(); //first left turndelay(500); //delay needs to be such that the robot takes a perfect 90º right ...

Get Hands-On Robotics Programming with C++ now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.