Skip to content

Configuration

ConfigurationBuilder

Builds configuration

Source code in commonroad_velocity_planner/configuration/configuration_builder.py
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
class ConfigurationBuilder:
    """
    Builds configuration
    """

    @staticmethod
    def get_predefined_configuration(
        planner_config: PlannerConfig = PlannerConfig.DEFAULT,
    ) -> VelocityPlannerConfig:
        """
        Builds predefined velocity planner config
        :param planner_config: planner config
        :return: velocity planner config object
        """
        if planner_config == PlannerConfig.DEFAULT:
            retconf: VelocityPlannerConfig = ConfigurationBuilder.build_default_config()

        else:
            raise NotImplementedError(f"The config {planner_config} is not implemented")

        return retconf

    @staticmethod
    def build_velocity_config(
        optimization_config: OptimizationConfig,
        vehicle_config: VehicleConfig,
        a_min: float,
        a_max: float,
        a_lateral_max: float,
        j_min: float,
        j_max: float,
        v_min_driving: float,
        v_max_street: float,
    ) -> VelocityPlannerConfig:
        """
        Build velocity planner config
        :param optimization_config: optimization config
        :param vehicle_config: vehicle configuration
        :param a_min: minimum acceleration
        :param a_max: maximum acceleration
        :param a_lateral_max: maximum lateral acceleration
        :param j_min: minimum jerk
        :param j_max: maximum jerk
        :param v_min_driving: minimum driving velocity
        :param v_max_street: maximum possible velocity if no rules
        :return:
        """
        return VelocityPlannerConfig(
            optimization_config=optimization_config,
            vehicle_config=vehicle_config,
            a_min=a_min,
            a_max=a_max,
            a_lateral_max=a_lateral_max,
            j_min=j_min,
            j_max=j_max,
            v_min_driving=v_min_driving,
            v_max_street=v_max_street,
        )

    @staticmethod
    def build_vehicle_config(
        mass: float,
        length_rear: float,
        length_front: float,
        inertia_z: float,
        tire_B_front: float,
        tire_C_front: float,
        tire_D_front: float,
        tire_B_rear: float,
        tire_C_rear: float,
        tire_D_rear: float,
    ) -> VehicleConfig:
        """
        Builds vehicle config
        :param mass: vehicle mass
        :param length_rear: length from cg to rear
        :param length_front: length from cg to front
        :param inertia_z: inertia z
        :param tire_B_front: pajecka B parameter for front tire
        :param tire_C_front: pajecka C parameter for front tire
        :param tire_D_front: pajecka D parameter for front tire
        :param tire_B_rear: pajecka B parameter for rear tire
        :param tire_C_rear: pajecka C parameter for rear tire
        :param tire_D_rear: pajecka D parameter for rear tire
        :return:
        """
        return VehicleConfig(
            mass=mass,
            length_rear=length_rear,
            length_front=length_front,
            inertia_z=inertia_z,
            tire_B_front=tire_B_front,
            tire_C_front=tire_C_front,
            tire_D_front=tire_D_front,
            tire_B_rear=tire_B_rear,
            tire_C_rear=tire_C_rear,
            tire_D_rear=tire_D_rear,
        )

    @staticmethod
    def build_optimization_config(
        velocity_maximization_type: VelMaxType,
        jerk_minimization_type: JerkMinType,
        jerk_min_weight: float,
        velocity_bound_type: VelBoundType,
        velocity_constraint: ConstraintType,
        velocity_over_weight: float,
        acceleration_constraint: ConstraintType,
        acceleration_over_weight: float,
        approximated_jerk_constraint: Optional[ConstraintType],
        approximated_jerk_over_weight: float,
        pseudo_jerk_constraint: Optional[ConstraintType],
        pseudo_jerk_over_weight: float,
        solver: SolverBackend,
    ) -> OptimizationConfig:
        """
        Builds optimization config
        :param velocity_maximization_type: type of velocity maximization
        :param jerk_minimization_type: type of jerk minimization
        :param jerk_min_weight: weight for jerk
        :param velocity_bound_type: type of velocity bound
        :param velocity_constraint: type constraint for velocity
        :param velocity_over_weight: weight for velocity in utility
        :param acceleration_constraint: type of acceleration constraint
        :param acceleration_over_weight: acceleration slack weight
        :param approximated_jerk_constraint: type for approximated jerk constraint
        :param approximated_jerk_over_weight: jerk slack weight
        :param pseudo_jerk_constraint: constraint type for pseudo jerk
        :param pseudo_jerk_over_weight: pseudo jerk weight
        :param solver: cvxpy solver
        :return: optimization config object
        """
        return OptimizationConfig(
            velocity_maximization_type=velocity_maximization_type,
            jerk_minimization_type=jerk_minimization_type,
            jerk_min_weight=jerk_min_weight,
            velocity_bound_type=velocity_bound_type,
            velocity_constraint=velocity_constraint,
            velocity_over_weight=velocity_over_weight,
            acceleration_constraint=acceleration_constraint,
            acceleration_over_weight=acceleration_over_weight,
            approximated_jerk_constraint=approximated_jerk_constraint,
            approximated_jerk_over_weight=approximated_jerk_over_weight,
            pseudo_jerk_constraint=pseudo_jerk_constraint,
            pseudo_jerk_over_weight=pseudo_jerk_over_weight,
            solver=solver,
        )

    @staticmethod
    def build_default_optimization_config() -> OptimizationConfig:
        """
        Builds default optimization config
        :return: optimization config
        """
        return ConfigurationBuilder.build_optimization_config(
            velocity_maximization_type=VelMaxType.SCALED_TO_APPROX_VEL,
            jerk_minimization_type=JerkMinType.APPROXIMATED_JERK,
            jerk_min_weight=30.0,
            velocity_bound_type=VelBoundType.APPROX_VEL_BOUNDED,
            velocity_constraint=ConstraintType.SOFT_QUADRATIC,
            velocity_over_weight=10e5,
            acceleration_constraint=ConstraintType.SOFT_QUADRATIC,
            acceleration_over_weight=6 * 10e6,
            approximated_jerk_constraint=None,
            approximated_jerk_over_weight=5 * 10e5,
            pseudo_jerk_constraint=ConstraintType.SOFT_QUADRATIC,
            pseudo_jerk_over_weight=5 * 10e5,
            solver=SolverBackend.CLARABEL,
        )

    @staticmethod
    def build_default_vehicle_config() -> VehicleConfig:
        """
        Builds default vehicle config
        :return: Vehicle Config
        """
        return ConfigurationBuilder.build_vehicle_config(
            length_rear=1.644,
            length_front=1.484,
            mass=2520,
            inertia_z=13600,
            tire_B_front=10,
            tire_C_front=1.3,
            tire_D_front=1.2,
            tire_B_rear=10,
            tire_C_rear=1.6,
            tire_D_rear=2.1,
        )

    @staticmethod
    def build_default_velocity_planner_config(
        optimization_config: OptimizationConfig, vehicle_config: VehicleConfig
    ) -> VelocityPlannerConfig:
        """
        Builds default velocity planner config
        :param optimization_config: optimization config
        :param vehicle_config: vehicle config
        :return: velocity planner config
        """
        return ConfigurationBuilder.build_velocity_config(
            optimization_config=optimization_config,
            vehicle_config=vehicle_config,
            a_lateral_max=2.0,
            a_min=-2.5,
            a_max=1.5,
            j_min=-4.0,
            j_max=3.6,
            v_min_driving=3.0,
            v_max_street=130.0 / 3.6,
        )

    @staticmethod
    def build_default_config() -> VelocityPlannerConfig:
        """
        Builds default config.
        For reasonable default values, confer
        https://www.researchgate.net/publication/326546961_Automated_Driving_System_ADS_High-Level_Quality_Requirements_Analysis_-_Driving_Behavior_Comfort#fullTextFileContent
        :return: default velocity planer config
        """
        optimization_config = ConfigurationBuilder.build_default_optimization_config()

        vehicle_config: VehicleConfig = (
            ConfigurationBuilder.build_default_vehicle_config()
        )

        return ConfigurationBuilder.build_default_velocity_planner_config(
            optimization_config=optimization_config, vehicle_config=vehicle_config
        )

build_default_config() staticmethod

Builds default config. For reasonable default values, confer https://www.researchgate.net/publication/326546961_Automated_Driving_System_ADS_High-Level_Quality_Requirements_Analysis_-_Driving_Behavior_Comfort#fullTextFileContent

Returns:

Type Description
VelocityPlannerConfig

default velocity planer config

Source code in commonroad_velocity_planner/configuration/configuration_builder.py
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
@staticmethod
def build_default_config() -> VelocityPlannerConfig:
    """
    Builds default config.
    For reasonable default values, confer
    https://www.researchgate.net/publication/326546961_Automated_Driving_System_ADS_High-Level_Quality_Requirements_Analysis_-_Driving_Behavior_Comfort#fullTextFileContent
    :return: default velocity planer config
    """
    optimization_config = ConfigurationBuilder.build_default_optimization_config()

    vehicle_config: VehicleConfig = (
        ConfigurationBuilder.build_default_vehicle_config()
    )

    return ConfigurationBuilder.build_default_velocity_planner_config(
        optimization_config=optimization_config, vehicle_config=vehicle_config
    )

build_default_optimization_config() staticmethod

Builds default optimization config

Returns:

Type Description
OptimizationConfig

optimization config

Source code in commonroad_velocity_planner/configuration/configuration_builder.py
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
@staticmethod
def build_default_optimization_config() -> OptimizationConfig:
    """
    Builds default optimization config
    :return: optimization config
    """
    return ConfigurationBuilder.build_optimization_config(
        velocity_maximization_type=VelMaxType.SCALED_TO_APPROX_VEL,
        jerk_minimization_type=JerkMinType.APPROXIMATED_JERK,
        jerk_min_weight=30.0,
        velocity_bound_type=VelBoundType.APPROX_VEL_BOUNDED,
        velocity_constraint=ConstraintType.SOFT_QUADRATIC,
        velocity_over_weight=10e5,
        acceleration_constraint=ConstraintType.SOFT_QUADRATIC,
        acceleration_over_weight=6 * 10e6,
        approximated_jerk_constraint=None,
        approximated_jerk_over_weight=5 * 10e5,
        pseudo_jerk_constraint=ConstraintType.SOFT_QUADRATIC,
        pseudo_jerk_over_weight=5 * 10e5,
        solver=SolverBackend.CLARABEL,
    )

build_default_vehicle_config() staticmethod

Builds default vehicle config

Returns:

Type Description
VehicleConfig

Vehicle Config

Source code in commonroad_velocity_planner/configuration/configuration_builder.py
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
@staticmethod
def build_default_vehicle_config() -> VehicleConfig:
    """
    Builds default vehicle config
    :return: Vehicle Config
    """
    return ConfigurationBuilder.build_vehicle_config(
        length_rear=1.644,
        length_front=1.484,
        mass=2520,
        inertia_z=13600,
        tire_B_front=10,
        tire_C_front=1.3,
        tire_D_front=1.2,
        tire_B_rear=10,
        tire_C_rear=1.6,
        tire_D_rear=2.1,
    )

build_default_velocity_planner_config(optimization_config, vehicle_config) staticmethod

Builds default velocity planner config

Parameters:

Name Type Description Default
optimization_config OptimizationConfig

optimization config

required
vehicle_config VehicleConfig

vehicle config

required

Returns:

Type Description
VelocityPlannerConfig

velocity planner config

Source code in commonroad_velocity_planner/configuration/configuration_builder.py
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
@staticmethod
def build_default_velocity_planner_config(
    optimization_config: OptimizationConfig, vehicle_config: VehicleConfig
) -> VelocityPlannerConfig:
    """
    Builds default velocity planner config
    :param optimization_config: optimization config
    :param vehicle_config: vehicle config
    :return: velocity planner config
    """
    return ConfigurationBuilder.build_velocity_config(
        optimization_config=optimization_config,
        vehicle_config=vehicle_config,
        a_lateral_max=2.0,
        a_min=-2.5,
        a_max=1.5,
        j_min=-4.0,
        j_max=3.6,
        v_min_driving=3.0,
        v_max_street=130.0 / 3.6,
    )

build_optimization_config(velocity_maximization_type, jerk_minimization_type, jerk_min_weight, velocity_bound_type, velocity_constraint, velocity_over_weight, acceleration_constraint, acceleration_over_weight, approximated_jerk_constraint, approximated_jerk_over_weight, pseudo_jerk_constraint, pseudo_jerk_over_weight, solver) staticmethod

Builds optimization config

Parameters:

Name Type Description Default
velocity_maximization_type VelMaxType

type of velocity maximization

required
jerk_minimization_type JerkMinType

type of jerk minimization

required
jerk_min_weight float

weight for jerk

required
velocity_bound_type VelBoundType

type of velocity bound

required
velocity_constraint ConstraintType

type constraint for velocity

required
velocity_over_weight float

weight for velocity in utility

required
acceleration_constraint ConstraintType

type of acceleration constraint

required
acceleration_over_weight float

acceleration slack weight

required
approximated_jerk_constraint Optional[ConstraintType]

type for approximated jerk constraint

required
approximated_jerk_over_weight float

jerk slack weight

required
pseudo_jerk_constraint Optional[ConstraintType]

constraint type for pseudo jerk

required
pseudo_jerk_over_weight float

pseudo jerk weight

required
solver SolverBackend

cvxpy solver

required

Returns:

Type Description
OptimizationConfig

optimization config object

Source code in commonroad_velocity_planner/configuration/configuration_builder.py
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
@staticmethod
def build_optimization_config(
    velocity_maximization_type: VelMaxType,
    jerk_minimization_type: JerkMinType,
    jerk_min_weight: float,
    velocity_bound_type: VelBoundType,
    velocity_constraint: ConstraintType,
    velocity_over_weight: float,
    acceleration_constraint: ConstraintType,
    acceleration_over_weight: float,
    approximated_jerk_constraint: Optional[ConstraintType],
    approximated_jerk_over_weight: float,
    pseudo_jerk_constraint: Optional[ConstraintType],
    pseudo_jerk_over_weight: float,
    solver: SolverBackend,
) -> OptimizationConfig:
    """
    Builds optimization config
    :param velocity_maximization_type: type of velocity maximization
    :param jerk_minimization_type: type of jerk minimization
    :param jerk_min_weight: weight for jerk
    :param velocity_bound_type: type of velocity bound
    :param velocity_constraint: type constraint for velocity
    :param velocity_over_weight: weight for velocity in utility
    :param acceleration_constraint: type of acceleration constraint
    :param acceleration_over_weight: acceleration slack weight
    :param approximated_jerk_constraint: type for approximated jerk constraint
    :param approximated_jerk_over_weight: jerk slack weight
    :param pseudo_jerk_constraint: constraint type for pseudo jerk
    :param pseudo_jerk_over_weight: pseudo jerk weight
    :param solver: cvxpy solver
    :return: optimization config object
    """
    return OptimizationConfig(
        velocity_maximization_type=velocity_maximization_type,
        jerk_minimization_type=jerk_minimization_type,
        jerk_min_weight=jerk_min_weight,
        velocity_bound_type=velocity_bound_type,
        velocity_constraint=velocity_constraint,
        velocity_over_weight=velocity_over_weight,
        acceleration_constraint=acceleration_constraint,
        acceleration_over_weight=acceleration_over_weight,
        approximated_jerk_constraint=approximated_jerk_constraint,
        approximated_jerk_over_weight=approximated_jerk_over_weight,
        pseudo_jerk_constraint=pseudo_jerk_constraint,
        pseudo_jerk_over_weight=pseudo_jerk_over_weight,
        solver=solver,
    )

build_vehicle_config(mass, length_rear, length_front, inertia_z, tire_B_front, tire_C_front, tire_D_front, tire_B_rear, tire_C_rear, tire_D_rear) staticmethod

Builds vehicle config

Parameters:

Name Type Description Default
mass float

vehicle mass

required
length_rear float

length from cg to rear

required
length_front float

length from cg to front

required
inertia_z float

inertia z

required
tire_B_front float

pajecka B parameter for front tire

required
tire_C_front float

pajecka C parameter for front tire

required
tire_D_front float

pajecka D parameter for front tire

required
tire_B_rear float

pajecka B parameter for rear tire

required
tire_C_rear float

pajecka C parameter for rear tire

required
tire_D_rear float

pajecka D parameter for rear tire

required

Returns:

Type Description
VehicleConfig
Source code in commonroad_velocity_planner/configuration/configuration_builder.py
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
@staticmethod
def build_vehicle_config(
    mass: float,
    length_rear: float,
    length_front: float,
    inertia_z: float,
    tire_B_front: float,
    tire_C_front: float,
    tire_D_front: float,
    tire_B_rear: float,
    tire_C_rear: float,
    tire_D_rear: float,
) -> VehicleConfig:
    """
    Builds vehicle config
    :param mass: vehicle mass
    :param length_rear: length from cg to rear
    :param length_front: length from cg to front
    :param inertia_z: inertia z
    :param tire_B_front: pajecka B parameter for front tire
    :param tire_C_front: pajecka C parameter for front tire
    :param tire_D_front: pajecka D parameter for front tire
    :param tire_B_rear: pajecka B parameter for rear tire
    :param tire_C_rear: pajecka C parameter for rear tire
    :param tire_D_rear: pajecka D parameter for rear tire
    :return:
    """
    return VehicleConfig(
        mass=mass,
        length_rear=length_rear,
        length_front=length_front,
        inertia_z=inertia_z,
        tire_B_front=tire_B_front,
        tire_C_front=tire_C_front,
        tire_D_front=tire_D_front,
        tire_B_rear=tire_B_rear,
        tire_C_rear=tire_C_rear,
        tire_D_rear=tire_D_rear,
    )

build_velocity_config(optimization_config, vehicle_config, a_min, a_max, a_lateral_max, j_min, j_max, v_min_driving, v_max_street) staticmethod

Build velocity planner config

Parameters:

Name Type Description Default
optimization_config OptimizationConfig

optimization config

required
vehicle_config VehicleConfig

vehicle configuration

required
a_min float

minimum acceleration

required
a_max float

maximum acceleration

required
a_lateral_max float

maximum lateral acceleration

required
j_min float

minimum jerk

required
j_max float

maximum jerk

required
v_min_driving float

minimum driving velocity

required
v_max_street float

maximum possible velocity if no rules

required

Returns:

Type Description
VelocityPlannerConfig
Source code in commonroad_velocity_planner/configuration/configuration_builder.py
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
@staticmethod
def build_velocity_config(
    optimization_config: OptimizationConfig,
    vehicle_config: VehicleConfig,
    a_min: float,
    a_max: float,
    a_lateral_max: float,
    j_min: float,
    j_max: float,
    v_min_driving: float,
    v_max_street: float,
) -> VelocityPlannerConfig:
    """
    Build velocity planner config
    :param optimization_config: optimization config
    :param vehicle_config: vehicle configuration
    :param a_min: minimum acceleration
    :param a_max: maximum acceleration
    :param a_lateral_max: maximum lateral acceleration
    :param j_min: minimum jerk
    :param j_max: maximum jerk
    :param v_min_driving: minimum driving velocity
    :param v_max_street: maximum possible velocity if no rules
    :return:
    """
    return VelocityPlannerConfig(
        optimization_config=optimization_config,
        vehicle_config=vehicle_config,
        a_min=a_min,
        a_max=a_max,
        a_lateral_max=a_lateral_max,
        j_min=j_min,
        j_max=j_max,
        v_min_driving=v_min_driving,
        v_max_street=v_max_street,
    )

get_predefined_configuration(planner_config=PlannerConfig.DEFAULT) staticmethod

Builds predefined velocity planner config

Parameters:

Name Type Description Default
planner_config PlannerConfig

planner config

DEFAULT

Returns:

Type Description
VelocityPlannerConfig

velocity planner config object

Source code in commonroad_velocity_planner/configuration/configuration_builder.py
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
@staticmethod
def get_predefined_configuration(
    planner_config: PlannerConfig = PlannerConfig.DEFAULT,
) -> VelocityPlannerConfig:
    """
    Builds predefined velocity planner config
    :param planner_config: planner config
    :return: velocity planner config object
    """
    if planner_config == PlannerConfig.DEFAULT:
        retconf: VelocityPlannerConfig = ConfigurationBuilder.build_default_config()

    else:
        raise NotImplementedError(f"The config {planner_config} is not implemented")

    return retconf

OptimizationConfig dataclass

Configuration used in optimization-based planners

Source code in commonroad_velocity_planner/configuration/optimization_config.py
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
@dataclass(frozen=True)
class OptimizationConfig:
    """
    Configuration used in optimization-based planners
    """

    # normalize velocity to prevent ueberschwingen
    velocity_maximization_type: VelMaxType
    # activating jerk minization
    jerk_minimization_type: JerkMinType
    jerk_min_weight: float
    velocity_bound_type: VelBoundType
    velocity_constraint: ConstraintType
    velocity_over_weight: float
    acceleration_constraint: ConstraintType
    acceleration_over_weight: float
    approximated_jerk_constraint: Optional[ConstraintType]
    approximated_jerk_over_weight: float
    pseudo_jerk_constraint: Optional[ConstraintType]
    pseudo_jerk_over_weight: float
    solver: SolverBackend

VehicleConfig dataclass

Vehicle configuration. Used in bang bang control planners.

Source code in commonroad_velocity_planner/configuration/vehicle_config.py
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
@dataclass
class VehicleConfig:
    """
    Vehicle configuration. Used in bang bang control planners.
    """

    mass: float
    length_rear: float
    length_front: float
    inertia_z: float

    # Tire model
    tire_B_front: float
    tire_C_front: float
    tire_D_front: float
    tire_B_rear: float
    tire_C_rear: float
    tire_D_rear: float

VelocityPlannerConfig dataclass

Velocity planner config, uniting optimization config, vehicle config and several top-level params.

Source code in commonroad_velocity_planner/configuration/velocity_planner_config.py
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
@dataclass(frozen=True)
class VelocityPlannerConfig:
    """
    Velocity planner config, uniting optimization config, vehicle config and several top-level params.
    """

    optimization_config: OptimizationConfig
    vehicle_config: VehicleConfig
    a_min: float
    a_max: float
    a_lateral_max: float
    j_min: float
    j_max: float
    v_min_driving: float
    v_max_street: float
    g: float = 9.81