Example 2: Multiple Corridors ====================== This example demonstrates how to use Arena with a multiple-corridors scenario. .. figure:: /_static/images/example3_figure1.png :width: 100% :align: center :alt: Example of a two-corridor setup .. literalinclude:: example_multiple_corridors.py :language: python :linenos: :caption: example_multiple_corridors.py Step 1 — Corridors definition ------------------------------- We first define five corridors through the function ``get_corridor_from_vector``, particularly useful for longer sequences of corridors. .. literalinclude:: example_multiple_corridors.py :language: python :lines: 16-64 Step 2 — Unicycle vehicle definition --------------------------- Next, we instantiate a ``Unicycle`` object by loading a predefined model from Arena’s unicycle library. In this case, the user does not need to manually specify the vehicle parameters. If a parameter needs to be adjusted, the ``update()`` method of the ``Unicycle`` object can be used, as shown below. .. literalinclude:: example_multiple_corridors.py :language: python :lines: 66-70 Step 3 — Initial and final pose definition --------------------------- The initial and final poses can be conveniently obtained using the functions ``compute_start_pose()`` and ``compute_end_pose()``. These functions place the vehicle along the centerline of the corresponding corridor while automatically enforcing a collision-free positioning. - ``compute_start_pose()`` positions the vehicle in the **first corridor**. The pose is computed by taking the midpoint of the *back* face of the corridor and shifting it forward by half the vehicle length plus an optional safety margin. The orientation is aligned with the corridor direction. - ``compute_end_pose()`` performs the analogous operation in the **last corridor**, starting from the midpoint of the *front* face and shifting backward by the same offset. Using these helper functions ensures that the start and goal configurations always lie inside their respective corridors. .. literalinclude:: example_multiple_corridors.py :language: python :lines: 72-74 Step 4 — Create the Motion Planner and compute the trajectory --------------------------- Now we instantiate the ``MotionPlanner`` object and use the ``compute_trajectory_analytical()`` method to find the solution trajectory. .. literalinclude:: example_multiple_corridors.py :language: python :lines: 76-80 Step 5 — Plot the results --------------------------- Finally we plot the resulting path and control profiles. .. literalinclude:: example_multiple_corridors.py :language: python :lines: 82-87