Go to Post Our robot name is currently "Subject to Change". - JesseK [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

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #16   Spotlight this post!  
Unread 05-03-2010, 16:04
furiousgeorge's Avatar
furiousgeorge furiousgeorge is offline
Registered User
FRC #3055
 
Join Date: Jan 2009
Location: Austin
Posts: 74
furiousgeorge will become famous soon enoughfuriousgeorge will become famous soon enough
Re: Strafe using Joystick Buttons

Quote:
Originally Posted by Robototes2412 View Post
we have a method in java we could give to you if you want
We've never used java before, but if you're willing to help us out I'd be glad to give it a try.
  #17   Spotlight this post!  
Unread 05-03-2010, 19:03
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: Strafe using Joystick Buttons

we used this code for strafing and moving, turning is its own can of worms.

Code:
public class WesleyCrusher {
    private Victor FRvictor = new Victor(2);  //right motor
    private Victor FLvictor = new Victor(1);   //left motor
    private Victor RRvictor = new Victor(4);  //right motor
    private Victor RLvictor = new Victor(3);   //left motor
    private Jaguar ballSucker = new Jaguar(7); //ball sucker
    
    boolean DEBUG = true;

    void checkingDrive(double magnitude, double rotation) { //DONT TOUCH THIS
        magnitude = limit(magnitude);  //1 is highest, so make n > 1, 1
        rotation  = limit(rotation);

        double frontLeftSpeed, rearLeftSpeed, frontRightSpeed, rearRightSpeed;  //temporary motor speed values

        frontLeftSpeed = ((magnitude - rotation));  //calculate speed values
        frontRightSpeed = ((magnitude + rotation));
        rearLeftSpeed = ((magnitude + rotation));
        rearRightSpeed = ((magnitude - rotation));

        if(DEBUG) {
        double maxMotor = Math.max(
            Math.max(Math.abs(frontLeftSpeed), Math.abs(frontRightSpeed)),
            Math.max(Math.abs(rearLeftSpeed), Math.abs(rearRightSpeed))
        );

        if (maxMotor > 1){
            frontRightSpeed = frontRightSpeed / maxMotor;
            rearRightSpeed = rearRightSpeed / maxMotor;
            frontLeftSpeed = frontLeftSpeed / maxMotor;
            rearLeftSpeed = rearLeftSpeed / maxMotor;
        }
        }

        frontLeftSpeed = limit(fiddleWithSpeed(frontLeftSpeed));
        frontRightSpeed = limit(fiddleWithSpeed(frontRightSpeed));
        rearLeftSpeed = limit(fiddleWithSpeed(rearLeftSpeed));
        rearRightSpeed = limit(fiddleWithSpeed(rearRightSpeed));

        if(magnitude != 0 || rotation !=0) {
            System.out.println("#############################################");
            System.out.println("Mangnitude: " + magnitude + "  Rotation: " + rotation);  //debugOut
            System.out.println("FLSpeed: " + frontLeftSpeed + "  FRSpeed: " + frontRightSpeed);
            System.out.println("RLSpeed: " + rearLeftSpeed + "  RRSpeed: " + rearRightSpeed);
        }

        FLvictor.set(-frontLeftSpeed);  //set the speeds on the motors
        FRvictor.set(frontRightSpeed);
        RLvictor.set(-rearLeftSpeed);
        RRvictor.set(rearRightSpeed);
    } //void checkingDrive

    void turn(double power) {
        if(Math.abs(power) > 0) {
            RRvictor.set(power);
            RLvictor.set(power);
        }
    }

    double limit(double num) {
        if (num > 1.0) {
            return 1.0;
        }
        if (num < -1.0) {
            return -1.0;
        }
        return num;
    }
    void ballSuckerOn() {
        ballSucker.set(0.75);
    }

    void ballSuckerOff() {
        ballSucker.set(0);
    }
}
Yes, i name all my code classes after bridge crew of the Enterprise-D
Closed Thread


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
Buttons on Joystick helenajoy NI LabVIEW 15 17-02-2010 22:26
Using the same Jaguar/Controller for Joystick and buttons.... mck567 NI LabVIEW 2 09-02-2010 16:34
Joystick buttons Team_2547 NI LabVIEW 1 24-01-2009 19:42
Using auxiliary joystick buttons with IFI controller. Eric W. Jones Programming 9 03-12-2006 22:26
Using the extra buttons on the joystick. Code\\Pilot Programming 7 04-12-2004 19:30


All times are GMT -5. The time now is 03:44.

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