Question: I need help creating code for a robot that will be going down a hallway and needs to stop 1 meter before hitting the end

I need help creating code for a robot that will be going down a hallway and needs to stop 1 meter before hitting the end of the hallway. The robot is placed at a random initial point and needs to center it's self and go straight while using a lidar scan.
```
function [u, stop, info]= robot_guidance(t, lidar_scan, wheel_encoders, info)
% robot guidance function
This will be called by the sim / robot interface. This function receives
sensor data which you can use to compute wheel speed commands that will be
used to steer the robot down the corridor. Output should be the rotation rate
of each wheel in rad/s. The example code here creates a randomly driving
robot.
Arguments:
t -- the current time (in seconds). Zero is the unix epoch (midnight
GMT on 1970-01-01)
lidar_scan -- a structure with fields:
.lidar_theta - a vector of angles (rad) where there is a lidar distance
reading available. An angle of 0 is straight ahead of the robot.
The axis of rotation is vertically "up" and rotations are
right-handed.
.lidar_range - a vector of distance readings from the lidar (m)
corresponding to the angles in lidar_range
wheel_encoders -- a structure with fields:
.left -- encoder count for rotation of the left wheel. Positive is the
robot moving forward.
.right -- encoder count for rotation of the right wheel. Positive is
the robot moving forward.
Returns:
u -- a 1 x 2 array giving the commanded rotation rate (rad / s) for the
left and right wheels. Left wheel should go in the first entry and
right in the second.
stop -- boolean, true if you want the robot to stop because you have
finished your task. False if you want to keep going
info -- anything you want to save. This will loop back in (the outer
managament code will give it back to you next time this function runs)
so if you need to keep track of anything between runs you can put it in
here. Make it an array, cell array, structure, whatever you like.
```
I need help creating code for a robot that will

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 Programming Questions!