Skip to content

Commit

Permalink
sensor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Nitish Bhupathi Raju authored and Nitish Bhupathi Raju committed Apr 1, 2024
1 parent bbd9183 commit 88d4445
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 14 deletions.
39 changes: 32 additions & 7 deletions sense.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,10 @@ def sense(self, agent: BaseAgent, state_dict, lane_map):
x = cont['ego.x']
y = cont['ego.y']
position = np.array([x,y])
lateral = lane_map.get_lateral_distance("T0", position)
true_lateral = lane_map.get_lateral_distance("T0", position)

blowup = true_lateral + np.random.uniform(low=-0.25, high=0.25, size=5)
lateral = random.choice(blowup)

if(lateral < -1):
cont['ego.s'] = 0
Expand All @@ -77,6 +80,9 @@ def sense(self, agent: BaseAgent, state_dict, lane_map):
else:
cont['ego.s'] = 1


#perception contract: blow up lateral array and randomly sample

else:
if agent.id == 'car':
cont['ego.x'] = [state_dict['car'][0][0][1], state_dict['car'][0][1][1]]
Expand All @@ -86,14 +92,21 @@ def sense(self, agent: BaseAgent, state_dict, lane_map):
cont['ego.t'] = [state_dict['car'][0][0][5], state_dict['car'][0][1][5]]
disc['ego.agent_mode'] = state_dict['car'][1][0]

lateral = []
true_lateral = []
#print("new four")
for x in cont['ego.x']:
for y in cont['ego.y']:
position = np.array([x,y])
print(position)
lateral.append(lane_map.get_lateral_distance("T0", position))
#print(position)
true_lateral.append(lane_map.get_lateral_distance("T0", position))

min_lateral = min(lateral)
blowup = []
for l in true_lateral:
blowup += list(l + np.random.uniform(low=-0.25, high=0.25, size=5))

min_lateral = min(blowup) #+ 0.1

#perception contract: blow up lateral array and choose minimum

if(min_lateral < -1):
cont['ego.s'] = [0,0]
Expand All @@ -113,7 +126,7 @@ def __init__(self):
segment0 = CircularLane("Seg0", [14, 14], 12, np.pi * 3 / 2, np.pi, True, 4)
segment1 = StraightLane("Seg1", [2, 14], [2, 24], 4)
segment2 = CircularLane("Seg2", [14, 24], 12, np.pi, 0, True, 4)
segment3 = StraightLane("Seg3", [26, 24], [26, 14], 4)
#segment3 = StraightLane("Seg3", [26, 24], [26, 14], 4)
lane0 = Lane("T0", [segment0, segment1, segment2])# segment3])
self.add_lanes([lane0])
self.h_dict = {("T0", "Left", "Right"): "T0", ("T0", "Right", "Left"): "T0",
Expand Down Expand Up @@ -192,7 +205,19 @@ def __init__(self, id, code=None, file_name=None):
#traces_simu = scenario.simulate(60,0.01)
traces_veri = scenario.verify(10, 0.01)

traces_veri.dump("out.json")
nodes = traces_veri._get_all_nodes(traces_veri.root)
#print(len(nodes))
# for n in nodes:
# print("new node")
# for l in n.trace['car']:
# print(l[1:3])

#traces_veri.visualize()
#print(nodes)
#print("height")
#print(traces_veri.height)

#traces_veri.dump("out.json")

# fig = go.Figure()
# fig = simulation_tree(traces_simu, None, fig, 1, 2, [0, 1], "lines", "trace")
Expand Down
10 changes: 5 additions & 5 deletions sensedl.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@ def decisionLogic(ego: State, track_map):
output.track_mode = TrackMode.T0


x = ego.x
y = ego.y
position = [x,y]
lateral = track_map.get_lateral_distance("T0", position)
# x = ego.x
# y = ego.y
# position = [x,y]
# lateral = track_map.get_lateral_distance("T0", position)

# assert -2 <= lateral and lateral <= 2
#assert -2 <= lateral and lateral <= 2
#assert ((ego.x-14)**2 + (ego.y-14)**2 >= 10**2 and (ego.x-14)**2 + (ego.y-14)**2 <= 14**2 and ego.y <= 14) or (ego.x > 0 and ego.x < 4 and ego.y > 14 and ego.y <= 24) or ((ego.x-14)**2 + (ego.y-24)**2 >= 10**2 and (ego.x-14)**2 + (ego.y-24)**2 <= 14**2 and ego.y > 24)
assert True

Expand Down
2 changes: 2 additions & 0 deletions verse/analysis/dryvr.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,8 @@ def calc_bloated_tube(
traces = [sim_func(mode_label, cur_center, time_horizon, time_step, lane_map)]
# Simulate SIMTRACENUM times to learn the sensitivity
for i in range(sim_trace_num):
# modified
random.seed(i)
new_init_point = randomPoint(initial_set[0], initial_set[1])
traces.append(sim_func(mode_label, new_init_point, time_horizon, time_step, lane_map))

Expand Down
11 changes: 9 additions & 2 deletions verse/analysis/verifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ def compute_full_reachtube_step(
uncertain_param = node.uncertain_param[agent_id]
if consts.reachability_method == ReachabilityMethod.DRYVR:
# pp(('tube', agent_id, mode, inits))
#exact rectangles
(
cur_bloated_tube,
cache_tube_update,
Expand Down Expand Up @@ -666,6 +667,8 @@ def compute_full_reachtube(
# print(f">>>>>>>> Number of transitions happening: {num_transitions}")
self.num_transitions = num_transitions

#print(len(self.nodes))

return self.reachtube_tree

@staticmethod
Expand Down Expand Up @@ -789,11 +792,15 @@ def get_transition_verify_opt(
guard_hits = []
guard_hit = False
reduction_rate = 10
reduction_queue = [(0, trace_length, trace_length)]
reduction_queue = []
for i in range(trace_length):
reduction_queue.append((i,i+1,1))
#reduction_queue = [(0, trace_length, trace_length)]
# for idx, end_idx,combine_len in reduction_queue:
hits = []
while reduction_queue:
idx, end_idx, combine_len = reduction_queue.pop()
#don't over approximate rectangles
idx, end_idx, combine_len = reduction_queue.pop(0)
reduction_needed = False
# print((idx, combine_len))
any_contained = False
Expand Down

0 comments on commit 88d4445

Please sign in to comment.