Go to Post Thou Shalt Not Leave Crap In The Walking Path. - Billfred [more]
Home
Go Back   Chief Delphi > Technical > Programming > Python
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 30-11-2016, 20:48
FRC Fanatic's Avatar
FRC Fanatic FRC Fanatic is offline
Registered User
no team
 
Join Date: May 2016
Location: United States
Posts: 7
FRC Fanatic is on a distinguished road
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.
Reply With Quote
  #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,033
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
  #3   Spotlight this post!  
Unread 30-11-2016, 22:10
FRC Fanatic's Avatar
FRC Fanatic FRC Fanatic is offline
Registered User
no team
 
Join Date: May 2016
Location: United States
Posts: 7
FRC Fanatic is on a distinguished road
Re: Pneumatics Piston not working in python

Quote:
Originally Posted by virtuald View Post
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!
Reply With Quote
Reply


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:59.

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