Line Robot - Basic lessons - Exercises - Wall following with 1 sensor
This is one more skill needed for RCJ Rescue Line competition.
Task: follow a wall.
Program Your robot to follow right wall. If You assembled and set-up the robot according to the instructions, You will read the right lidar with command
rightFront()
Solution
void loop(){
if (rightFront() > 100)
go(80, 20);
else
go(20, 80);
}
If distance between the sensor and the right wall is more than 100 (mm), left motor will have speed 80, the right one 20. Therefore, the robot will be turning towards the wall, trying to decrease the distance. In the opposite case, the distance is 100 or less, it will be turning away from the wall. Adjust the parameters to get optimal trajectory.