Go to Post If you water it and nurture it and fertilize it and put it out in the sunlight, it might just grow up to be a big lathe... :) - dlavery [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rating: Thread Rating: 5 votes, 5.00 average. Display Modes
Prev Previous Post   Next Post Next
  #1   Spotlight this post!  
Unread 28-01-2014, 19:17
FriendzonedJim's Avatar
FriendzonedJim FriendzonedJim is offline
Registered User
FRC #3749
Team Role: Programmer
 
Join Date: Jan 2014
Rookie Year: 2014
Location: The North
Posts: 2
FriendzonedJim is an unknown quantity at this point
May I Please Have Some Help?

Hey guys, I am a part of this club in my school, and we are taking place in the 2014 robotics competition. We can not test our code yet because we are waiting on our build team to finalize a design. However, we have some code written and were wondering if it would work in theory.

Thank you all so much,
FriendzonedJim


Code:
/*----------------------------------------------------------------------------*/
/* Copyright (c) FIRST 2008. All Rights Reserved.                             */
/* Open Source Software - may be modified and shared by FRC teams. The code   */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project.                                                               */
/*----------------------------------------------------------------------------*/

package edu.wpi.first.wpilibj.templates;


import edu.wpi.first.wpilibj.Encoder;
import edu.wpi.first.wpilibj.IterativeRobot;
import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.Relay;
import edu.wpi.first.wpilibj.RobotDrive;
import edu.wpi.first.wpilibj.Talon;
import edu.wpi.first.wpilibj.Timer;

/**
 * The VM is configured to automatically run this class, and to call the
 * functions corresponding to each mode, as described in the IterativeRobot
 * documentation. If you change the name of this class or the package after
 * creating this project, you must also update the manifest file in the resource
 * directory.
 */
public class mainClass extends IterativeRobot {
    /**
     * This function is run when the robot is first started up and should be
     * used for any initialization code.
     */
    double angle = 41.6;
    boolean ifLightButtonPushed = false;
    Joystick driveStick = new Joystick(1);
    Joystick controlStick = new Joystick(2);
    
    RobotDrive mainDrive = new RobotDrive(1,2,3,4);
    
    Talon pickupTalon = new Talon(3);
    Talon launchTalon = new Talon(4);
    
    Relay ledRing = new Relay(1);
    Encoder pickupEncoder = new Encoder(1,2);
    Encoder elasticEncoder = new Encoder(3,4);
    public void robotInit() {
        pickupEncoder.start();
    }

    /**
     * This function is called periodically during autonomous
     */
    public void autonomousPeriodic() {

    }
    public void autonomousContinuous() {
        mainDrive.setSafetyEnabled(false);
        mainDrive.drive(0.5,0.0);
        Timer.delay(2.0);
        mainDrive.drive(0.0,0.0);
    }
    /**
     * This function is called periodically during operator control
     */
    public void teleopPeriodic() {
        
        mainDrive.arcadeDrive(driveStick);
        if (controlStick.getRawButton(3)) {
            if (pickupEncoder.get() < angle) {
                pickupTalon.set(.5);
             } else {
                pickupTalon.set(0.0);
            }
        } else {
            pickupTalon.set(0.0);
          }
        if (controlStick.getRawButton(1)) {
            launchTalon.set(0.5);
        } else {
            launchTalon.set(0.0);
        }
        if (controlStick.getRawButton(4)) {
            ifLightButtonPushed = !(ifLightButtonPushed);
        }
        if (ifLightButtonPushed) {
            
            ledRing.set(Relay.Value.kOff);
        }
    }
        
    
    /**
     * This function is called periodically during test mode
     */
    public void testPeriodic() {
    
    }
    
}
 


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

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