Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Java (http://www.chiefdelphi.com/forums/forumdisplay.php?f=184)
-   -   Drive Issue (http://www.chiefdelphi.com/forums/showthread.php?t=112886)

Mr.Roboto3335 06-02-2013 12:51

Drive Issue
 
Our motors are backwards and my team does not want to reverse the wiring. How do I reverse the motors with Java?

notmattlythgoe 06-02-2013 12:57

Re: Drive Issue
 
Quote:

Originally Posted by Mr.Roboto3335 (Post 1228782)
Our motors are backwards and my team does not want to reverse the wiring. How do I reverse the motors with Java?

An easy way to do it is just put in the opposite power level. So if you want 0.5 power put in -0.5 instead.

Quote:

public void drive(double leftPower, double rightPower) {
robotDrive.tankDrive(-leftPower, -rightPower);
}

inkspell4 06-02-2013 12:57

You make one of the joystick values negative.

For further help we would need your code

Mark McLeod 06-02-2013 12:59

Re: Drive Issue
 
*-1

or I think this is still valid from last year?

drive.setInvertedMotor(RobotDrive.kFrontLeft, true);
drive.setInvertedMotor(RobotDrive.kRearLeft, true);

Mr.Roboto3335 06-02-2013 13:00

Re: Drive Issue
 
This is it so far.

/*----------------------------------------------------------------------------*/
/* 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.Joystick;
import edu.wpi.first.wpilibj.RobotDrive;
import edu.wpi.first.wpilibj.SimpleRobot;
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 SimpleRobot
* 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 TheReaper extends SimpleRobot {
RobotDrive drive = new RobotDrive(1, 2);
Joystick leftStick = new Joystick(1);
Joystick rightStick = new Joystick(2);

/**
* This function is called once each time the robot enters autonomous mode.
*/
public void autonomous() {

}

/**
* This function is called once each time the robot enters operator control.
*/
public void operatorControl() {
while (isOperatorControl() && isEnabled()){

drive.tankDrive(leftStick, rightStick);
Timer.delay(0.01);
}

}

/**
* This function is called once each time the robot enters test mode.
*/
public void test() {

}
}

notmattlythgoe 06-02-2013 13:03

Re: Drive Issue
 
Quote:

drive.tankDrive(leftStick, rightStick);
Change that to:

Quote:

drive.tankDrive(-leftStick, -rightStick);
Now to confirm that I'm understanding, both sets of motors are spinning backwards, so the robot moves backwards. Or one set spins forward and one spins back?

Mr.Roboto3335 06-02-2013 13:04

Re: Drive Issue
 
Quote:

Originally Posted by notmattlythgoe (Post 1228792)
Change that to:

It gives me an error when I try that.
Both are backwards.

notmattlythgoe 06-02-2013 13:06

Re: Drive Issue
 
Quote:

Originally Posted by Mr.Roboto3335 (Post 1228795)
It gives me an error when I try that.

Try
Quote:

drive.tankDrive(-leftStick.getY(), -rightStick.getY());

Mr.Roboto3335 06-02-2013 13:12

Re: Drive Issue
 
Both are working now. Thank you very much!

notmattlythgoe 06-02-2013 13:17

Re: Drive Issue
 
Quote:

Originally Posted by Mr.Roboto3335 (Post 1228806)
Moving in the right direction now but the right side is not moving.

No problem, just so you have an understand of what you just did. The .getY() method returns the value of the joysticks Y axis(forwards and backwards). The - inverts whatever value that it is attached to.


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

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