Skip to content
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

Fixed MAC address #54

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion wiimote/nodes/wiimote_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,13 @@ def runWiimoteNode(self):
# and are handled there:

rospy.init_node('wiimote', anonymous=True, log_level=rospy.ERROR) # log_level=rospy.DEBUG
wiimoteDevice = wiimote.WIIMote.WIIMote()
self.addr = rospy.get_param("~fixed_wiimote_address","")

if ":" in self.addr :
wiimoteDevice = wiimote.WIIMote.WIIMote(self.addr)
else :
wiimoteDevice = wiimote.WIIMote.WIIMote()

wiimoteDevice.zeroDevice()

try:
Expand Down
20 changes: 14 additions & 6 deletions wiimote/src/wiimote/WIIMote.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,16 +92,15 @@ class WIIMote(object):


"""

# Public constants:

BATTERY_MAX = cwiid.BATTERY_MAX # 208 a.k.a. 0xD0

# Public vars:


_fixed_addr = False
_addr = ""
# Private constants:


# Private vars:

Expand Down Expand Up @@ -132,7 +131,7 @@ class WIIMote(object):
# __init__
#------------------

def __init__(self, theSampleRate=0, wiiStateLock=None, gatherCalibrationStats=False):
def __init__(self, addr="", theSampleRate=0, wiiStateLock=None, gatherCalibrationStats=False):
"""Instantiate a Wiimote driver instance, which controls one physical Wiimote device.

Parameters:
Expand All @@ -142,6 +141,12 @@ def __init__(self, theSampleRate=0, wiiStateLock=None, gatherCalibrationStats=Fa
theSampleRate= x: every x seconds
"""

# Use fixed MAC address for wiimote if available
self._addr = addr
if ":" in self._addr :
self._fixed_addr = True


self.lastZeroingTime = 0.

self.gatherCalibrationStats = gatherCalibrationStats
Expand Down Expand Up @@ -189,7 +194,10 @@ def __init__(self, theSampleRate=0, wiiStateLock=None, gatherCalibrationStats=Fa
promptUsr("Press buttons 1 and 2 together to pair (within 6 seconds).\n (If no blinking lights, press power button for ~3 seconds.)")

try:
self._wm = cwiid.Wiimote()
if self._fixed_addr :
self._wm = cwiid.Wiimote(self._addr)
else :
self._wm = cwiid.Wiimote()
except RuntimeError:
raise WiimoteNotFoundError("No Wiimote found to pair with.")
exit()
Expand Down