src package¶
Subpackages¶
Submodules¶
src.const module¶
src.ngsim_trajdata module¶
-
src.ngsim_trajdata.
car_df_index
(trajdata: src.ngsim_trajdata.NGSIMTrajdata, carid: int, frame: int)[source]¶ given frame and carid, find index of car in trajdata Returns 0 if it does not exist
-
src.ngsim_trajdata.
carid_set
(trajdata: src.ngsim_trajdata.NGSIMTrajdata)[source]¶ get all the vehicle id :param trajdata: NGSIMTrajdata :return: all the vehicle id
-
src.ngsim_trajdata.
carsinframe
(trajdata: src.ngsim_trajdata.NGSIMTrajdata, frame: int)[source]¶ get the vehicles in a given frame :param trajdata: NGSIMTrajdata :param frame: frame index :return: vehicles in the frame, [] if no such frame
-
src.ngsim_trajdata.
first_carid
(trajdata: src.ngsim_trajdata.NGSIMTrajdata, frame: int)[source]¶ get the first vehicle’s id in a given frame :param trajdata: NGSIMTrajdata :param frame: frame :return: the first vehicle’s id in a given frame
-
src.ngsim_trajdata.
get_frame_range
(trajdata: src.ngsim_trajdata.NGSIMTrajdata, carid: int)[source]¶ get the frame range for a car given the car id :param trajdata: NGSIMTrajdata :param carid: car id :return: frame range
-
src.ngsim_trajdata.
iscarinframe
(trajdata: src.ngsim_trajdata.NGSIMTrajdata, carid: int, frame: int)[source]¶ check if a car is in a frame given the car id and the frame :param trajdata: NGSIMTrajdata :param carid: car id :param frame: frame index :return: true if in the frame, false otherwise
src.roadway module¶
-
class
src.roadway.
NGSIMRoadway
(name: str, boundaries: list, centerlines: list)[source]¶ Bases:
object
-
class
src.roadway.
RoadwayInputParams
(filepath_boundaries: str, filepath_centerlines: str)[source]¶ Bases:
object
-
src.roadway.
convert_curves_feet_to_meters
(roadWay: src.Roadway.roadway.Roadway)[source]¶ convert all feet unit to meters :param roadWay: Roadway object :return: converted Roadway object
-
src.roadway.
get_segid
(lane: list)[source]¶ - Parameters
lane – list of CurvePt
- Returns
get the segment id of corresponding lane
-
src.roadway.
integrate
(centerline_fn: str, boundary_fn: str, dist_threshold_lane_connect: float = 2.0, desired_distance_between_curve_samples: float = 1.0)[source]¶ - Parameters
centerline_path – center line file path
boundary_path – boundary file path
dist_threshold_lane_connect – [m]
desired_distance_between_curve_samples – [m]
- Returns
-
src.roadway.
read_boundaries
(filepath_boundaries: str)[source]¶ load boundaries from a file given the file path :param filepath_boundaries: the file path of the boundary :return: the loaded boundary
src.splines module¶
-
src.splines.
arclength_1
(spline_coeffs_x, spline_coeffs_y, t_min: float = 0.0, t_max: float = 1.0, n_intervals: int = 100)[source]¶
-
src.splines.
arclength_2
(spline_coeffs_x, spline_coeffs_y, t_min: float = 0.0, t_max: float = None, n_intervals_per_segment: int = 100)[source]¶
-
src.splines.
calc_curve_length_2
(spline_coeffs_x, spline_coeffs_y, n_intervals_per_segment: int = 100)[source]¶
-
src.splines.
calc_curve_param_given_arclen
(spline_coeffs_x, spline_coeffs_y, s_arr, max_iterations: int = 50, curve_length: float = None, epsilon: float = 0.0001, n_intervals_in_arclen: int = 100)[source]¶
-
src.splines.
sample_spline_derivative_of_curvature_1
(spline_coeffs_x, spline_coeffs_y, t, stepsize=0.0001)[source]¶
-
src.splines.
sample_spline_derivative_of_curvature_2
(spline_coeffs_x, spline_coeffs_y, t_arr, stepsize=0.0001)[source]¶
src.trajdata module¶
-
class
src.trajdata.
FilterTrajectoryResult
(trajdata: src.ngsim_trajdata.NGSIMTrajdata, carid: int)[source]¶ Bases:
object
-
src.trajdata.
convert
(tdraw: src.ngsim_trajdata.NGSIMTrajdata, roadway: src.Roadway.roadway.Roadway)[source]¶ - Parameters
tdraw – trajectory raw data
roadway – roadway class
- Returns
ListRecord(), a preprocessed and integrated version of tdraw and roadway
-
src.trajdata.
convert_raw_ngsim_to_trajdatas
()[source]¶ convert the raw trajectory data and roadway to a integrated version and save to a file :return: no return
-
src.trajdata.
copy
(trajdata: src.ngsim_trajdata.NGSIMTrajdata, ftr: src.trajdata.FilterTrajectoryResult)[source]¶
-
src.trajdata.
filter_given_trajectory
(trajdata: src.ngsim_trajdata.NGSIMTrajdata, carid: int)[source]¶ - Parameters
trajdata – trajectory data file, NGSIMTrajdata object
carid – the id of the car that we want to filter
- Returns
a smoothed trajectory
-
src.trajdata.
filter_trajectory
(ftr: src.trajdata.FilterTrajectoryResult, v: src.trajectory_smoothing.VehicleSystem = <src.trajectory_smoothing.VehicleSystem object>)[source]¶
-
src.trajdata.
get_corresponding_roadway
(filename: str)[source]¶ - Parameters
filename – the path of the saved roadway file
- Returns
the roadway class object
-
src.trajdata.
load_ngsim_trajdata
(filepath: str, autofilter: bool = True)[source]¶ - Parameters
filepath – the path of the raw trajectory data file
autofilter – indicates do the filter or not
- Returns
the filtered(or not) data class
src.trajectory_smoothing module¶
-
src.trajectory_smoothing.
EKF
(v: src.trajectory_smoothing.VehicleSystem, mu: list, Cov, u: list, o: list)[source]¶ - Parameters
v – VehicleSystem
mu – mean of belief at time t-1
Cov – cov of belief at time t-1
u – next applied control
o – observation for time t
- Returns
mu_next np.array, Cov_next np.array
-
class
src.trajectory_smoothing.
SimulationResults
(x_arr, z_arr, u_arr, mu_arr, Cov_arr)[source]¶ Bases:
object
-
class
src.trajectory_smoothing.
VehicleSystem
(process_noise: float = 0.077, observation_noise: float = 16.7, control_noise_accel: float = 16.7, control_noise_turnrate: float = 0.46)[source]¶ Bases:
object
used to do trajectory smoothing
-
src.trajectory_smoothing.
compute_dynamics_jacobian
(v: src.trajectory_smoothing.VehicleSystem, x: list, u: list)[source]¶ Computes the dynamics Jacobian Inputs:
ν is the vehicle
x is the vehicle state [x,y,θ,v]ᵀ
u is the control [a,ω]
-
src.trajectory_smoothing.
compute_observation_jacobian
(v: src.trajectory_smoothing.VehicleSystem, x: list)[source]¶ Computes the observation Jacobian (H matrix) Inputs:
ν is the vehicle concrete type
x is the state estimate [x,y,θ,v]ᵀ
-
src.trajectory_smoothing.
get_control_noise_in_control_space
(v: src.trajectory_smoothing.VehicleSystem, u: list)[source]¶ To derive the covariance of the additional motion noise, we first determine the covariance matrix of the noise in control space Inputs:
ν is the vehicle concrete type
u is the control [a,ω]ᵀ
-
src.trajectory_smoothing.
get_observation_noise_covariance
(v: src.trajectory_smoothing.VehicleSystem)[source]¶
-
src.trajectory_smoothing.
get_process_noise_covariance
(v: src.trajectory_smoothing.VehicleSystem)[source]¶
-
src.trajectory_smoothing.
get_transform_control_noise_to_state_space
(v: src.trajectory_smoothing.VehicleSystem, u: list, x: list)[source]¶ To derive the covariance of the additional motion noise, we transform the covariance of noise in the control space by a linear approximation to the derivative of the motion function with respect to the motion parameters Inputs:
ν is the vehicle concrete type
u is the control [a,ω]ᵀ
x is the state estimate [x,y,θ,v]ᵀ