Question: An autonomous robot is being designed to step through a simple 2D obstacle course (that is a flat maze). For each step, the robot scans

An autonomous robot is being designed to step through a simple 2D obstacle course (that is a flat maze). For each step, the robot scans three points: to the left, in front, and to the right. The robot stores the results of the scan in a 1x3 vector (v) where each cell is occupied by either a 0 if no wall is scanned or a 1 if a wall is scanned. When there is no wall is in front of the robot, then the robot continues to step forward. When the front of the robot is blocked, then the robot turns to face the direction without a wall present. If the robot could turn left or right, then it chooses a random direction - Hint: randi([2,3]) will randomly select 2 or 3. When the robot reaches a dead end, the robot turns by 180 degrees and steps back the way it came.An autonomous robot is being designed to step through a simple 2D

Function Overview An autonomous robot is being designed to step through a simple 2D obstacle course (that is a flat maze). For each step, the robot scans three points: to the left, in front, and to the right. The robot stores the results of the scan in a 1x3 vector (v) where each cell is occupied by either a 0 if no wall is scanned or a 1 if a wall is scanned. When there is no wall is in front of the robot, then the robot continues to step forward. When the front of the robot is blocked, then the robot turns to face the direction without a wall present. If the robot could turn left or right, then it chooses a random direction Hint: randi ([2,3]) will randomly select 2 or 3. When the robot reaches a dead end, the robot turns by 180 degrees and steps back the way it came. Write a code that outputs the direction an autonomous robot should travel in, given obstruction data is provided as an input Function Inputs V A 1x3 vector containing obstruction data. Function Outputs Direction Represents the direction the robot should travel in. 1, 2, 3, 4 represent 'go straight,'turn left,'turn right' and 'turn around' respectively. Function Template function Direction-robot_direction(v) % INSERT CODE HERE end Function Example robot direction ( [0, 1, 11) should return 2. robot direction( [,0, 1] ) should return 1 Additional Notes Useful functions and commands include: if, elseif, else, randi

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!