Go to Post The propagation of the idea of making FIRST into a perfectly fair competition is just silly. - Andy Baker [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 26-01-2013, 12:34
joelg236 joelg236 is offline
4334 Retired Mentor & Alumni
AKA: Joel Gallant
no team
Team Role: Mentor
 
Join Date: Dec 2011
Rookie Year: 2012
Location: Calgary
Posts: 733
joelg236 has a reputation beyond reputejoelg236 has a reputation beyond reputejoelg236 has a reputation beyond reputejoelg236 has a reputation beyond reputejoelg236 has a reputation beyond reputejoelg236 has a reputation beyond reputejoelg236 has a reputation beyond reputejoelg236 has a reputation beyond reputejoelg236 has a reputation beyond reputejoelg236 has a reputation beyond reputejoelg236 has a reputation beyond repute
Sneak Peak at ATAlibj

Hey guys,

Just thought I'd give you a sneak peak at what production code will look like with the API we on team 4334 are working on. We will release it this summer, so be on the lookout!

Code:
public class Drivetrain extends Subsystem {

    private final RobotDriveModule driveModule;
    private final XboxController controller;
    private final SpikeRelayModule compressor;
    private final SolenoidModule left1, left2, right1, right2;

    public Drivetrain(RobotDriveModule driveModule, XboxController controller,
            SpikeRelayModule compressor, SolenoidModule left1, SolenoidModule left2,
            SolenoidModule right1, SolenoidModule right2) {
        super(new Module[]{driveModule, controller, compressor, left1, left2, right1, right2});
        this.driveModule = driveModule;
        this.controller = controller;
        this.compressor = compressor;
        this.left1 = left1;
        this.left2 = left2;
        this.right1 = right1;
        this.right2 = right2;
        init();
    }

    private void init() {
        controller.bindAxis(XboxController.RIGHT_FROM_MIDDLE, new SideBinding(driveModule, SideBinding.RIGHT));
        controller.bindAxis(XboxController.LEFT_FROM_MIDDLE, new SideBinding(driveModule, SideBinding.LEFT));
        controller.bindWhenPressed(XboxController.RIGHT_BUMPER, new Command() {
            public void run() {
                if(left1.get() && right1.get()) {
                    left1.set(false);
                    left2.set(true);
                    right1.set(false);
                    right2.set(true);
                } else {
                    left1.set(true);
                    left2.set(false);
                    right1.set(true);
                    right2.set(false);
                }
            }
        });
    }
    
    public void teleop() {
        compressor.set(SpikeRelay.FORWARD);
        controller.doBinds();
    }
}
If you didn't catch on, there is joystick bindings, modules, subsystems and custom wrapper classes for a lot of the wpilibj classes. This code controls a supershifter gear shifting robot. Notice that to control the drivetrain, final code is 2 lines long.
__________________
All opinions are my own.
Reply With Quote
  #2   Spotlight this post!  
Unread 30-01-2013, 16:47
apples000's Avatar
apples000 apples000 is offline
Registered User
no team
 
Join Date: Mar 2012
Rookie Year: 2012
Location: United States
Posts: 222
apples000 has a brilliant futureapples000 has a brilliant futureapples000 has a brilliant futureapples000 has a brilliant futureapples000 has a brilliant futureapples000 has a brilliant futureapples000 has a brilliant futureapples000 has a brilliant futureapples000 has a brilliant futureapples000 has a brilliant futureapples000 has a brilliant future
Re: Sneak Peak at ATAlibj

That's pretty cool. Also, it seems organized which is a huge advantage.
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 10:03.

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