Skip to content

Commit bbc0e2c

Browse files
committed
obstacles without cbf
1 parent 7ae0b5b commit bbc0e2c

File tree

3 files changed

+19
-15
lines changed

3 files changed

+19
-15
lines changed

scripts/test16.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
NUM_STEPS = 100
2929
NUM_CHANNELS = 3
3030
GAMMA = 0.5
31-
USE_CBF = True
31+
USE_CBF = False
3232

3333
resolution = 2 * ROBOT_RANGE / GRID_STEPS
3434

@@ -223,7 +223,7 @@ def safety_constraint(u, A, b):
223223
# Check for obstacles (2x2 m)
224224
for obs in obstacles:
225225
# if p_w[0] > obs[0] - 1.0 and p_w[0] < obs[0] + 1.0 and p_w[1] > obs[1] - 1.0 and p_w[1] < obs[1] + 1.0:
226-
if np.linalg.norm(p_w - obs) < 0.5*SAFETY_DIST:
226+
if np.linalg.norm(p_w - obs) < SAFETY_DIST:
227227
img_obs[0, i, j] = 255
228228

229229
# -------- EVAL -------

scripts/test20.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@
2525
SAFETY_DIST = 2.0
2626
EPISODES = 50
2727
NUM_OBSTACLES = 4
28-
NUM_STEPS = 100
28+
NUM_STEPS = 50
2929
NUM_CHANNELS = 3
3030
GAMMA = 0.5
31-
USE_CBF = True
31+
USE_CBF = False
3232

3333
resolution = 2 * ROBOT_RANGE / GRID_STEPS
3434

@@ -224,7 +224,7 @@ def safety_constraint(u, A, b):
224224
# Check for obstacles (2x2 m)
225225
for obs in obstacles:
226226
# if p_w[0] > obs[0] - 1.0 and p_w[0] < obs[0] + 1.0 and p_w[1] > obs[1] - 1.0 and p_w[1] < obs[1] + 1.0:
227-
if np.linalg.norm(p_w - obs) < 0.5*SAFETY_DIST:
227+
if np.linalg.norm(p_w - obs) < SAFETY_DIST:
228228
img_obs[0, i, j] = 255
229229

230230
# -------- EVAL -------

scripts/test_2d_model.py

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@
2323
GRID_STEPS = 64
2424
vmax = 1.5
2525
SAFETY_DIST = 2.0
26-
EPISODES = 50
26+
EPISODES = 1
2727
NUM_OBSTACLES = 4
28-
NUM_STEPS = 100
28+
NUM_STEPS = 50
2929
NUM_CHANNELS = 3
3030
GAMMA = 0.5
31-
USE_CBF = True
31+
USE_CBF = False
3232

3333
resolution = 2 * ROBOT_RANGE / GRID_STEPS
3434

@@ -225,7 +225,7 @@ def safety_constraint(u, A, b):
225225
# Check for obstacles (2x2 m)
226226
for obs in obstacles:
227227
# if p_w[0] > obs[0] - 1.0 and p_w[0] < obs[0] + 1.0 and p_w[1] > obs[1] - 1.0 and p_w[1] < obs[1] + 1.0:
228-
if np.linalg.norm(p_w - obs) < 0.5*SAFETY_DIST:
228+
if np.linalg.norm(p_w - obs) < SAFETY_DIST:
229229
img_obs[0, i, j] = 255
230230

231231
# -------- EVAL -------
@@ -315,19 +315,23 @@ def safety_constraint(u, A, b):
315315
np.save(res_path/"eta12.npy", eval_data)
316316
np.save(res_path/"collisions12.npy", collision_counter)
317317

318-
'''
318+
"""
319+
fig, ax = plt.subplots(1, 1)
320+
plot_occgrid(Xg, Yg, Z, ax=ax)
321+
319322
for i in range(ROBOTS_NUM):
320323
ax.plot(robots_hist[:, i, 0], robots_hist[:, i, 1])
321324
ax.scatter(robots_hist[-1, i, 0], robots_hist[-1, i, 1])
322325
326+
th = np.arange(0, 2*np.pi+np.pi/20, np.pi/20)
323327
for obs in obstacles:
324-
o_x = np.array([obs[0]-1, obs[0]+1, obs[0]+1, obs[0]-1, obs[0]-1])
325-
o_y = np.array([obs[1]-1, obs[1]-1, obs[1]+1, obs[1]+1, obs[1]-1])
328+
# o_x = np.array([obs[0]-1, obs[0]+1, obs[0]+1, obs[0]-1, obs[0]-1])
329+
# o_y = np.array([obs[1]-1, obs[1]-1, obs[1]+1, obs[1]+1, obs[1]-1])
330+
o_x = obs[0] + 0.5*SAFETY_DIST*np.cos(th)
331+
o_y = obs[1] + 0.5*SAFETY_DIST*np.sin(th)
326332
ax.plot(o_x, o_y, c='r', linewidth=3)
327333
328-
for i in range(ROBOTS_NUM):
329-
ax2.scatter(robots_hist[-1, i, 0], robots_hist[-1, i, 1])
330334
331335
plt.show()
332-
'''
333336
337+
"""

0 commit comments

Comments
 (0)