@@ -138,6 +138,12 @@ def safety_constraint(u, A, b):
138138
139139  obstacles  =  np .array ([5.0 , - 5.0 ])
140140  OBS_W  =  20.0 
141+   vs  =  []
142+   vs .append (Point (np .array ([obstacles [0 ]- 0.5 * OBS_W , obstacles [1 ]- 0.5 * OBS_W ])))
143+   vs .append (Point (np .array ([obstacles [0 ]+ 0.5 * OBS_W , obstacles [1 ]- 0.5 * OBS_W ])))
144+   vs .append (Point (np .array ([obstacles [0 ]+ 0.5 * OBS_W , obstacles [1 ]+ 0.5 * OBS_W ])))
145+   vs .append (Point (np .array ([obstacles [0 ]- 0.5 * OBS_W , obstacles [1 ]+ 0.5 * OBS_W ])))
146+   obs_polygon  =  Polygon (vs )
141147
142148  fig , ax  =  plt .subplots (1 , 1 , figsize = (8 ,8 ))
143149  plot_occgrid (Xg , Yg , Z , ax = ax )
@@ -158,6 +164,8 @@ def safety_constraint(u, A, b):
158164  dt  =  0.25 
159165  failed  =  False 
160166
167+   
168+ 
161169
162170
163171
@@ -273,9 +281,8 @@ def safety_constraint(u, A, b):
273281        for  j  in  np .arange (ymin , ymax , discretize_precision ):
274282          pt_i  =  Point (i ,j )
275283          insideObs  =  False 
276-           for  obs  in  obs_polygons :
277-               if  obs .contains (pt_i ):
278-                   insideObs  =  True 
284+           if  obs_polygon .contains (pt_i ):
285+               insideObs  =  True 
279286
280287          if  lim_region .contains (pt_i ) and  not  insideObs :
281288            dA_pdf  =  dA  *  gmm_pdf (i , j , means , covariances , mix )
@@ -332,9 +339,7 @@ def safety_constraint(u, A, b):
332339        all_stopped  =  False 
333340
334341    robots_hist  =  np .concatenate ((robots_hist , np .expand_dims (points , 0 )))
335-     eta  =  num  /  denom 
336342    # print("Efficiency: ", eta) 
337-     eval_data [episode , s - 1 ] =  eta [0 ]
338343
339344
340345
0 commit comments