Go to Post I would be thankful to just participate in champs, I would be happy with just that. - Brandon_L [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rating: Thread Rating: 3 votes, 5.00 average. Display Modes
Prev Previous Post   Next Post Next
  #1   Spotlight this post!  
Unread 24-02-2015, 19:50
Aero Aero is offline
consumes pizza, produces code
AKA: Ari Lotter
FRC #0865 (Warp7)
Team Role: Programmer
 
Join Date: May 2013
Rookie Year: 2013
Location: Toronto
Posts: 30
Aero is on a distinguished road
Can't get current from PDP, crashes.

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:
Code:
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()
Code:
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
 


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 01:43.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi