11
11
12
12
13
13
class LateralPlanner :
14
- def __init__ (self , use_lanelines = True , wide_camera = False ):
14
+ def __init__ (self , CP , use_lanelines = True , wide_camera = False ):
15
15
self .use_lanelines = use_lanelines
16
16
self .LP = LanePlanner (wide_camera )
17
17
self .DH = DesireHelper ()
18
18
19
19
self .last_cloudlog_t = 0
20
+ self .steer_rate_cost = CP .steerRateCost
20
21
self .solution_invalid_cnt = 0
21
22
22
23
self .path_xyz = np .zeros ((TRAJECTORY_SIZE , 3 ))
@@ -58,12 +59,12 @@ def update(self, sm):
58
59
# Calculate final driving path and set MPC costs
59
60
if self .use_lanelines :
60
61
d_path_xyz = self .LP .get_d_path (v_ego , self .t_idxs , self .path_xyz )
61
- self .lat_mpc .set_weights (MPC_COST_LAT .PATH , MPC_COST_LAT .HEADING , MPC_COST_LAT . STEER_RATE )
62
+ self .lat_mpc .set_weights (MPC_COST_LAT .PATH , MPC_COST_LAT .HEADING , self . steer_rate_cost )
62
63
else :
63
64
d_path_xyz = self .path_xyz
64
65
# Heading cost is useful at low speed, otherwise end of plan can be off-heading
65
66
heading_cost = interp (v_ego , [5.0 , 10.0 ], [MPC_COST_LAT .HEADING , 0.15 ])
66
- self .lat_mpc .set_weights (MPC_COST_LAT .PATH , heading_cost , MPC_COST_LAT . STEER_RATE )
67
+ self .lat_mpc .set_weights (MPC_COST_LAT .PATH , heading_cost , self . steer_rate_cost )
67
68
68
69
y_pts = np .interp (v_ego * self .t_idxs [:LAT_MPC_N + 1 ], np .linalg .norm (d_path_xyz , axis = 1 ), d_path_xyz [:, 1 ])
69
70
heading_pts = np .interp (v_ego * self .t_idxs [:LAT_MPC_N + 1 ], np .linalg .norm (self .path_xyz , axis = 1 ), self .plan_yaw )
@@ -78,7 +79,7 @@ def update(self, sm):
78
79
y_pts ,
79
80
heading_pts )
80
81
# init state for next
81
- # mpc.u_sol is the desired curvature rate given x0 curv state.
82
+ # mpc.u_sol is the desired curvature rate given x0 curv state.
82
83
# with x0[3] = measured_curvature, this would be the actual desired rate.
83
84
# instead, interpolate x_sol so that x0[3] is the desired curvature for lat_control.
84
85
self .x0 [3 ] = interp (DT_MDL , self .t_idxs [:LAT_MPC_N + 1 ], self .lat_mpc .x_sol [:, 3 ])
0 commit comments