Skip to content

Commit eb0d555

Browse files
committed
hw1 part1.3 finished
1 parent 42c0985 commit eb0d555

4 files changed

Lines changed: 35 additions & 27 deletions

File tree

GEMstack/knowledge/defaults/computation_graph.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ components:
4444
inputs: [vehicle, roadgraph, mission]
4545
outputs: route
4646
- driving_logic:
47-
inputs: all
47+
inputs:
4848
outputs: intent
4949
- motion_planning:
5050
inputs: all

GEMstack/onboard/planning/blink_component.py

Lines changed: 19 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,6 @@ def __init__(self, vehicle_interface : GEMHardwareInterface):
2222
self.prev_time = time.time()
2323
self.curr_time = time.time()
2424

25-
# while True :
26-
# self.curr_time = time.time()
27-
# if (self.curr_time - self.prev_time > 2):
28-
# self.update()
29-
# self.prev_time = self.curr_time
3025

3126
def rate(self):
3227
"""Requested update frequency, in Hz"""
@@ -59,30 +54,28 @@ def update(self, *args):
5954
# self.vehicle_interface.send_command(command)
6055
self.curr_time = time.time()
6156

62-
print("====================")
63-
print(args)
64-
print("====================")
57+
intent = args[0]
6558

66-
67-
if(self.curr_time - self.prev_time > 2):
68-
if command.left_turn_signal is True:
69-
# print("code goes if")
70-
command.left_turn_signal = False
71-
command.right_turn_signal = True
72-
73-
elif command.right_turn_signal is True:
74-
# print("code goes elif")
75-
command.left_turn_signal = False
76-
command.right_turn_signal = False
59+
if(intent == 2):
60+
if(self.curr_time - self.prev_time > 2):
61+
if command.left_turn_signal is True:
62+
# print("code goes if")
63+
command.left_turn_signal = False
64+
command.right_turn_signal = True
65+
66+
elif command.right_turn_signal is True:
67+
# print("code goes elif")
68+
command.left_turn_signal = False
69+
command.right_turn_signal = False
70+
71+
else:
72+
# print("code goes else")
73+
command.left_turn_signal = True
74+
command.right_turn_signal = False
7775

78-
else:
79-
# print("code goes else")
80-
command.left_turn_signal = True
81-
command.right_turn_signal = False
76+
self.prev_time = self.curr_time
77+
self.command = command
8278

83-
self.prev_time = self.curr_time
84-
self.command = command
85-
8679
self.vehicle_interface.send_command(command)
8780
# print(command.left_turn_signal, command.right_turn_signal)
8881

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
from ..component import Component
2+
from typing import List
3+
4+
class Driving_Logic(Component):
5+
def __init__(self):
6+
self.intent = 2 # halting
7+
8+
def state_outputs(self) -> List[str]:
9+
"""Returns the list of AllState outputs this component generates."""
10+
return ['intent']
11+
def update(self, *args, **kwargs):
12+
"""Update the component."""
13+
return self.intent

launch/blink_launch.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ recovery:
99
state_estimation : GNSSStateEstimator
1010
perception_normalization : StandardPerceptionNormalizer
1111
planning:
12+
driving_logic : driving_logic_component.Driving_Logic
1213
signaling : blink_component.BlinkDistress
1314
# trajectory_tracking : blink_component.BlinkDistress
1415
# Driving behavior for the GEM vehicle. Runs perception and planner but doesn't execute anything (no controller).
@@ -17,6 +18,7 @@ drive:
1718
state_estimation : GNSSStateEstimator
1819
perception_normalization : StandardPerceptionNormalizer
1920
planning:
21+
driving_logic : driving_logic_component.Driving_Logic
2022
signaling : blink_component.BlinkDistress
2123
# trajectory_tracking : blink_component.BlinkDistress
2224
log:

0 commit comments

Comments
 (0)