Permalink
...
Comparing changes
Open a pull request
- 5 commits
- 5 files changed
- 0 commit comments
- 1 contributor
Unified
Split
Showing
with
16 additions
and 8 deletions.
- +3 −0 hal-base/hal/constants.py
- +1 −1 hal-sim/hal_impl/data.py
- +7 −3 hal-sim/hal_impl/functions.py
- +1 −1 wpilib/setup.py
- +4 −3 wpilib/wpilib/joystick.py
View
3
hal-base/hal/constants.py
| @@ -256,3 +256,6 @@ class TalonSRXParam: | ||
| eSettingsChanged = 90 | ||
| eQuadFilterEn = 91 | ||
| ePidIaccum = 93 | ||
| + | ||
| +TalonSRXParam_tostr = {getattr(TalonSRXParam, p): p for p in dir(TalonSRXParam) if not p.startswith('__')} | ||
| + | ||
View
2
hal-sim/hal_impl/data.py
| @@ -133,7 +133,7 @@ def _reset_hal_data(hooks): | ||
| # povs are stored as integer values | ||
| 'joysticks': [{ | ||
| 'has_source': False, | ||
| - 'buttons': [False]*12, # numbered 0-11 | ||
| + 'buttons': [None] + [False]*12, # numbered 1-12 -- 0 is ignored | ||
| 'axes': [0]*constants.kMaxJoystickAxes, # x is 0, y is 1, .. | ||
| 'povs': [-1]*constants.kMaxJoystickPOVs # integers | ||
View
10
hal-sim/hal_impl/functions.py
| @@ -9,6 +9,9 @@ | ||
| from hal_impl.sim_hooks import SimHooks | ||
| from hal_impl.pwm_helpers import reverseByType | ||
| +import logging | ||
| +logger = logging.getLogger('hal') | ||
| + | ||
| hooks = SimHooks() | ||
| def reset_hal(): | ||
| @@ -228,6 +231,7 @@ def getFPGAButton(status): | ||
| return hal_data['fpga_button'] | ||
| def HALSetErrorData(errors, errorsLength, wait_ms): | ||
| + logger.warn(errors.decode('utf-8').strip()) | ||
| hal_data['error_data'] = errors | ||
| def HALGetControlWord(): | ||
| @@ -1348,17 +1352,17 @@ def c_TalonSRX_SetParam(handle, paramEnum, value): | ||
| def c_TalonSRX_RequestParam(handle, paramEnum): | ||
| params = hal_data['CAN'][handle.id]['params'] | ||
| - assert paramEnum in params, "Parameter %s not set!" # TODO: is this correct? | ||
| + assert paramEnum in params, "Parameter %s not set!" % constants.TalonSRXParam_tostr[paramEnum] # TODO: is this correct? | ||
| return params[paramEnum] | ||
| def c_TalonSRX_GetParamResponse(handle, paramEnum): | ||
| params = hal_data['CAN'][handle.id]['params'] | ||
| - assert paramEnum in params, "Parameter %s not set!" # TODO: is this correct? | ||
| + assert paramEnum in params, "Parameter %s not set!" % constants.TalonSRXParam_tostr[paramEnum] # TODO: is this correct? | ||
| return params[paramEnum] | ||
| def c_TalonSRX_GetParamResponseInt32(handle, paramEnum): | ||
| params = hal_data['CAN'][handle.id]['params'] | ||
| - assert paramEnum in params, "Parameter %s not set!" # TODO: is this correct? | ||
| + assert paramEnum in params, "Parameter %s not set!" % constants.TalonSRXParam_tostr[paramEnum] # TODO: is this correct? | ||
| return params[paramEnum] | ||
| def c_TalonSRX_SetStatusFrameRate(handle, frameEnum, periodMs): | ||
View
2
wpilib/setup.py
| @@ -49,7 +49,7 @@ | ||
| url='https://github.com/robotpy/robotpy-wpilib', | ||
| keywords='frc first robotics wpilib', | ||
| packages=find_packages(), | ||
| - install_requires=['pynetworktables>=2015.0.6'], | ||
| + install_requires=['pynetworktables>=2015.1.0'], | ||
| license="BSD License", | ||
| classifiers=[ | ||
| "Development Status :: 5 - Production/Stable", | ||
View
7
wpilib/wpilib/joystick.py
| @@ -169,6 +169,7 @@ def getAxis(self, axis): | ||
| example :func:`getX`). | ||
| :param axis: The axis to read. | ||
| + :type axis: :class:`Joystick.AxisType` | ||
| :returns: The value of the axis. | ||
| :rtype: float | ||
| """ | ||
| @@ -183,7 +184,7 @@ def getAxis(self, axis): | ||
| elif axis == self.AxisType.kThrottle: | ||
| return self.getThrottle() | ||
| else: | ||
| - return 0.0 | ||
| + raise ValueError("Invalid axis specified! Must be one of wpilib.Joystick.AxisType, or use getRawAxis instead") | ||
| def getAxisCount(self): | ||
| """For the current joystick, return the number of axis""" | ||
| @@ -280,7 +281,7 @@ def getButton(self, button): | ||
| elif button == self.ButtonType.kTop: | ||
| return self.getTop() | ||
| else: | ||
| - return False | ||
| + raise ValueError("Invalid button specified! Must be one of wpilib.Joystick.ButtonType, or use getRawButton instead") | ||
| def getMagnitude(self): | ||
| """Get the magnitude of the direction vector formed by the joystick's | ||
| @@ -347,7 +348,7 @@ def setRumble(self, type, value): | ||
| elif type == self.RumbleType.kRightRumble_val: | ||
| self.rightRumble = int(value*65535) | ||
| else: | ||
| - raise ValueError("Invalid Rumble type: {}".format(type)) | ||
| + raise ValueError("Invalid wpilib.Joystick.RumbleType: {}".format(type)) | ||
| self.flush_outputs() | ||
| def setOutput(self, outputNumber, value): | ||