Go to Post Well I guess that's better than some teams idea of team bonding which would be taping a wayward freshman to the wall with duct tape. - Koko Ed [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
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 02-15-2011, 07:25 PM
MisterL's Avatar
MisterL MisterL is offline
Robot C Master and Mentor
AKA: Derrick Canfield
FRC #1544 (One Byte Short)
Team Role: Mentor
 
Join Date: Feb 2011
Rookie Year: 2006
Location: Alaska
Posts: 30
MisterL is an unknown quantity at this point
Question Java Pneumatics

I was told this year I have to program our compressor and Solenoid for our robotic arm. I only programmed ROBOTC for FTC before. We have nobody experienced in Java and while we have a drive program I can't for the life of me find out how to program pneumatics. Can anybody help me out even if its a little?

(This is my first post, sorry if its done wrong)
__________________
"Doing Java from scratch with no previous experience with it? Piece of cake!" Famous Last Words
One Byte Short Mentor
Reply With Quote
  #2   Spotlight this post!  
Unread 02-15-2011, 09:11 PM
Patrickwhite's Avatar
Patrickwhite Patrickwhite is offline
May the North be with you
FRC #0610 (The Coyotes)
Team Role: Programmer
 
Join Date: Dec 2008
Rookie Year: 2008
Location: Toronto
Posts: 88
Patrickwhite is a glorious beacon of lightPatrickwhite is a glorious beacon of lightPatrickwhite is a glorious beacon of lightPatrickwhite is a glorious beacon of lightPatrickwhite is a glorious beacon of lightPatrickwhite is a glorious beacon of light
Re: Java Pneumatics

For the Solenoids, the first thing to do is to create the Solenoid object. The constructor follows the general WPI format, with options to create it based on slot (of the Solenoid module) and channel, or just by channel.
Code:
Solenoid armSol = new Solenoid(7,4); //creates a Solenoid object in slot 7, channel 4.
After that, there are only two functions to concern yourself with: get(), which returns the current state of the Solenoid (true or false), and set(boolean on), which sets the state of the Solenoid.
Code:
armSol.set(true); //turns the Solenoid on
The compressor can take up to four parameters, because it has two 'things' to set: the location of the pressure switch (what reads the pressure and tells the robot when it's 'full'), and the location of the relay (what turns the compressor on or off). After that, start() the compressor object and it should automatically regulate itself, turning off when the pressure is high enough, then restarting when it drops. You can get the value of the pressure switch and the state of the compressor with getPressureSwitchValue() and enabled(), respectively, but for safety reasons you cannot control the actual state of the compressor manually.
Code:
Compressor aCompressor = new Compressor(1,1); //create a compressor with the default slots and relay and pressure switch channels 1 and 1.
aCompressor.start(); //start the compressor.
__________________
while(!going.isTough());
tough.exit();

What will we do tonight, Warfa?
The same thing we do every night, Patrick. Sit and wait for Electrical.

Last edited by Patrickwhite : 02-15-2011 at 09:20 PM. Reason: I may or may not have completely forgotten the compressor.
Reply With Quote
  #3   Spotlight this post!  
Unread 02-16-2011, 11:29 AM
Robototes2412's Avatar
Robototes2412 Robototes2412 is offline
1 * 4 != 14
FRC #2412 (Robototes)
Team Role: Programmer
 
Join Date: Jan 2010
Rookie Year: 2007
Location: Bellevue
Posts: 312
Robototes2412 is on a distinguished road
Re: Java Pneumatics

My double and single solenoid class
Code:
package com.shadowh511.mayor.outputs;

import edu.wpi.first.wpilibj.Solenoid;

/**
 *
 * @author sam
 */
public class MySolenoid {
    private Solenoid foo;
    private Solenoid bar;

    private boolean doublek = false;

    /*
     * For a one-solenoid system
     */
    public MySolenoid(int port) {
        foo = new Solenoid(8, port);
        doublek = false;
        System.out.println("MySolenoid enabled on port " + port);
    }

    /*
     * For a double solenoid system
     */
    public MySolenoid(int port1, int port2) {
        doublek = true;
        foo = new Solenoid(8, port1);
        bar = new Solenoid(8, port2);
        System.out.println("Double MySolenoid enabled on ports " + port1 + " and " + port2);
    }

    /*
     * For a double solenoid system, custom slot
     */
    public MySolenoid(int slot, int port1, int port2) {
        doublek = true;
        foo = new Solenoid(slot, port1);
        bar = new Solenoid(slot, port2);
        System.out.println("Double MySolenoid enabled on slot " + slot + " and ports " + port1 + " and " + port2);
    }

    /*
     * Extends the solenoid
     */
    public void extend() {
        foo.set(true);

        if(doublek) {
            bar.set(false);
        }
    }

    /*
     * Retracts the solenoid
     */
    public void retract() {
        foo.set(false);

        if(doublek) {
            bar.set(true);
        }
    }

    /*
     * Gets the state of the first solenoid
     */
    public boolean get() {
        return this.foo.get();
    }

    /*
     * Gets the state of the other solenoid
     */
    public boolean getOther() {
        boolean eggs = bar.get();
        return eggs;
    }
}
__________________
Code:
class team2412(GP):
    def __init__(self):
        GP.__init__(self)
        self.coopertition = True
        self.info = {"name": "Robototes", "school": "Sammamish High School, Bellevue, WA"}
        assert self.kind_people == True
Reply With Quote
  #4   Spotlight this post!  
Unread 02-16-2011, 06:11 PM
MisterL's Avatar
MisterL MisterL is offline
Robot C Master and Mentor
AKA: Derrick Canfield
FRC #1544 (One Byte Short)
Team Role: Mentor
 
Join Date: Feb 2011
Rookie Year: 2006
Location: Alaska
Posts: 30
MisterL is an unknown quantity at this point
Re: Java Pneumatics

Thank you! Those both were very helpful!!!!
__________________
"Doing Java from scratch with no previous experience with it? Piece of cake!" Famous Last Words
One Byte Short Mentor
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 08:12 AM.

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