Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Java (http://www.chiefdelphi.com/forums/forumdisplay.php?f=184)
-   -   new motor (http://www.chiefdelphi.com/forums/showthread.php?t=82909)

Twisted eric 17-02-2010 16:07

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.

MattD 17-02-2010 16:30

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();
        }
    }


Twisted eric 18-02-2010 00:38

Re: new motor
 
got it working thanks


All times are GMT -5. The time now is 09:38.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi