Tutorial 2: Variational Trajectory Planning - Build a motion planner and upload benchmark solutions

This tutorial shows how you can plan trajectories in CommonRoad scenarios by solving an optimization problem and easily create a benchmark solution file for upload the solution to commonroad.in.tum.de. We therefore use the CommonRoad scenario 'ZAM_Tutorial-1_2_T-1.xml' which was created in Tutorial 1.

Task of the Ego Vehicle

The ego vehicle has the following specification in our scenario:

The following physical constraints apply to the ego vehicle:

The task of the ego vehicle is to reach its target velocity of 30.0 m/s without colliding with other obstacles.

Exercise 0: Read the created CommonRoad scenario

The CommonRoadFileReader reads the Scenario and the PlanningProblemSet from a CommonRoad XML-file. Please read the scenario from the CommonRoad file.

Helper Functions for visualization

First, make sure that the required packages are installed. The following functions are necessary for this tutorial.

Variables of the Optimization Problem

We use the convex optimization package cvxpy to formulate our optimization problem. The following code initializes all necessary variables such as the state and input vector as well as the cost matrices.

Exercise 1: Consider the vehicle model

In order to obtain kinematically feasible motion plans, the optimization problem needs to respect the constraints of the vehicle model. We use a linear vehicle model, which can be written in the following state-space form: $$x_{k+1} = A x_k + B u_k.$$ Please fill the matrices A and B according to the fourth-order point-mass model, discretized using the time step dT.

Formulation of the Optimization Problem

We are now able to formulate the optimization problem. Please set the initial state of the ego vehicle with a velocity of 0 m/s and its reference velocity. Subsequently, we create the cost terms and constraints of the optimization problem.

Exercise 2: Consider additional constraints

The obtained trajectory reaches the desired reference velocity of the ego vehicle. However, the physical constraints are not fulfilled. Please add the physical constraints to the optimization problem in order to obtain kinematically feasible trajectories.

Exercise 3: Extract the prediction of obstacles

In our scenario, the ego vehicle is surrounded by two other traffic participants -- one following and one leading vehicle. In order to not cause a collision with these two vehicles, we need to consider the positions of the two vehicles in our optimization problem. Please obtain the minimum and maximum feasible position of the ego vehicle for each point in time. Please note that each obstacle has a certain shape.

Exercise 4: Plan the motion of the ego vehicle

The obtained collision constraint allow us to avoid collisions with the following and leading vehicle. Please add the constraints to our optimization problem and obtain a trajectory.

Exercise 5

We have successfully planned the motion of the ego vehicle. Please convert the ego vehicle to a dynamic obstacle and visualize the scenario and the motion of the ego vehicle for each time step.

Exercise 6

Now that we have the planned trajectory and motion of our vehicle, we are ready to write the scenario to a benchmark solution file. This can be done by using the Solution Writer provided by Commonroad. A solution file requires a trajectory for the planning problem and IDs for vehicle model, vehicle type, and the scenario ID. Remember, we used a point-mass vehicle model (PM) and the parameters for VW_VANAGON (vehicle type 3). For the cost function, we choose WX1 (see documentation).

After running the following code, you will find a file automatically named in the following format according to the definition from our paper:

solution_{VehicleModel&VehicleType}:{CostFunctionID}:{scenario_id}:{ScenarioVersion}.xml

In this case, the file will be named solution_PM3:SM3:ZAM_Tutorial-1_2_T-1:2020a.xml and it is ready to be submitted on the submissions page.

Exercise 7

To submit the CommonRoad solution, you need to create an account and afterwards a submission here.

Select the file generated in the previous step and submit your solution. After uploading, you can check your score before publishing your solution.

Finally, you can compare your result against others in the ranking!