-
Notifications
You must be signed in to change notification settings - Fork 378
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add several accelerations to custom output #939
Changes from 93 commits
da243f9
951c755
df0bb66
863f360
87dcff2
d192a9f
92a745d
215d4ab
5bb7074
97f3ccd
3608652
0a83576
9b649ef
c18ec58
5878eae
34cecff
fc99836
6c11a70
d6ffaa6
97400c7
151e3b2
9d2026e
43eeee0
8eed7e1
c373e94
a88c209
89f8d1d
306a01f
0d5fa6b
0ade197
1111e9a
a4c7d67
36e8851
ebb2921
e4c02bb
505d646
7d52445
c3b2a51
dc881e0
ee1188e
65c9ee0
5a3ff57
ddc53fb
e7ac1a9
c970219
3b10524
638f9b4
bc8584a
0ee6646
3af5595
8d4ad29
aa14dbf
00a526b
de35f90
979d047
fdd983e
6af7e02
72d4733
420ea3f
e45eb92
d578e63
32c0528
c7cd963
b5be92a
6884960
7e549be
a799abd
f4fa426
2563818
498e08a
d7da535
3df2312
28d4f73
0779832
b3f15a3
d66a0ab
38af177
fceedf8
df182ad
d888405
27e2960
69f6f55
4f2f23e
d2ba069
8eee772
b5f5424
3c6dcf7
ddf6a24
53cf035
b49dbce
528f0aa
cbf6a42
8645811
1669787
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -113,7 +113,10 @@ def initialize(self, vehicles): | |
self.__vehicles[veh_id] = dict() | ||
self.__vehicles[veh_id]['type'] = typ['veh_id'] | ||
self.__vehicles[veh_id]['initial_speed'] = typ['initial_speed'] | ||
self.__vehicles[veh_id]["accel_without_noise"] = None | ||
self.__vehicles[veh_id]["accel_no_noise_no_failsafe"] = None | ||
self.__vehicles[veh_id]["accel_no_noise_with_failsafe"] = None | ||
self.__vehicles[veh_id]["accel_with_noise_no_failsafe"] = None | ||
self.__vehicles[veh_id]["accel_with_noise_with_failsafe"] = None | ||
self.num_vehicles += 1 | ||
if typ['acceleration_controller'][0] == RLController: | ||
self.num_rl_vehicles += 1 | ||
|
@@ -964,6 +967,20 @@ def apply_acceleration(self, veh_ids, acc): | |
next_vel = max([this_vel + acc[i] * self.sim_step, 0]) | ||
self.kernel_api.vehicle.slowDown(vid, next_vel, 1e-3) | ||
|
||
def apply_acceleration_not_smooth(self, veh_ids, acc): | ||
"""See parent class.""" | ||
# to hand the case of a single vehicle | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: to handle |
||
if type(veh_ids) == str: | ||
veh_ids = [veh_ids] | ||
acc = [acc] | ||
|
||
for i, vid in enumerate(veh_ids): | ||
if acc[i] is not None and vid in self.get_ids(): | ||
self.__vehicles[vid]["accel"] = acc[i] | ||
this_vel = self.get_speed(vid) | ||
next_vel = max([this_vel + acc[i] * self.sim_step, 0]) | ||
self.kernel_api.vehicle.setSpeed(vid, next_vel) | ||
Comment on lines
+973
to
+978
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. how is this different than the normal method? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the normal method uses slowDown() method which applies some sort of smoothing. here setSpeed() method is used which doesn't apply smoothing. |
||
|
||
def apply_lane_change(self, veh_ids, direction): | ||
"""See parent class.""" | ||
# to hand the case of a single vehicle | ||
|
@@ -1130,15 +1147,45 @@ def get_accel(self, veh_id): | |
self.__vehicles[veh_id]["accel"] = None | ||
return self.__vehicles[veh_id]["accel"] | ||
|
||
def update_accel_without_noise(self, veh_id, accel_without_noise): | ||
def update_accel_no_noise_no_failsafe(self, veh_id, accel_no_noise_no_failsafe): | ||
"""See parent class.""" | ||
self.__vehicles[veh_id]["accel_no_noise_no_failsafe"] = accel_no_noise_no_failsafe | ||
|
||
def update_accel_no_noise_with_failsafe(self, veh_id, accel_no_noise_with_failsafe): | ||
"""See parent class.""" | ||
self.__vehicles[veh_id]["accel_no_noise_with_failsafe"] = accel_no_noise_with_failsafe | ||
|
||
def update_accel_with_noise_no_failsafe(self, veh_id, accel_with_noise_no_failsafe): | ||
"""See parent class.""" | ||
self.__vehicles[veh_id]["accel_with_noise_no_failsafe"] = accel_with_noise_no_failsafe | ||
|
||
def update_accel_with_noise_with_failsafe(self, veh_id, accel_with_noise_with_failsafe): | ||
"""See parent class.""" | ||
self.__vehicles[veh_id]["accel_with_noise_with_failsafe"] = accel_with_noise_with_failsafe | ||
|
||
def get_accel_no_noise_no_failsafe(self, veh_id): | ||
"""See parent class.""" | ||
if "accel_no_noise_no_failsafe" not in self.__vehicles[veh_id]: | ||
self.__vehicles[veh_id]["accel_no_noise_no_failsafe"] = None | ||
return self.__vehicles[veh_id]["accel_no_noise_no_failsafe"] | ||
|
||
def get_accel_no_noise_with_failsafe(self, veh_id): | ||
"""See parent class.""" | ||
if "accel_no_noise_with_failsafe" not in self.__vehicles[veh_id]: | ||
self.__vehicles[veh_id]["accel_no_noise_with_failsafe"] = None | ||
return self.__vehicles[veh_id]["accel_no_noise_with_failsafe"] | ||
|
||
def get_accel_with_noise_no_failsafe(self, veh_id): | ||
"""See parent class.""" | ||
self.__vehicles[veh_id]["accel_without_noise"] = accel_without_noise | ||
if "accel_with_noise_no_failsafe" not in self.__vehicles[veh_id]: | ||
self.__vehicles[veh_id]["accel_with_noise_no_failsafe"] = None | ||
return self.__vehicles[veh_id]["accel_with_noise_no_failsafe"] | ||
|
||
def get_accel_without_noise(self, veh_id): | ||
def get_accel_with_noise_with_failsafe(self, veh_id): | ||
"""See parent class.""" | ||
if "accel_without_noise" not in self.__vehicles[veh_id]: | ||
self.__vehicles[veh_id]["accel_without_noise"] = None | ||
return self.__vehicles[veh_id]["accel_without_noise"] | ||
if "accel_with_noise_with_failsafe" not in self.__vehicles[veh_id]: | ||
self.__vehicles[veh_id]["accel_with_noise_with_failsafe"] = None | ||
return self.__vehicles[veh_id]["accel_with_noise_with_failsafe"] | ||
|
||
def get_realized_accel(self, veh_id): | ||
"""See parent class.""" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since there is a key existence check in all the get methods below. There is no need to initialize them here.