Skip to content
Permalink
Browse files

Merge pull request #23 from davidko-ww/beacon_v2_robot_id

Added initial support for Beacon V2...
  • Loading branch information
elenzil committed Oct 8, 2019
2 parents 907add2 + d9accd7 commit 8b3fc73897356f7515370e9f81214e6a0695a5fa
Showing with 22 additions and 1 deletion.
  1. +15 −0 WonderPy/components/wwSensorBeacon.py
  2. +7 −1 WonderPy/core/wwSensors.py
@@ -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]
@@ -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

@@ -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)
@@ -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,
@@ -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

0 comments on commit 8b3fc73

Please sign in to comment.
You can’t perform that action at this time.