Line following AGV Simulation Issue

17 visualizzazioni (ultimi 30 giorni)
METIN REHA
METIN REHA il 1 Ago 2024
Risposto: Umar il 28 Ago 2024
I'm planning to simulate a warehouse with line following AGVs. I would like the warehouse as the one in Mobile Robotics Simulation Toolbox. However, instead of using probabilistic methods, I want each robot to strictly follow predefined paths/lines without deviating. How can I configure these paths and ensure the robots follow them while avoiding collisions with each other? Thank you

Risposte (1)

Umar
Umar il 28 Ago 2024

Hi @METIN REHA ,

Let me address your query regarding, “I'm planning to simulate a warehouse with line following AGVs. I would like the warehouse as the one in Mobile Robotics Simulation Toolbox. However, instead of using probabilistic methods, I want each robot to strictly follow predefined paths/lines without deviating. How can I configure these paths and ensure the robots follow them while avoiding collisions with each other? Thank you”

Please see my response to your comments below.

After studying the following documentations at links mentioned below regarding your task to achieve the simulation in your mentioned comments, I had to come up with a structured approach, focusing on defining the paths for the AGVs and implementing strict adherence to these paths while avoiding collisions.

https://www.mathworks.com/help/releases/R2024a/robotics/ug/control-and-simulate-multiple-warehouse-robots.html?s_tid=doc_srchtitle

https://www.mathworks.com/help/releases/R2024a/robotics/ug/path-following-for-differential-drive-robot.html#PathFollowingControllerExample-1

Below is a step-by-step guide, along with relevant code snippets to help you implement this.

Step 1: Create the Warehouse Scenario

You will begin by creating a warehouse scenario using either static meshes or SDF models. This involves defining the layout of the warehouse and placing any necessary obstacles.

% Create a robotScenario object
scenario = robotScenario(UpdateRate=10);
% Add ground plane
addMesh(scenario,"Plane",Position=[5 0 0],Size=[20 12],Color=[0.7 0.7 0.7]);
% Add shelves as static box meshes
addMesh(scenario,"Box",Position=[3 5 2],Size=[4 2 4],Color=[1 0.5   
0.25],IsBinaryOccupied=true);
addMesh(scenario,"Box",Position=[3 -5 2],Size=[4 2 4],Color=[1 0.5 
0.25],IsBinaryOccupied=true);

Step 2: Add Mobile Robots to the Scenario

Next, add your AGVs (robot platforms) to the scenario.

% Load mobile robot model
[pioneerRBT,pioneerRBTInfo] = loadrobot("amrPioneer3DX");
% Define loading and unloading positions
loadingPosition = [0 0];
unloadingPosition = [10 0];
% Create robot platforms
robotA = robotPlatform("MobileRobotA", scenario, RigidBodyTree=pioneerRBT,   
InitialBasePosition=[loadingPosition,0]);
robotB = robotPlatform("MobileRobotB", scenario, RigidBodyTree=pioneerRBT, 
InitialBasePosition=[unloadingPosition,0]);

Step 3: Define Predefined Paths

Define the paths that your robots will follow. You can do this by specifying waypoints for each robot:

% Define waypoints for Robot A (loading to unloading)
pathA = [loadingPosition; [5, 0]; unloadingPosition];
% Define waypoints for Robot B (unloading to loading)
pathB = [unloadingPosition; [5, 0]; loadingPosition];

Step 4: Implement Path Following Control

Use a controller that ensures robots follow their respective paths strictly without deviation.

% Create controllers for path following
controllerA = controllerPurePursuit;
controllerA.Waypoints = pathA;
controllerA.DesiredLinearVelocity = 0.6;
controllerA.MaxAngularVelocity = 2;
controllerA.LookaheadDistance = 0.3;
controllerB = controllerPurePursuit;
controllerB.Waypoints = pathB;
controllerB.DesiredLinearVelocity = 0.6;
controllerB.MaxAngularVelocity = 2;
controllerB.LookaheadDistance = 0.3;

Step 5: Collision Avoidance Logic

To prevent collisions between robots while they follow their paths, implement a simple avoidance mechanism. This can be done using distance checks between robots:

while true
  % Get current poses of robots
  robotAPose = getCurrentPose(robotA);
  robotBPose = getCurrentPose(robotB);
    % Check distance between robots and adjust speed if too close
    distanceBetweenRobots = norm(robotAPose(1:2) - robotBPose(1:2));
    if distanceBetweenRobots < thresholdDistance % define thresholdDistance 
    based on your requirements
        % Slow down or stop one of the robots to avoid collision
        controllerA.DesiredLinearVelocity = max(0,   
    controllerA.DesiredLinearVelocity - decelerationRate);
    end
    % Update robot positions based on controllers
    % Your logic here for moving robots...
  end

Since you mentioned in your comments about not using probabilistic methods, make sure that your predefined paths are well-defined and do not overlap at any point unless intended. Try to adjust parameters such as LookaheadDistance, DesiredLinearVelocity, and MaxAngularVelocity based on your simulation needs and robot dynamics.

Now, if you plan on running this simulation in real-time, keep in mind to make sure that update loop is efficient to handle any real-time constraints imposed by the simulation environment and utilize visualization tools within MATLAB to monitor both the planned and actual paths of the robots during simulation for debugging purposes.

By following these steps and code snippets, it should help you get started to accomplish your task. Hope this answers your question. Please let me know if you have any further questions.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by