Module feasibility
feasibility_checker
- position_orientation_objective(u: array, x0: array, x1: array, dt: float, vehicle_dynamics: VehicleDynamics, ftol: float = 1e-08, e: array = array([0.02, 0.02, 0.03])) float [source]
Position-Orientation objective function to be minimized for the state transition feasibility.
Simulates the next state using the inputs and calculates the norm of the difference between the simulated next state and actual next state. Position, velocity and orientation state fields will be used for calculation of the norm.
- Parameters:
u – input values
x0 – initial state values
x1 – next state values
dt – delta time
vehicle_dynamics – the vehicle dynamics model to be used for forward simulation
ftol – ftol parameter used by the optimizer
e – error margin, function will return norm of the error vector multiplied with 100 as cost if the input violates the friction circle constraint or input bounds.
- Returns:
cost
- position_orientation_feasibility_criteria(x: array, x_sim: array, vehicle_dynamics: VehicleDynamics, e: array = array([0.02, 0.02, 0.03]), d: int = 4) bool [source]
Position-Orientation feasibility criteria to be checked between the real next state and the simulated next state in the state transition feasibility testing after a valid input has been found.
Checks whether the position and orientation difference is within acceptable between actual state and simulated state.
- Parameters:
x – real next state
x_sim – simulated next state
vehicle_dynamics – the vehicle dynamics model to be used for forward simulation
e – error margin, function will return False if the positional difference between the simulated next state and the actual next state is bigger then error margin.
d – decimal points where the difference values are rounded up to in order to avoid floating point errors set it based on the error margin, i.e e=0.02, d=3
- Returns:
True if the positional difference is below error margin.
- state_transition_feasibility(x0: ~commonroad.scenario.state.State | ~commonroad.scenario.state.InitialState | ~commonroad.scenario.state.PMState | ~commonroad.scenario.state.KSState | ~commonroad.scenario.state.KSTState | ~commonroad.scenario.state.STState | ~commonroad.scenario.state.STDState | ~commonroad.scenario.state.MBState | ~commonroad.scenario.state.InputState | ~commonroad.scenario.state.PMInputState | ~commonroad.scenario.state.LateralState | ~commonroad.scenario.state.LongitudinalState | ~commonroad.scenario.state.CustomState | ~commonroad.scenario.state.ExtendedPMState, x1: ~commonroad.scenario.state.State | ~commonroad.scenario.state.InitialState | ~commonroad.scenario.state.PMState | ~commonroad.scenario.state.KSState | ~commonroad.scenario.state.KSTState | ~commonroad.scenario.state.STState | ~commonroad.scenario.state.STDState | ~commonroad.scenario.state.MBState | ~commonroad.scenario.state.InputState | ~commonroad.scenario.state.PMInputState | ~commonroad.scenario.state.LateralState | ~commonroad.scenario.state.LongitudinalState | ~commonroad.scenario.state.CustomState | ~commonroad.scenario.state.ExtendedPMState, vehicle_dynamics: ~commonroad_dc.feasibility.vehicle_dynamics.VehicleDynamics, dt: float, objective=<function position_orientation_objective>, criteria=<function position_orientation_feasibility_criteria>, ftol: float = 1e-08, e: ~numpy.array = array([0.02, 0.02, 0.03]), d: int = 4, maxiter: int = 100, disp: bool = False) Tuple[bool, InputState | PMInputState] [source]
Checks if the state transition is feasible between given two state according to the vehicle dynamics.
Tries to find a valid input for the state transition by minimizing the objective function, and then checks if the state simulated by using the reconstructed input is feasible.
By default, the trajectory feasibility checker will use position-orientation objective function as the objective and position-orientation feasibility criteria function will be used for feasibility criteria.
Objectives can be changed by passing a function with the signature fun(u: np.array, x0: np.array, x1: np.array, dt: float, vehicle_dynamics: VehicleDynamics, ftol: float = 1e-8, e: np.array -> float
Feasibility criteria can be changed by passing a function with the signature fun(x: np.array, x_sim: np.array, vehicle_dynamics: VehicleDynamics, e: np.array = np.array([2e-2, 2e-2, 3e-2]), d: int = 4) -> bool
- Parameters:
x0 – initial state
x1 – next state
vehicle_dynamics – the vehicle dynamics model to be used for forward simulation
dt – delta time
objective – callable fun(u, x0, x1, dt, vehicle_dynamics) -> float, objective function to be minimized in order to find a valid input for state transition
criteria – callable fun(x1, x_sim, vehicle_dynamics) -> bool, feasibility criteria to be checked between the real next state and the simulated next state
ftol – ftol passed to the minimizer function
e – error margin passed to the feasibility criteria function
d – decimal points where the difference values are rounded up to in order to avoid floating point errors set it based on the error margin, i.e e=0.02, d=4
maxiter – maxiter passed to the minimizer function
disp – disp passed to the minimizer function
- Returns:
True if feasible, and the constructed input as State
- trajectory_feasibility(trajectory: ~commonroad.scenario.trajectory.Trajectory, vehicle_dynamics: ~commonroad_dc.feasibility.vehicle_dynamics.VehicleDynamics, dt: float, objective=<function position_orientation_objective>, criteria=<function position_orientation_feasibility_criteria>, ftol: float = 1e-08, e: ~numpy.array = array([0.02, 0.02, 0.03]), d: int = 4, maxiter: int = 100, disp: bool = False) Tuple[bool, Trajectory] [source]
Checks if the given trajectory is feasible for the vehicle model by checking if the state transition is feasible between each consecutive state of the trajectory.
The state_transition_feasibility function will be applied to consecutive states of a given trajectory, and the reconstructed inputs will be returned as Trajectory object. If the trajectory was not feasible, reconstructed inputs up to infeasible state will be returned.
ATTENTION: Reconstructed inputs are just approximated inputs for the forward simulation between consecutive states n and n+1. Simulating full trajectory from the initial state by using the reconstructed inputs can result in a different (but similar) trajectory compared to the real one. The reason for this is the small differences between the approximate inputs and the real inputs adding up as we simulate further from the initial state.
By default, the trajectory feasibility checker will use position-orientation objective function as the objective and position-orientation feasibility criteria function will be used for feasibility criteria.
Objectives can be changed by passing a function with the signature fun(u: np.array, x0: np.array, x1: np.array, dt: float, vehicle_dynamics: VehicleDynamics, ftol: float = 1e-8, e: np.array) -> float
Feasibility criteria can be changed by passing a function with the signature fun(x: np.array, x_sim: np.array, vehicle_dynamics: VehicleDynamics, e: np.array = np.array([2e-2, 2e-2, 3e-2]), d: int = 4) -> bool
- Parameters:
trajectory – trajectory
vehicle_dynamics – the vehicle dynamics model to be used for forward simulation
dt – delta time
objective – callable fun(u, x0, x1, dt, vehicle_dynamics) -> float, objective function to be minimized in order to find a valid input for state transition
criteria – callable fun(x1, x_sim, vehicle_dynamics) -> bool, feasibility criteria to be checked between the real next state and the simulated next state
ftol – ftol passed to the minimizer function
e – error margin passed to the feasibility criteria function
d – decimal points where the difference values are rounded up to in order to avoid floating point errors set it based on the error margin, i.e e=0.02, d=4
maxiter – maxiter passed to the minimizer function
disp – disp passed to the minimizer function
- Returns:
True if feasible, and list of constructed inputs as Trajectory object
- input_vector_feasibility(initial_state: InitialState, input_vector: Trajectory, vehicle_dynamics: VehicleDynamics, dt: float) Tuple[bool, Trajectory] [source]
Checks whether the given input vector (as Trajectory object) is feasible according to the input and state constraints.
The input bounds and friction circle constraint of corresponding vehicle model is being used as criteria of validity. During the process of feasibility checking, the trajectory will be simulated for the given initial state and input vector. If there is an infeasible input, all the trajectory states simulated up to that input will be returned instead.
For example, if we have initial state wth time step 0, and valid input vector that contains 20 inputs, the trajectory will be completely simulated and returned together with the feasibility result. If we have an input vector that is valid up to 5th input, then the trajectory will be simulated up to 5th time step, but 6th time step will not be simulated since the input is not feasible.
- Parameters:
initial_state – initial state which the input vector will be applied
input_vector – input vector s Trajectory object
vehicle_dynamics – the vehicle dynamics model to be used for input constraint checks
dt – delta time
- Returns:
True if feasible, and simulated trajectory.
solution_checker
- exception SolutionCheckerException[source]
Main exception class for exceptions related to the solution checker.
- exception GoalNotReachedException[source]
Exception class for exceptions related to the goal checks.
- exception MissingSolutionException[source]
Exception class for exceptions related to the planning problem solutions.
- solution_feasible(solution: Solution, dt: float, planning_problem_set: PlanningProblemSet) Dict[int, Tuple[bool, Trajectory, Trajectory]] [source]
Checks whether the given solution is feasible.
- Parameters:
solution – Solution
planning_problem_set – PlanningProblemSet
dt – Scenario dt
- Returns:
planning problem id -> feasible, input or reconstructed input, trajectory or simulated trajectory. Raises FeasibilityException if there is any trajectory in the solution that is not feasible.
- obstacle_collision(scenario: Scenario, planning_problem_set: PlanningProblemSet, solution: Solution) bool [source]
Checks whether there is a collision between the ego vehicles of the solution and the scenario obstacles.
- Parameters:
scenario – Scenario
planning_problem_set – PlanningProblemSet
solution – Solution
- Returns:
False if there is no collision. Raises CollisionException if there are any obstacle collisions.
- boundary_collision(scenario: Scenario, planning_problem_set: PlanningProblemSet, solution: Solution) bool [source]
Checks whether the ego vehicles go out of lanelet boundaries.
- Parameters:
scenario – Scenario
planning_problem_set – PlanningProblemSet
solution – Solution
- Returns:
False if the ego vehicles stay in lanes. Raises CollisionException if there are any boundary collisions.
- ego_collision(scenario: Scenario, planning_problem_set: PlanningProblemSet, solution: Solution) bool [source]
Checks whether the ego vehicles collide with each other in the solution.
- Parameters:
scenario – Scenario
planning_problem_set – PlanningProblemSet
solution – Solution
- Returns:
False if there is no collision. Raises CollisionException if there are any collisions between ego vehicles.
- goal_reached(scenario: Scenario, planning_problem_set: PlanningProblemSet, solution: Solution) bool [source]
Checks whether the goal has been reached for each of the planning problem solutions.
- Parameters:
scenario – Scenario
planning_problem_set – PlanningProblemSet
solution – Solution
- Returns:
True if all reached goal. Raises GoalNotReachedException if there are any planning problem solutions that have not reached the goal position.
- solved_all_problems(planning_problem_set: PlanningProblemSet, solution: Solution) bool [source]
Checks whether the solution has solved all planning problems of the scenario.
- Parameters:
planning_problem_set – PlanningProblemSet
solution – Solution
- Returns:
True if there is a solution for each planning problem. Raises MissingSolutionException if there are any missing planning problem solutions.
- starts_at_correct_state(solution: Solution, planning_problem_set: PlanningProblemSet) bool [source]
Checks whether the given solution trajectories or input vectors start at the correct state/time step.
Expected time steps are: - Equal to planning problem’s initial time step, if input vector solution - Planning problem’s initial state, if trajectory solution
- Parameters:
solution – Solution
planning_problem_set – PlanningProblemSet
- Returns:
True if all solution trajectories start at correct time step
- valid_solution(scenario: Scenario, planning_problem_set: PlanningProblemSet, solution: Solution) Tuple[bool, Dict[int, Tuple[bool, Trajectory, Trajectory]]] [source]
- Checks whether a solution is valid or not by checking
Solution has solved all planning problems of the scenario (solved_all_problems)
All planning problem solutions reached goal (goal_reached)
All planning problem solutions trajectories/input vectors start at correct time step (starts_at_correct_ts)
All planning problem solutions are feasible (solution_feasible)
There isn’t a collision between the ego vehicles and the scenario obstacles (obstacle_collision)
The ego vehicles don’t go out of lane boundaries (boundary_collision)
The ego vehicles don’t collide with each other (ego_collision)
It returns a dictionary that contains the inputs (or reconstructed inputs if trajectory solution), and trajectory (simulated trajectory if input vector solution).
The valid_solution functions is being used as a basis for validity when a submission was made to commonroad.in.tum.de website for evaluation. If the solution is not valid according to this function, then the solution will not be accepted.
- Parameters:
scenario – Scenario
planning_problem_set – PlanningProblemSet
solution – Solution
- Returns:
True if all checks pass successfully, and dictionary for simulated trajectories or reconstructed inputs. Raises SolutionCheckerException if any of the checks fail.
vehicle_dynamics
- class VehicleParameterMapping(value)[source]
Mapping for VehicleType name to VehicleParameters
- FORD_ESCORT = VehicleParameters(l=4.298, w=1.674, steering=SteeringParameters(min=-0.91, max=0.91, v_min=-0.4, v_max=0.4, kappa_dot_max=0.4, kappa_dot_dot_max=20.0), longitudinal=LongitudinalParameters(v_min=-13.9, v_max=45.8, v_switch=4.755, a_max=11.5, j_max=10000.0, j_dot_max=10000.0), m=1225.8878467253344, m_s=1094.542720290477, m_uf=65.67256321742863, m_ur=65.67256321742863, a=0.88392, b=1.50876, I_Phi_s=244.04723069965206, I_y_s=1342.2597688480864, I_z=1538.8533713561394, I_xz_s=0.0, K_sf=21898.332429625985, K_sdf=1459.3902937206362, K_sr=21898.332429625985, K_sdr=1459.3902937206362, T_f=1.389888, T_r=1.423416, K_ras=175186.65943700788, K_tsf=-12880.270509148304, K_tsr=0.0, K_rad=10215.732056044453, K_zt=189785.5477234252, h_cg=0.5577840000000001, h_raf=0.0, h_rar=0.0, h_s=0.59436, I_uf=32.53963075995361, I_ur=32.53963075995361, I_y_w=1.7, K_lt=1.0278264878518764e-05, R_w=0.344, T_sb=0.76, T_se=1.0, D_f=-0.6233595800524934, D_r=-0.20997375328083986, E_f=0.0, E_r=0.0, tire=TireParameters(p_cx1=1.6411, p_dx1=1.1739, p_dx3=0.0, p_ex1=0.46403, p_kx1=22.303, p_hx1=0.0012297, p_vx1=-8.8098e-06, r_bx1=13.276, r_bx2=-13.778, r_cx1=1.2568, r_ex1=0.65225, r_hx1=0.0050722, p_cy1=1.3507, p_dy1=1.0489, p_dy3=-2.8821, p_ey1=-0.0074722, p_ky1=-21.92, p_hy1=0.0026747, p_hy3=0.031415, p_vy1=0.037318, p_vy3=-0.32931, r_by1=7.1433, r_by2=9.1916, r_by3=-0.027856, r_cy1=1.0719, r_ey1=-0.27572, r_hy1=5.7448e-06, r_vy1=-0.027825, r_vy3=-0.27568, r_vy4=12.12, r_vy5=1.9, r_vy6=-10.704), trailer=TrailerParameters(l=None, w=None, l_hitch=None, l_total=None, l_wb=None))
- BMW_320i = VehicleParameters(l=4.508, w=1.61, steering=SteeringParameters(min=-1.066, max=1.066, v_min=-0.4, v_max=0.4, kappa_dot_max=0.4, kappa_dot_dot_max=20.0), longitudinal=LongitudinalParameters(v_min=-13.9, v_max=50.8, v_switch=7.319, a_max=11.5, j_max=10000.0, j_dot_max=10000.0), m=1093.2952334674046, m_s=965.7108098804363, m_uf=63.7921826056784, m_ur=63.7921826056784, a=1.1561957064, b=1.4227170936, I_Phi_s=207.26524557936952, I_y_s=1565.8178787125541, I_z=1791.5995300122856, I_xz_s=0.0, K_sf=24453.137879749014, K_sdf=1786.2441002440723, K_sr=19635.504745231297, K_sdr=1649.0833034887382, T_f=1.38684, T_r=1.36398, K_ras=175186.65943700788, K_tsf=-6914.881688272133, K_tsr=-2643.6009520155308, K_rad=10215.732056044453, K_zt=158294.1398119115, h_cg=0.5748689544000001, h_raf=0.0, h_rar=0.0, h_s=0.61373004, I_uf=30.673279563178017, I_ur=29.670408143156248, I_y_w=1.7, K_lt=1.6430724599974725e-05, R_w=0.344, T_sb=0.66, T_se=0.0, D_f=-0.39370078740157477, D_r=-0.905511811023622, E_f=0.0, E_r=0.0, tire=TireParameters(p_cx1=1.6411, p_dx1=1.1739, p_dx3=0.0, p_ex1=0.46403, p_kx1=22.303, p_hx1=0.0012297, p_vx1=-8.8098e-06, r_bx1=13.276, r_bx2=-13.778, r_cx1=1.2568, r_ex1=0.65225, r_hx1=0.0050722, p_cy1=1.3507, p_dy1=1.0489, p_dy3=-2.8821, p_ey1=-0.0074722, p_ky1=-21.92, p_hy1=0.0026747, p_hy3=0.031415, p_vy1=0.037318, p_vy3=-0.32931, r_by1=7.1433, r_by2=9.1916, r_by3=-0.027856, r_cy1=1.0719, r_ey1=-0.27572, r_hy1=5.7448e-06, r_vy1=-0.027825, r_vy3=-0.27568, r_vy4=12.12, r_vy5=1.9, r_vy6=-10.704), trailer=TrailerParameters(l=None, w=None, l_hitch=None, l_total=None, l_wb=None))
- VW_VANAGON = VehicleParameters(l=4.569, w=1.844, steering=SteeringParameters(min=-1.023, max=1.023, v_min=-0.4, v_max=0.4, kappa_dot_max=0.4, kappa_dot_dot_max=20.0), longitudinal=LongitudinalParameters(v_min=-11.2, v_max=41.7, v_switch=7.824, a_max=11.5, j_max=10000.0, j_dot_max=10000.0), m=1478.8979637767998, m_s=1316.6086552490374, m_uf=81.14428941630796, m_ur=81.14428941630796, a=1.1507916024, b=1.3211363976000001, I_Phi_s=479.88430581318335, I_y_s=2204.322715845899, I_z=2473.1176915564442, I_xz_s=0.0, K_sf=33577.44305875984, K_sdf=2405.564099800005, K_sr=39125.020607598424, K_sdr=2769.727219182409, T_f=1.574292, T_r=1.5438120000000002, K_ras=175186.65943700788, K_tsf=-33948.217142834066, K_tsr=-7731.374238208578, K_rad=10215.732056044453, K_zt=212641.56722464017, h_cg=0.7478167416, h_raf=0.0, h_rar=0.0, h_s=0.804490644, I_uf=50.276902138127426, I_ur=48.34891545742069, I_y_w=1.7, K_lt=1.2231329122034703e-05, R_w=0.344, T_sb=0.64, T_se=0.0, D_f=-0.32808398950131235, D_r=-0.32808398950131235, E_f=0.0, E_r=0.0, tire=TireParameters(p_cx1=1.6411, p_dx1=1.1739, p_dx3=0.0, p_ex1=0.46403, p_kx1=22.303, p_hx1=0.0012297, p_vx1=-8.8098e-06, r_bx1=13.276, r_bx2=-13.778, r_cx1=1.2568, r_ex1=0.65225, r_hx1=0.0050722, p_cy1=1.3507, p_dy1=1.0489, p_dy3=-2.8821, p_ey1=-0.0074722, p_ky1=-21.92, p_hy1=0.0026747, p_hy3=0.031415, p_vy1=0.037318, p_vy3=-0.32931, r_by1=7.1433, r_by2=9.1916, r_by3=-0.027856, r_cy1=1.0719, r_ey1=-0.27572, r_hy1=5.7448e-06, r_vy1=-0.027825, r_vy3=-0.27568, r_vy4=12.12, r_vy5=1.9, r_vy6=-10.704), trailer=TrailerParameters(l=None, w=None, l_hitch=None, l_total=None, l_wb=None))
- TRUCK = VehicleParameters(l=5.1, w=2.55, steering=SteeringParameters(min=-0.55, max=0.55, v_min=-0.7103, v_max=0.7103, kappa_dot_max=None, kappa_dot_dot_max=None), longitudinal=LongitudinalParameters(v_min=-2.78, v_max=22.22, v_switch=7.824, a_max=11.5, j_max=None, j_dot_max=None), m=None, m_s=None, m_uf=None, m_ur=None, a=1.8, b=1.8, I_Phi_s=None, I_y_s=None, I_z=None, I_xz_s=None, K_sf=None, K_sdf=None, K_sr=None, K_sdr=None, T_f=None, T_r=None, K_ras=None, K_tsf=None, K_tsr=None, K_rad=None, K_zt=None, h_cg=None, h_raf=None, h_rar=None, h_s=None, I_uf=None, I_ur=None, I_y_w=None, K_lt=None, R_w=None, T_sb=None, T_se=None, D_f=None, D_r=None, E_f=None, E_r=None, tire=TireParameters(p_cx1=1.6411, p_dx1=1.1739, p_dx3=0.0, p_ex1=0.46403, p_kx1=22.303, p_hx1=0.0012297, p_vx1=-8.8098e-06, r_bx1=13.276, r_bx2=-13.778, r_cx1=1.2568, r_ex1=0.65225, r_hx1=0.0050722, p_cy1=1.3507, p_dy1=1.0489, p_dy3=-2.8821, p_ey1=-0.0074722, p_ky1=-21.92, p_hy1=0.0026747, p_hy3=0.031415, p_vy1=0.037318, p_vy3=-0.32931, r_by1=7.1433, r_by2=9.1916, r_by3=-0.027856, r_cy1=1.0719, r_ey1=-0.27572, r_hy1=5.7448e-06, r_vy1=-0.027825, r_vy3=-0.27568, r_vy4=12.12, r_vy5=1.9, r_vy6=-10.704), trailer=TrailerParameters(l=13.6, w=2.55, l_hitch=12.0, l_total=16.5, l_wb=8.1))
- class VehicleDynamics(vehicle_model: VehicleModel, vehicle_type: VehicleType)[source]
VehicleDynamics abstract class that encapsulates the common methods of all VehicleDynamics classes.
- List of currently implemented vehicle models
Point-Mass Model (PM)
Kinematic Single-Track Model (KS)
Linearized Kinematic Single-Track Model (LKS)
Kinematic Single-Track Trailer Model (KST)
Single-Track Model (ST)
Multi-Body Model (MB)
New types of VehicleDynamics can be defined by extending this class. If there isn’t any mismatch with the state values, the new VehicleDynamics class can be used directly with the feasibility checkers as well.
For detailed documentation of the Vehicle Models, please check the Vehicle Model Documentation
- classmethod PM(vehicle_type: VehicleType) PointMassDynamics [source]
Creates a PointMassDynamics model.
- Parameters:
vehicle_type – VehicleType, i.e. VehileType.FORD_ESCORT
- Returns:
PointMassDynamics instance with the given vehicle type.
- classmethod KS(vehicle_type: VehicleType) KinematicSingleTrackDynamics [source]
Creates a KinematicSingleTrackDynamics model.
- Parameters:
vehicle_type – VehicleType, i.e. VehileType.FORD_ESCORT
- Returns:
KinematicSingleTrackDynamics instance with the given vehicle type.
- classmethod ST(vehicle_type: VehicleType) SingleTrackDynamics [source]
Creates a SingleTrackDynamics VehicleDynamics model.
- Parameters:
vehicle_type – VehicleType, i.e. VehileType.FORD_ESCORT
- Returns:
SingleTrackDynamics instance with the given vehicle type.
- classmethod MB(vehicle_type: VehicleType) MultiBodyDynamics [source]
Creates a MultiBodyDynamics VehicleDynamics model.
- Parameters:
vehicle_type – VehicleType, i.e. VehileType.FORD_ESCORT
- Returns:
MultiBodyDynamics instance with the given vehicle type.
- classmethod KST(vehicle_type: VehicleType) KinematicSingleTrackTrailerDynamics [source]
Creates a KinematicSingleTrackTrailerDynamics VehicleDynamics model.
- Parameters:
vehicle_type – VehicleType, i.e. VehicleType.FORD_ESCORT
- Returns:
KinematicSingleTrackTrailerDynamics instance with the given vehicle type.
- classmethod LKS(vehicle_type: VehicleType, ref_pos: ndarray, ref_theta: ndarray) LinearizedKSDynamics [source]
Creates a LinearizedKSDynamics VehicleDynamics model.
- Parameters:
vehicle_type – VehicleType, i.e. VehicleType.FORD_ESCORT
ref_pos – longitudinal position (s) of each vertex of the reference path
ref_theta – orientations (theta) at each vertex of the reference path
- Returns:
KinematicSingleTrackTrailerDynamics instance with the given vehicle type.
- classmethod from_model(vehicle_model: VehicleModel, vehicle_type: VehicleType) VehicleDynamics [source]
Creates a VehicleDynamics model for the given vehicle model and type.
- Parameters:
vehicle_model – VehicleModel, i.e. VehicleModel.KS
vehicle_type – VehicleType, i.e. VehileType.FORD_ESCORT
- Returns:
VehicleDynamics instance with the given vehicle type.
- abstract dynamics(t, x, u) List[float] [source]
Vehicle dynamics function that models the motion of the vehicle during forward simulation.
- Parameters:
t – time point which the differentiation is being calculated at.
x – state values
u – input values
- Returns:
next state values
- property input_bounds: Bounds
Returns the bounds on inputs (constraints).
- Bounds are
min steering velocity <= steering_angle_speed <= max steering velocity
-max longitudinal acc <= acceleration <= max longitudinal acc
- Returns:
Bounds
- input_within_bounds(u: InputState | PMInputState | LKSInputState | array, throw: bool = False) bool [source]
Checks whether the given input is within input constraints of the vehicle dynamics model.
- Parameters:
u – input values as np.array or State - Contains 2 values
throw – if set to false, will return bool instead of throwing exception (default=False)
- Returns:
True if within constraints
- violates_friction_circle(x: PMState | KSState | KSTState | STState | MBState | array, u: InputState | array, throw: bool = False) bool [source]
Checks whether given input violates the friction circle constraint for the given state.
- Parameters:
x – current state
u – the input which was used to simulate the next state
throw – if set to false, will return bool instead of throwing exception (default=False)
- Returns:
True if the constraint was violated
- forward_simulation(x: array, u: array, dt: float, throw: bool = True) None | array [source]
Simulates the next state using the given state and input values as numpy arrays.
- Parameters:
x – state values.
u – input values
dt – scenario delta time.
throw – if set to false, will return None as next state instead of throwing exception (default=True)
- Returns:
simulated next state values, raises VehicleDynamicsException if invalid input.
- simulate_next_state(x: PMState | KSState | KSTState | STState | MBState | Tuple[LongitudinalState, LateralState], u: InputState | PMInputState | LKSInputState, dt: float, throw: bool = True) None | PMState | KSState | KSTState | STState | MBState | Tuple[LongitudinalState, LateralState] [source]
Simulates the next state using the given state and input values as State objects.
- Parameters:
x – current state
u – inputs for simulating the next state
dt – scenario delta time.
throw – if set to false, will return None as next state instead of throwing exception (default=True)
- Returns:
simulated next state, raises VehicleDynamicsException if invalid input.
- simulate_trajectory(initial_state: InitialState, input_vector: Trajectory, dt: float, throw: bool = True) None | Trajectory [source]
Creates the trajectory for the given input vector.
- Parameters:
initial_state – initial state of the planning problem
input_vector – input vector as Trajectory object
dt – scenario delta time
throw – if set to false, will return None as trajectory instead of throwing exception (default=True)
- Returns:
simulated trajectory, raises VehicleDynamicsException if there is an invalid input.
- state_to_array(state: PMState | KSState | KSTState | STState | MBState | InitialState, steering_angle_default=0.0) Tuple[array, int] [source]
Converts the given State to numpy array.
- Parameters:
state – State
- Returns:
state values as numpy array and time step of the state
- array_to_state(x: array, time_step: int) PMState | KSState | KSTState | STState | MBState [source]
Converts the given numpy array of values to State.
- Parameters:
x – list of state values
time_step – time step of the converted state
- Returns:
State
- convert_initial_state(initial_state: InitialState, steering_angle_default=0.0) PMState | KSState | KSTState | STState | MBState [source]
Converts the given default initial state to VehicleModel’s state by setting the state values accordingly.
- Parameters:
initial_state – default initial state
steering_angle_default – default steering_angle value as it is not given in intiial state
- Returns:
converted initial state
- input_to_array(input: InputState | PMInputState | LKSInputState) Tuple[array, int] [source]
Converts the given input (as State object) to numpy array.
- Parameters:
input – input as State object
- Returns:
state values as numpy array and time step of the state, raises VehicleDynamicsException if invalid input
- array_to_input(u: array, time_step: int) InputState | PMInputState | LKSInputState [source]
Converts the given numpy array of values to input (as State object).
- Parameters:
u – input values
time_step – time step of the converted input
- Returns:
input as state object, raises VehicleDynamicsException if invalid input
- class PointMassDynamics(vehicle_type: VehicleType)[source]
- dynamics(t, x, u) List[float] [source]
Point Mass model dynamics function. Overrides the dynamics function of VehicleDynamics for PointMass model.
- Parameters:
t –
x – state values, [position x, position y, velocity x, velocity y]
u – input values, [acceleration x, acceleration y]
- Returns:
- property input_bounds: Bounds
Overrides the bounds method of Vehicle Model in order to return bounds for the Point Mass inputs.
- Bounds are
-max longitudinal acc <= acceleration <= max longitudinal acc
-max longitudinal acc <= acceleration_y <= max longitudinal acc
- Returns:
Bounds
- violates_friction_circle(x: PMState | array, u: PMInputState | array, throw: bool = False) bool [source]
Overrides the friction circle constraint method of Vehicle Model in order calculate friction circle constraint for the Point Mass model.
- Parameters:
x – current state
u – the input which was used to simulate the next state
throw – if set to false, will return bool instead of throwing exception (default=False)
- Returns:
True if the constraint was violated
- class KinematicSingleTrackTrailerDynamics(vehicle_type: VehicleType)[source]
- dynamics(t, x, u) List[float] [source]
Vehicle dynamics function that models the motion of the vehicle during forward simulation.
- Parameters:
t – time point which the differentiation is being calculated at.
x – state values
u – input values
- Returns:
next state values
- convert_initial_state(initial_state: InitialState, steering_angle_default=0.0, hitch_angle_default=0.0) KSTState [source]
Overrides method convert_initial_state() in VehicleDynamics Base class due to additional hitch angle Converts the given default initial state to VehicleModel’s state by setting the state values accordingly.
- Parameters:
initial_state – default initial state
steering_angle_default – default steering_angle value as it is not given in initial state
hitch_angle_default – default hitch angle as it is not given in initial state
- Returns:
converted initial state
- state_to_array(state: KSTState | InitialState, steering_angle_default=0.0, hitch_angle_default=0.0) Tuple[array, int] [source]
Overrides method state_to_array() from VehicleDynamics Base class due to additional hitch angle Converts the given State to numpy array.
- Parameters:
state – State
steering_angle_default – default steering_angle value as it is not given in initial state
hitch_angle_default – default hitch angle as it is not given in initial state
- Returns:
state values as numpy array and time step of the state
- class LinearizedKSDynamics(vehicle_type: VehicleType, ref_pos: ndarray, ref_theta: ndarray)[source]
-
- property input_bounds: Bounds
Overrides the input_bounds() method of VehicleDynamics Base class in order to return bounds for the Linearized KS inputs.
- Bounds are
max jerk_dot <= jerk_dot <= max jerk_dot
min kappa_dot_dot <= kappa_dot_dot <= max kappa_dot_dot
- Returns:
Bounds
- forward_simulation(x: array, u: array, dt: float, throw: bool = True) None | array [source]
Overrides method forward_simulation() from VehicleDynamics Base class! Simulates the next state using the given state and input values as numpy arrays.
- Parameters:
x – state values.
u – input values
dt – scenario delta time.
throw – if set to false, will return None as next state instead of throwing exception (default=True)
- Returns:
simulated next state values, raises VehicleDynamicsException if invalid input.
- convert_initial_state(initial_state: InitialState, steering_angle_default=0.0) None [source]
Overrides method _array_to_input() from VehicleDynamics Base class.
- violates_friction_circle(x: Tuple[LongitudinalState, LateralState] | array, u: LKSInputState | array, throw: bool = False) bool [source]
Overrides method violates_friction_circle() from VehicleDynamics Base class! Checks whether the given state violates the friction circle constraint for the LKS model
- Parameters:
x – current state
u – the input which was used to simulate the next state
throw – if set to false, will return bool instead of throwing exception (default=False)
- Returns:
True if the constraint was violated