Go to Post *When putting grease on anything* "The bigger the glob the better the job." - TheMagicPenguin [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 20-11-2011, 20:13
whcirobotics's Avatar
whcirobotics whcirobotics is offline
Registered User
FRC #1514 (Vikings)
 
Join Date: Nov 2008
Rookie Year: 2009
Location: WHCI
Posts: 174
whcirobotics is an unknown quantity at this point
Inverting the motors through software

When we ran the java code the motors were inverted so we tried to change its value to negative in software but it would not let us. We know we can just do it physically on the robot, but it is good to learn how to do it through software. We looked online and we came accross this:

public void setInvertedMotor(RobotDrive.MotorType motor, boolean isInverted)

How do we add that in our code to make the motors negative? Here is our code so far that does the basic drive and starts compressor.

CODE:


package edu.wpi.first.wpilibj.templates;


import edu.wpi.first.wpilibj.SimpleRobot;
import edu.wpi.first.wpilibj.RobotDrive;
import edu.wpi.first.wpilibj.Jaguar;
import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.Timer;
import edu.wpi.first.wpilibj.Compressor;
import edu.wpi.first.wpilibj.Solenoid;
import edu.wpi.first.wpilibj.Gyro;
import edu.wpi.first.wpilibj.Victor;
import edu.wpi.first.wpilibj.DigitalInput;


/**
* 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 RobotTemplate extends SimpleRobot {


Joystick leftstick = new Joystick(1);
Joystick rightstick = new Joystick(2);
Jaguar rearleft = new Jaguar(10);
Jaguar rearright = new Jaguar(9);
Jaguar frontleft = new Jaguar(8);
Jaguar frontright = new Jaguar(7);
Victor victor = new Victor(4,5);
Compressor compressor = new Compressor(11,5);


RobotDrive drivetrain = new RobotDrive(frontleft,rearleft,frontright,rearright );

public void robotInit()
{
System.out.println("Initializing robot");
compressor.start();//Start the compressor
}

public void autonomous(){
System.out.println("Entered the autonomous mode");
for(int i = 0; i < 4; i++){
drivetrain.drive(-0.5, 0);
Timer.delay(1.0);
drivetrain.drive(0.0,0.75);

}
drivetrain.drive(0.0,0.0);
}

public void operatorControl(){
System.out.println("Entered the teleop mode");
while(isOperatorControl() && isEnabled()){
drivetrain.arcadeDrive(leftstick, false);

}
}


}
__________________
"A team back in training !"
Reply With Quote
  #2   Spotlight this post!  
Unread 21-11-2011, 08:42
kinganu123 kinganu123 is offline
Registered User
FRC #1747
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2008
Location: Piscataway, NJ
Posts: 243
kinganu123 is on a distinguished road
Re: Inverting the motors through software

use drivetrain.setInvertedMotor()
There are some default parameter is auto enters, so u can just edit that to the motor you need inverted
__________________
Reply With Quote
  #3   Spotlight this post!  
Unread 21-11-2011, 08:57
Jared Russell's Avatar
Jared Russell Jared Russell is online now
Taking a year (mostly) off
FRC #0254 (The Cheesy Poofs), FRC #0341 (Miss Daisy)
Team Role: Engineer
 
Join Date: Nov 2002
Rookie Year: 2001
Location: San Francisco, CA
Posts: 3,078
Jared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond repute
Re: Inverting the motors through software

Right after this line:

Code:
RobotDrive drivetrain = new RobotDrive(frontleft,rearleft,frontright,rearright );
You would add code like this:

Code:
drivetrain.setInvertedMotor(RobotDrive.kFrontLeft, true);
drivetrain.setInvertedMotor(RobotDrive.kRearLeft, true);
(or use kFrontRight and kRearRight...just remember to invert both motors on the side!)
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


All times are GMT -5. The time now is 22:17.

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