Quote:
Originally Posted by FRC Fanatic
Hello, so i'm trying to understand how to program pneumatics in python in the off-season. I've read the Robotpy documentation and the Pacgoat pneumatic documentation on github and i want to make sure that the issue is not code side, because the kFoward is functional but not the kReverse
here is a quick rundown of the pneumatic setup
double solenoid on Vex Manifold is running to 1 piston which we just want to control.
here is the code as follows
Code:
#!/usr/mybin/env python3
import math
import wpilib
from RobotMap import RobotMap
from networktables import NetworkTable
from wpilib.doublesolenoid import DoubleSolenoid
class MyRobot(wpilib.IterativeRobot):
def robotInit(self):
self.xb = wpilib.Joystick(2)
self.Compressor = wpilib.Compressor(0)
self.Compressor.setClosedLoopControl(True)
self.enabled = self.Compressor.enabled()
self.PSV = self.Compressor.getPressureSwitchValue()
self.DS = wpilib.DoubleSolenoid(1,2)
self.Compressor.start()
def teleopPeriodic(self):
elif(self.xb.getRawButton(2)):
self.DS.set(DoubleSolenoid.Value.kForward)
elif(self.xb.getRawButton(4)):
self.DS.set(DoubleSolenoid.Value.kReverse)
is there any glaring issues? i'm new to pneumatic programming and any assistance would be great, thank you.
|
There are a few syntax/import issues with your code, and your teleopPeriodic function is at the wrong indentation level so it will never be called. However, the individual lines of code that set the solenoid values seem correct.
Have you tried running the code using the pyfrc simulator? That will allow you to easily test the code and see the output of any error messages. It will show solenoids turning on/off.