In automated driving toolbox, how can I make an ego vehicle stop and rotate at stationary position?
2 views (last 30 days)
Show older comments
Hello, I am simulating path planning for a line follower with automated driving toolbox. Since it cannot deviate from the line, it has to be able to rotate by 90degrees to turn left or right at a corner. But, I cannot figure out how to make it rotate at stationary position. Could you kindly expain how to achieve it please?
Thank you!
0 Comments
Answers (1)
Vishnu
on 10 Jul 2023
Hi Jiwoo, to make your line follower rotate by 90 degrees at a stationary position, you can utilize the differential drive controller and the Pure Pursuit path following algorithm
distanceToGoal = norm(robotInitialLocation - robotGoal);
while(distanceToGoal > 0.1) % Adjust the threshold according to your requirements
% Update the robot's pose and compute the desired linear and angular velocities
robotCurrentPose = [robot.CurrentPose(1:2) robotCurrentPose(3)];
[v, omega] = pathFollower(robotCurrentPose);
% Check if the robot is near a corner to perform the rotation
currentWaypoint = pathFollower.CurrentWaypoint;
if currentWaypoint == size(waypoints, 1) && distanceToGoal < 0.5 % Adjust the threshold according to your requirements
v = 0; % Set linear velocity to zero to stop the robot
omega = pi/2; % Set angular velocity to rotate 90 degrees
end
% Drive the robot based on the computed velocities
drive(robot, v, omega);
% Update the distance to the goal
distanceToGoal = norm(robot.CurrentPose(1:2) - robotGoal);
% Pause for a short duration to visualize the motion
pause(0.1);
end
or else
% Get current heading
currentHeading = getCurrentHeading();
% Calculate desired heading
desiredHeading = currentHeading - 90; % For a left turn
% Rotate the line follower
rotate(lineFollower, desiredHeading);
Make sure to replace getCurrentHeading() with the appropriate function or method to obtain the current heading of your line follower. Adjust the code accordingly for a right turn by adding 90 degrees instead of subtracting.
0 Comments
See Also
Categories
Find more on Robotics in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!