View Single Post
  #2   Spotlight this post!  
Unread 30-11-2016, 21:19
virtuald's Avatar
virtuald virtuald is offline
RobotPy Guy
AKA: Dustin Spicuzza
FRC #1418 (), FRC #1973, FRC #4796, FRC #6367 ()
Team Role: Mentor
 
Join Date: Dec 2008
Rookie Year: 2003
Location: Boston, MA
Posts: 1,043
virtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant future
Re: Pneumatics Piston not working in python

Quote:
Originally Posted by FRC Fanatic View Post
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.
__________________
Maintainer of RobotPy - Python for FRC
Creator of pyfrc (Robot Simulator + utilities for Python) and pynetworktables/pynetworktables2js (NetworkTables for Python & Javascript)

2017 Season: Teams #1973, #4796, #6369
Team #1418 (remote mentor): Newton Quarterfinalists, 2016 Chesapeake District Champion, 2x Innovation in Control award, 2x district event winner
Team #1418: 2015 DC Regional Innovation In Control Award, #2 seed; 2014 VA Industrial Design Award; 2014 Finalists in DC & VA
Team #2423: 2012 & 2013 Boston Regional Innovation in Control Award


Resources: FIRSTWiki (relaunched!) | My Software Stuff
Reply With Quote