Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a matlab function that helps a robot can traverse through a maze avoiding

ID: 2293826 • Letter: W

Question

Write a matlab function that helps a robot can traverse through a maze avoiding any
collision with the wall.
(a) Code runs without error (10 points)
(b) Code satisfies the specification (15 points)

Explanation / Answer

function visibility = line_of_sight(observer_state, current_target_node, external_boundaries) %Functions determines whether the current target node is visible from the %current observer position %Dissect observer state into coordinates x_observer = observer_state(1); y_observer = observer_state(2); %Dissect current target node ccordinates x_current_target = current_target_node(1); y_current_target = current_target_node(2); %Create empty distance array and initialize counter distance_array = zeros(1,size(external_boundaries,1)); i = 0; for k = 1:1:size(external_boundaries,1) if k = 0) if p >= 0 if (y_2 - y_1) == 0 %Check if wall is horizontal %find q (intersection position along wall vector) q = ( x_observer - x_1 + p*(x_current_target - x_observer) )/(x_2 - x_1); elseif (x_2 - x_1) == 0 %Check if wall is vertical %find q q = ( y_observer - y_1 + p*(y_current_target - y_observer ) )/(y_2 - y_1); else %If wall is neither vertical nor horizontal %find q q = ( y_observer - y_1 + p*(y_current_target - y_observer ) )/(y_2 - y_1); %Can use any of the two previous equations for calculating q end %Check if intersection happened within the wall ends if q >= 0 && q
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote