Example 1: Hello World ====================== .. figure:: /_static/images/example1_figure1.png :width: 100% :align: center :alt: Example of a two-corridor setup This example demonstrates how to use Arena with a simple scenario. .. literalinclude:: hello_world.py :language: python :linenos: :caption: hello_world.py Step 1 — Corridors definition ------------------------------- To begin, we define the geometric properties for two corridors. Each corridor is represented as a rectangle, and is defined by its width, length, center point and orientation. Then, we instantiate two ``CorridorWorld`` objects with the defined parameters and place them in a list that defines the order in which the vehicle will navigate them. .. literalinclude:: hello_world.py :language: python :lines: 4-26 Step 2 — Vehicle definition --------------------------- Next, we define the characteristics of a unicycle vehicle, and instatiate the ``Unicycle`` object. .. literalinclude:: hello_world.py :language: python :lines: 28-41 Step 3 — Initial and Final Pose definition --------------------------- The start and end poses of the vehicle are represented as lists with three elements: ``x, y, θ``. These correspond to the position in the plane (``x`` and ``y``) and the vehicle’s orientation ``θ`` (in radians). It is important to provide consistent values, as the planner will deliver trajectories only if the initial position lies within the first corridor and the final position lies within the last corridor in ``corridor_list``. .. literalinclude:: hello_world.py :language: python :lines: 43-45 Step 4 — Create the Motion Planner and compute the trajectory --------------------------- With all the elements for the motion planning problem ready, we can instantiate the ``MotionPlananer`` object, and compute the trajectory by using its method ``compute_trajectory_analytical()``. .. literalinclude:: hello_world.py :language: python :lines: 47-51 Step 5 — Plot the results --------------------------- Finally, we can easily plot the results by creating a ``figure`` with the method ``plot_planner_inputs()``. Then the function ``plot_analytical_trajectory()`` plots the solution path in the ``figure``. The function ``plot_velocity_profiles()`` instead creates a new figure showing the control profiles. .. literalinclude:: hello_world.py :language: python :lines: 53-60