Skip to content

Commit b63ca95

Browse files
authored
Merge pull request #11 from kaka012/add-sonar-perceptor
Implement the sonar perceptor in spark_agent.py
2 parents 03a61f1 + 41871f7 commit b63ca95

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

software_installation/spark_agent.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
from threading import Thread
77
from math import pi, atan2, asin, cos, sin
88
from sexpr import str2sexpr
9-
import numpy as np
109

1110
DEG_TO_RAD = pi / 180
1211

@@ -19,6 +18,7 @@
1918
GAME_STATE_PERCEPTOR = "GS"
2019
GPS_PERCEPTOR = "GPS"
2120
BAT_PERCEPTOR = "BAT"
21+
SONAR_PERCEPTOR = "US"
2222

2323
VISION_PERCEPTOR = "See"
2424
VISION_PERCEPTOR_TRUE_BALL = "ballpos"
@@ -132,6 +132,7 @@ def __init__(self):
132132
self.game_state = GameState()
133133
self.gps = {}
134134
self.imu = [0, 0] # [AngleX, AngleY]
135+
self.us = {}
135136

136137
def update(self, sexp):
137138
for s in sexp:
@@ -164,6 +165,8 @@ def update(self, sexp):
164165
self.gps[s[1][1]] = [float(v) for v in s[2][1:]]
165166
elif name == BAT_PERCEPTOR:
166167
self.bat = float(s[1])
168+
elif name == SONAR_PERCEPTOR:
169+
self.us[s[1]] = [float(dist) for dist in s[2]]
167170
else:
168171
raise RuntimeError('unknown perception: ' + str(s))
169172

0 commit comments

Comments
 (0)