Aero
24-02-2015, 19:50
Hey guys, I'm experiencing a lil bit of trouble with the PDP's CAN stuff.
I'm trying to make our compressor disable once we're drawing a certain amount of amperage, just cause that current allowance could be better used.
For some reason, calling the PDP's getTotalCurrent method is causing our robot to crash with a "CTRE CAN Recieve Timeout"
Here's the code and full error:
from wpilib import Compressor, PowerDistributionPanel
class Pneumatics(object):
AMPERAGE_THRESHOLD = 20
def __init__(self):
self.comp = Compressor()
self.pdp = PowerDistributionPanel()
def update(self):
"""
Monitors the PDP for amp draw, and disables the compressor if amp draw is above a threshold to prevent brownouts.
:return:
"""
if self.pdp.getTotalCurrent() > self.AMPERAGE_THRESHOLD:
self.comp.stop()
else:
self.comp.start()
ERROR Unhandled exception:
Traceback (most recent call last):
File "/home/lvuser/py/robot.py", line 110, in <module>
run(Drake)
File "/usr/local/lib/python3.4/site-packages/wpilib/_impl/main.py", line 100, in run
retval = options.cmdobj.run(options, robot_class, **kwargs)
File "/usr/local/lib/python3.4/site-packages/hal/main.py", line 11, in run
return robot_class.main(robot_class)
File "/usr/local/lib/python3.4/site-packages/wpilib/robotbase.py", line 185, in main
robot.startCompetition()
File "/usr/local/lib/python3.4/site-packages/wpilib/samplerobot.py", line 162, in startCompetition
self.operatorControl()
File "/home/lvuser/py/robot.py", line 95, in operatorControl
self.update()
File "/home/lvuser/py/robot.py", line 102, in update
component.update()
File "/home/lvuser/py/components/pneumatics.py", line 16, in update
if self.pdp.getTotalCurrent() > self.AMPERAGE_THRESHOLD:
File "/usr/local/lib/python3.4/site-packages/wpilib/powerdistributionpanel.py", line 56, in getTotalCurrent
return hal.getPDPTotalCurrent()
File "/usr/local/lib/python3.4/site-packages/hal/functions.py", line 40, in outer
raise HALError(getHALErrorMessage(status.value))
hal.exceptions.HALError: CTRE CAN Recieve Timeout
I'm trying to make our compressor disable once we're drawing a certain amount of amperage, just cause that current allowance could be better used.
For some reason, calling the PDP's getTotalCurrent method is causing our robot to crash with a "CTRE CAN Recieve Timeout"
Here's the code and full error:
from wpilib import Compressor, PowerDistributionPanel
class Pneumatics(object):
AMPERAGE_THRESHOLD = 20
def __init__(self):
self.comp = Compressor()
self.pdp = PowerDistributionPanel()
def update(self):
"""
Monitors the PDP for amp draw, and disables the compressor if amp draw is above a threshold to prevent brownouts.
:return:
"""
if self.pdp.getTotalCurrent() > self.AMPERAGE_THRESHOLD:
self.comp.stop()
else:
self.comp.start()
ERROR Unhandled exception:
Traceback (most recent call last):
File "/home/lvuser/py/robot.py", line 110, in <module>
run(Drake)
File "/usr/local/lib/python3.4/site-packages/wpilib/_impl/main.py", line 100, in run
retval = options.cmdobj.run(options, robot_class, **kwargs)
File "/usr/local/lib/python3.4/site-packages/hal/main.py", line 11, in run
return robot_class.main(robot_class)
File "/usr/local/lib/python3.4/site-packages/wpilib/robotbase.py", line 185, in main
robot.startCompetition()
File "/usr/local/lib/python3.4/site-packages/wpilib/samplerobot.py", line 162, in startCompetition
self.operatorControl()
File "/home/lvuser/py/robot.py", line 95, in operatorControl
self.update()
File "/home/lvuser/py/robot.py", line 102, in update
component.update()
File "/home/lvuser/py/components/pneumatics.py", line 16, in update
if self.pdp.getTotalCurrent() > self.AMPERAGE_THRESHOLD:
File "/usr/local/lib/python3.4/site-packages/wpilib/powerdistributionpanel.py", line 56, in getTotalCurrent
return hal.getPDPTotalCurrent()
File "/usr/local/lib/python3.4/site-packages/hal/functions.py", line 40, in outer
raise HALError(getHALErrorMessage(status.value))
hal.exceptions.HALError: CTRE CAN Recieve Timeout