Example 2: Bicycle Model ====================== This example demonstrates how to use Arena with a two-corridors scenario and bicycle vehicle. .. figure:: /_static/images/example2_figure1.png :width: 100% :align: center :alt: Example of a two-corridor setup .. literalinclude:: example_bicycle.py :language: python :linenos: :caption: example_bicycle.py Step 1 — Corridors definition ------------------------------- We define the two corridors using the function ``get_corridor_from_vector``. This helper function simplifies corridor placement by constructing a corridor directly from a vector: given the corridor width and the tail and head points of a vector, it creates a corridor that is aligned with the vector and has the same length (optionally extended by a margin). This makes it straightforward to build consecutive corridors. .. literalinclude:: example_bicycle.py :language: python :lines: 14-45 Step 2 — Initial and final pose definition --------------------------- We define the initial and final poses in the **local reference frames** of the shrunken corridors. Each corridor has a corresponding shrunken version, with the same center and orientation but reduced width and length by ``2r``, where ``r`` is the robot footprint radius. In this local frame: - ``x`` and ``y`` range from ``-1`` to ``1`` inside the corridor bounds - ``θ = π/2`` corresponds to an orientation aligned with the corridor Defining poses in these normalized coordinates ensures that the start and goal always lie inside the feasible corridor region, making the specification intuitive and preventing invalid pose definitions. Then these poses are passed to the motion planner directly. .. literalinclude:: example_bicycle.py :language: python :lines: 47-62 Step 3 — Bicycle vehicle definition --------------------------- Next, we instantiate a ``Bicycle`` object using the user-defined vehicle parameters. .. literalinclude:: example_bicycle.py :language: python :lines: 64-79 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. Note that the relative poses are provided via the keywords ``relative_start_pose`` and ``relative_end_pose`` to the ``MotionPlanner`` object. .. literalinclude:: example_bicycle.py :language: python :lines: 81-88 Step 5 — Plot the results --------------------------- Finally we plot the resulting path and control profiles. .. literalinclude:: example_bicycle.py :language: python :lines: 90-96