Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Python (http://www.chiefdelphi.com/forums/forumdisplay.php?f=187)
-   -   Pneumatics Piston not working in python (http://www.chiefdelphi.com/forums/showthread.php?t=152477)

FRC Fanatic 30-11-2016 20:48

Pneumatics Piston not working in python
 
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.

virtuald 30-11-2016 21:19

Re: Pneumatics Piston not working in python
 
Quote:

Originally Posted by FRC Fanatic (Post 1618540)
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.

FRC Fanatic 30-11-2016 22:10

Re: Pneumatics Piston not working in python
 
Quote:

Originally Posted by virtuald (Post 1618549)
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.

well about the indentation. this is actually a copy paste of the code from a word document. so the indentation would be off. but it is correct in eclipse. aright, i actually forgot about the simulator. thank you!


All times are GMT -5. The time now is 21:40.

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