Go to Post Volunteer...it will make you see a totally different side of FIRST. - Collin Fultz [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-17-2010, 04:07 PM
Twisted eric's Avatar
Twisted eric Twisted eric is offline
Registered User
FRC #0581
 
Join Date: Jan 2010
Location: San Jose
Posts: 54
Twisted eric is an unknown quantity at this point
new motor

Code:
package edu.wpi.first.wpilibj.templates;

import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.RobotDrive;
import edu.wpi.first.wpilibj.SimpleRobot;
import edu.wpi.first.wpilibj.Timer;
import edu.wpi.first.wpilibj.Watchdog;
import edu.wpi.first.wpilibj.Compressor;
import edu.wpi.first.wpilibj.Relay;

public class Demonized extends SimpleRobot {

    private static final long TIME_DELAY = 1000; // in milliseconds
    RobotDrive drive = new RobotDrive(1, 2);
    RobotDrive spot = new RobotDrive(3);
    Joystick leftStick = new Joystick(1);
    Joystick rightStick = new Joystick(2);
    Joystick kicker = new Joystick(3);
    Watchdog fenrir = Watchdog.getInstance();
    Compressor fluffy = new Compressor(1, 1);

    

    void setUpRobot() {
        fluffy.start();
        fenrir.feed(); 
    }

    public void autonomous() {
        setUpRobot();
        try {
            while (true && isAutonomous() && isEnabled()) {
                for (int i = 0; i < 4; i++) {
                    fenrir.feed();
                    Thread.sleep(TIME_DELAY);
                    drive.drive(0.5, 0.0);  // drive 50% fwd 0% turn
                    Thread.sleep(TIME_DELAY);
                    fenrir.feed();
                    Thread.sleep(TIME_DELAY);
                    drive.drive(0.0, 0.5);  // drive 0% fwd 50% turn
                    fenrir.feed();
                    Thread.sleep(TIME_DELAY);
                    drive.drive(0.0, -0.5); // drive 0% fwd -50% turn
                }
            }

            drive.drive(0.0, 0.0);  // drive 0% fwd, 0% turn
        } catch (InterruptedException ie) {
            // aaaaaaah, how do we log this out?
            // but make sure we stop
            drive.drive(0.0, 0.0); // drive 0% fwd, 0% turn
        }
    }

    public void operatorControl() {
        setUpRobot();
        while (true && isOperatorControl() && isEnabled()) // loop until change
        {
            drive.tankDrive(leftStick, rightStick);
            Timer.delay(0.005);
            fenrir.feed();
            drive.arcadeDrive(kicker);
        }
    }
}
it does not like the second RobotDrive spot for some reasons.

any help.

Last edited by Twisted eric : 02-17-2010 at 04:08 PM. Reason: fix
Reply With Quote
  #2   Spotlight this post!  
Unread 02-17-2010, 04:30 PM
MattD's Avatar
MattD MattD is offline
Registered User
AKA: Matthew Douglas
FRC #0228 (GUS Robotics)
Team Role: Alumni
 
Join Date: Feb 2006
Rookie Year: 2005
Location: Indianapolis, IN
Posts: 185
MattD is a splendid one to beholdMattD is a splendid one to beholdMattD is a splendid one to beholdMattD is a splendid one to beholdMattD is a splendid one to beholdMattD is a splendid one to beholdMattD is a splendid one to behold
Send a message via AIM to MattD
Re: new motor

I'm imagining that this doesn't compile, since there isn't a RobotDrive constructor that takes only one int parameter. Also, in operatorControl() you're setting the drive motors based on input from two joysticks, and then setting them again based on input from a third joystick. This isn't going to produce a desirable result.

If you want to control a single motor with a joystick, use the appropriate SpeedController class -- Jaguar or Victor. RobotDrive is intended for use with drive trains that have two or four motor configurations.

Code:
Jaguar spot = new Jaguar(3);

...

    public void operatorControl() {
        setUpRobot();
        while (true && isOperatorControl() && isEnabled()) // loop until change
        {
            drive.tankDrive(leftStick, rightStick);
            spot.set(kicker.getY());
            Timer.delay(0.005);
            fenrir.feed();
        }
    }
__________________
GUS Robotics Team 228

2010 WPI Engineering Inspiration Award
2010 WPI Regional Champions (Thanks 230 & 20!)
2010 CT VEX Champions
2010 CT VEX Innovate Award
2009 QCC VEX Champions
2009 CT Motorola Quality Award
2007 CT J&J Sportsmanship Award
2006 CT Best Website Award
Reply With Quote
  #3   Spotlight this post!  
Unread 02-18-2010, 12:38 AM
Twisted eric's Avatar
Twisted eric Twisted eric is offline
Registered User
FRC #0581
 
Join Date: Jan 2010
Location: San Jose
Posts: 54
Twisted eric is an unknown quantity at this point
Re: new motor

got it working thanks
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

Similar Threads
Thread Thread Starter Forum Replies Last Post
New FP motor at event Pat Major Motors 1 02-14-2005 04:57 PM
New Drill Motor Mounts MattB703 Motors 1 01-08-2003 09:46 PM
New Drill Motor Mounts MattB703 Technical Discussion 0 01-06-2003 09:31 AM
New Fisher Price Motor - IMPORTANT Paul Copioli Motors 6 02-08-2002 01:35 PM
What's with the New Motor Specs for the Atwood Mobile (Chiaphua) Motor. Robb Gerber Motors 2 01-23-2002 08:58 AM


All times are GMT -5. The time now is 07:34 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