Skip to content

Commit fb9e159

Browse files
shalinmehtalgsvlmartins-mozeiko
authored andcommitted
Add Custom callback for EgoVehicle
1 parent 387ec36 commit fb9e159

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

lgsvl/agent.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,9 @@ def apply_control(self, control, sticky = False):
203203
args["control"]["turn_signal_right"] = control.turn_signal_right
204204
self.remote.command("vehicle/apply_control", args)
205205

206+
def on_custom(self, fn):
207+
self.simulator._add_callback(self, "custom", fn)
208+
206209

207210
class NpcVehicle(Vehicle):
208211
def __init__(self, uid, simulator):

lgsvl/sensor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,4 +126,4 @@ def __init__(self, remote, j):
126126
class CanBusSensor(Sensor):
127127
def __init__(self, remote, j):
128128
super().__init__(remote, j["uid"], j["name"])
129-
self.frequency = j["frequency"]
129+
self.frequency = j["frequency"]

lgsvl/simulator.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ def _process_events(self, events):
8989
fn(agent)
9090
elif event_type == "lane_change":
9191
fn(agent)
92+
elif event_type == "custom":
93+
fn(agent, ev["kind"], ev["context"])
9294
if self.stopped:
9395
return
9496

0 commit comments

Comments
 (0)