Skip to content

Commit

Permalink
Added initial support for Beacon V2...
Browse files Browse the repository at this point in the history
Added support for getting Beacon Robot ID.
  • Loading branch information
davidko-ww committed Aug 14, 2019
1 parent 907add2 commit d9accd7
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
15 changes: 15 additions & 0 deletions WonderPy/components/wwSensorBeacon.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,3 +153,18 @@ def get_robot_type(self):
highest_count = new_count

return ret


class WWSensorBeaconV2(WWSensorBase):
# For now, just use this to keep track of Beacon IDs
def __init__(self, robot):
super(WWSensorBeaconV2, self).__init__(robot)
self._robot_id_raw = None

@property
def robot_id_raw(self):
return self._robot_id_raw

def parse(self, single_component_dictionary):
if _rcv.WW_SENSOR_VALUE_BEACON_ROBOT_ID in single_component_dictionary:
self._robot_id_raw = single_component_dictionary[_rcv.WW_SENSOR_VALUE_BEACON_ROBOT_ID]
8 changes: 7 additions & 1 deletion WonderPy/core/wwSensors.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from WonderPy.components.wwSensorMedia import WWSensorMedia
from WonderPy.components.wwSensorAngle import WWSensorAngle
from WonderPy.components.wwSensorDistance import WWSensorDistance
from WonderPy.components.wwSensorBeacon import WWSensorBeacon
from WonderPy.components.wwSensorBeacon import WWSensorBeacon,WWSensorBeaconV2
from WonderPy.components.wwSensorWheel import WWSensorWheel
from WonderPy.components.wwSensorGyroscope import WWSensorGyroscope

Expand Down Expand Up @@ -46,6 +46,7 @@ def setup_all_sensors(self, robot):

# dash & cue
self._beacon = WWSensorBeacon (robot)
self._beacon_v2 = WWSensorBeaconV2 (robot)
self._distance_front_left_facing = WWSensorDistance (robot)
self._distance_front_right_facing = WWSensorDistance (robot)
self._distance_rear = WWSensorDistance (robot)
Expand All @@ -60,6 +61,7 @@ def setup_all_sensors(self, robot):
_rc.WW_SENSOR_ACCELEROMETER : self._accelerometer,
_rc.WW_SENSOR_ANIMATION_PLAYING : self._animation,
_rc.WW_SENSOR_BEACON : self._beacon,
_rc.WW_SENSOR_BEACON_V2 : self._beacon_v2,
_rc.WW_SENSOR_BODY_POSE : self._pose,
_rc.WW_SENSOR_BUTTON_1 : self._button_1,
_rc.WW_SENSOR_BUTTON_2 : self._button_2,
Expand Down Expand Up @@ -89,6 +91,10 @@ def animation(self):
def beacon(self):
return self._beacon

@property
def beacon_v2(self):
return self._beacon_v2

@property
def button_1(self):
return self._button_1
Expand Down

0 comments on commit d9accd7

Please sign in to comment.