@@ -31,8 +31,9 @@ def __init__(self):
31
31
self .yawrate_reso = 0.1 * math .pi / 180.0 # [rad/s]
32
32
self .dt = 0.1 # [s]
33
33
self .predict_time = 3.0 # [s]
34
- self .to_goal_cost_gain = 1.0
34
+ self .to_goal_cost_gain = 0.15
35
35
self .speed_cost_gain = 1.0
36
+ self .ob_cost_gain = 1.0
36
37
self .robot_radius = 1.0 # [m]
37
38
38
39
@@ -133,18 +134,16 @@ def calc_obstacle_cost(traj, ob, config):
133
134
if minr >= r :
134
135
minr = r
135
136
136
- return 1.0 / minr # OK
137
+ return config . ob_cost_gain / minr # OK
137
138
138
139
139
140
def calc_to_goal_cost (traj , goal , config ):
140
- # calc to goal cost. It is 2D norm.
141
-
142
- goal_magnitude = math .sqrt (goal [0 ]** 2 + goal [1 ]** 2 )
143
- traj_magnitude = math .sqrt (traj [- 1 , 0 ]** 2 + traj [- 1 , 1 ]** 2 )
144
- dot_product = (goal [0 ] * traj [- 1 , 0 ]) + (goal [1 ] * traj [- 1 , 1 ])
145
- error = dot_product / (goal_magnitude * traj_magnitude )
146
- error_angle = math .acos (error )
147
- cost = config .to_goal_cost_gain * error_angle
141
+ # calc to goal cost.
142
+
143
+ dx = goal [0 ] - traj [- 1 , 0 ]
144
+ dy = goal [1 ] - traj [- 1 , 1 ]
145
+ error_angle = math .atan2 (dy , dx )
146
+ cost = config .to_goal_cost_gain * abs (error_angle - traj [- 1 , 2 ])
148
147
149
148
return cost
150
149
0 commit comments