Question: Using EyeSim app, give the code to drive the robot in a lawnmower pattern. Use the code below to help. The below code is to;drive
Using EyeSim app, give the code to drive the robot in a lawnmower pattern. Use the code below to help.
The below code is to;drive the robot straight and collisionfree close to the
wall in front, then turn to the right, so it is parallel to the wall at the robots lefthand side in about cm distance.
#include "eyebot.h
int main
drive to wall
VWSetSpeed;
while true
if PSDGet
VWSetSpeed;
break;
int PSDOld ;
VWSetSpeed;
parallel to wall
while true
int PSDNew PSDGet ;
if PSDOld PSDNew
VWSetSpeed ;
break;
PSDOld PSDNew;
The below code is to: drive one complete and collisionfree loop around the driving area, always keeping a similar distance to the wall on the lefthandside of the robot.
#include "eyebot.h
void driveToWall
VWSetSpeed;
while true
if PSDGet
VWSetSpeed;
break;
return;
void driveParallelToWall
VWSetSpeed;
while true
if PSDGet
VWSetSpeed;
break;
int leftPSD PSDGet ;
if leftPSD
VWSetSpeed; Turns slightly right
else if leftPSD
VWSetSpeed; Turns slightly left
else
VWSetSpeed; Goes straight
return;
int main
driveToWall;
parallel to wall
int PSDOld ;
VWSetSpeed;
while true
int PSDNew PSDGet ;
if PSDOld PSDNew
VWSetSpeed ;
break;
PSDOld PSDNew;
for int i ; i ; i
driveToWall;
VWTurn; tweak value as it wont be exact
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
