Go to Post If you base a team on how well you do on the field you have a much harder time winning. - Bob Steele [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
  #1   Spotlight this post!  
Unread 20-01-2014, 17:02
Wzup4021 Wzup4021 is offline
Registered User
FRC #4021 (igKnightion)
Team Role: Programmer
 
Join Date: Jan 2014
Rookie Year: 2014
Location: United States
Posts: 32
Wzup4021 is an unknown quantity at this point
Can't get motors to spin correct way.

We have successfully gotten our robot wheels (6 wheel tank drive, 2 motors on each side) to spin, however they are going the wrong way. We have tried inserting a negative in many places in our code, we have tried multiplying by -1 and nothing seems to work. With everything we tried, the wheels will still spin the wrong way (they will spin either way, but the joystick/spin is reversed). Here is that part of the code:

public void operatorControl() {
chassis.setSafetyEnabled(true);
while (isOperatorControl() && isEnabled()) {
Joystick1 = leftStick.getAxis(Joystick.AxisType.kY);
Joystick2 = rightStick.getAxis(Joystick.AxisType.kY);

Originally we had this, but changed it to the above:
Joystick1 = leftStick.getY();
Joystick2 = rightStick.getY();


//Left Side Motor Code, controlled by the left joystick(might need to switch direction)
if ((Joystick1 < 0.1)&&(Joystick1 > -0.1)) {
LeftMotors.set(0);
}

else {
LeftMotors.set (Joystick1);
}

//Right Side Motor Code, controlled by the right joystick(might need to switch direction)
if ((Joystick2 < 0.1)&&(Joystick2 > -0.1)) {
RightMotors.set(0);
}

else {
RightMotors.set(Joystick2);
}


}
}
  #2   Spotlight this post!  
Unread 20-01-2014, 17:09
Racer26 Racer26 is offline
Registered User
no team
Team Role: Alumni
 
Join Date: Apr 2003
Rookie Year: 2003
Location: Beaverton, ON
Posts: 2,229
Racer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond repute
Re: Can't get motors to spin correct way.

Personally: I've always found this to be the way to go.

Code:
value = leftStick.getRawAxis(1);
getAxis returns a object of type Axis. getRawAxis returns the value of the axis. Multiply by -1 accordingly.

note that the 1 in my code is the axis number. Usually, joysticks return the "x" axis as axis 0, the "y" axis as axis 1, and additional analog axes (thumb wheels, xbox controller triggers, etc) as 2, 3, 4, etc.
  #3   Spotlight this post!  
Unread 20-01-2014, 17:10
jee7s jee7s is offline
Texan FIRSTer, ex-frc2789, ex-frc41
AKA: Jeffrey Erickson
FRC #6357
 
Join Date: Nov 2007
Rookie Year: 1997
Location: Dripping Springs, TX
Posts: 319
jee7s has a reputation beyond reputejee7s has a reputation beyond reputejee7s has a reputation beyond reputejee7s has a reputation beyond reputejee7s has a reputation beyond reputejee7s has a reputation beyond reputejee7s has a reputation beyond reputejee7s has a reputation beyond reputejee7s has a reputation beyond reputejee7s has a reputation beyond reputejee7s has a reputation beyond repute
Re: Can't get motors to spin correct way.

I think most of us reading that need a bit more context, namely what types all of those variables are and where you tried to make your changes that didn't work.

Particularly:
1. What is the type of LeftMotors and RightMotors?
2. What is the type of Joystick1 and Joystick2?

If LeftMotors and RightMotors are a variant of a speed controller, and Joystick1 and Joystick2 are Joysticks, then code like this would work:

LeftMotors.Set(Joystick1.GetY());
RightMotors.Set(Joystick2.GetY());

And if you needed to reverse the right motors you would replace with this:
LeftMotors.Set(Joystick1.GetY());
RightMotors.Set(-1.0 * Joystick2.GetY());

But, like I said, a bit more context to your question would be helpful.
__________________

2013 Alamo Regional Woodie Flowers Finalist Award Winner
2012 Texas Robot Roundup Volunteer of the Year
Texas Robot Roundup Planning Committee, 2012-present
FRC 6357 Mentor, 2016-
FRC 2789 Mentor, 2009-2016 -- 2 Golds, 2 Silvers, 8 Regional Elimination Appearances

FRC 41 Mentor 2007-2009
FLL Mentor 2006
FRC 619 Mentor 2002
FRC 41 Student 1998-2000
  #4   Spotlight this post!  
Unread 20-01-2014, 17:10
Wzup4021 Wzup4021 is offline
Registered User
FRC #4021 (igKnightion)
Team Role: Programmer
 
Join Date: Jan 2014
Rookie Year: 2014
Location: United States
Posts: 32
Wzup4021 is an unknown quantity at this point
Re: Can't get motors to spin correct way.

So is "value" just a variable in this? And what does the (1) do at the end?
  #5   Spotlight this post!  
Unread 20-01-2014, 17:11
ArchosR4's Avatar
ArchosR4 ArchosR4 is offline
User of the Matrix
FRC #2130 (Alpha+)
Team Role: Programmer
 
Join Date: Jan 2014
Rookie Year: 2010
Location: Bonners Ferry
Posts: 7
ArchosR4 is an unknown quantity at this point
Re: Can't get motors to spin correct way.

Have you tried looking for a generic drive function in your library. Such as tank or arcade drive? If you dont have these functions set one set of motors to a negative out put and leaving the other to a positive. Your function to remove the deadband of the controller looks good. however i would take it out until you get the motors to run in the right direction.
  #6   Spotlight this post!  
Unread 20-01-2014, 17:13
Wzup4021 Wzup4021 is offline
Registered User
FRC #4021 (igKnightion)
Team Role: Programmer
 
Join Date: Jan 2014
Rookie Year: 2014
Location: United States
Posts: 32
Wzup4021 is an unknown quantity at this point
Re: Can't get motors to spin correct way.

I'm not sure if I get your question, but "Leftmotors" means 2 cim motors, controlled by Talons. Right, the opposite. I'm not sure what you mean by joystick type. Basically we have 2 joysticks, one for each side. We have the joysticks matched up to the right side, but getting them to go the right way is what we are having issues with.
  #7   Spotlight this post!  
Unread 20-01-2014, 17:15
Wzup4021 Wzup4021 is offline
Registered User
FRC #4021 (igKnightion)
Team Role: Programmer
 
Join Date: Jan 2014
Rookie Year: 2014
Location: United States
Posts: 32
Wzup4021 is an unknown quantity at this point
Re: Can't get motors to spin correct way.

We used the tank drive template. We have tried inserting negatives everywhere we can think of (one at a time ofc) and also tried multiplying by -1. They still spin the same way regardless. Also, why should we remove the deadpan code, any reason?
  #8   Spotlight this post!  
Unread 20-01-2014, 17:19
jee7s jee7s is offline
Texan FIRSTer, ex-frc2789, ex-frc41
AKA: Jeffrey Erickson
FRC #6357
 
Join Date: Nov 2007
Rookie Year: 1997
Location: Dripping Springs, TX
Posts: 319
jee7s has a reputation beyond reputejee7s has a reputation beyond reputejee7s has a reputation beyond reputejee7s has a reputation beyond reputejee7s has a reputation beyond reputejee7s has a reputation beyond reputejee7s has a reputation beyond reputejee7s has a reputation beyond reputejee7s has a reputation beyond reputejee7s has a reputation beyond reputejee7s has a reputation beyond repute
Re: Can't get motors to spin correct way.

Quote:
Originally Posted by Wzup4021 View Post
We used the tank drive template. We have tried inserting negatives everywhere we can think of (one at a time ofc) and also tried multiplying by -1. They still spin the same way regardless. Also, why should we remove the deadpan code, any reason?
At this point, remove the deadband code to simplify your debugging.

Regarding the type, somewhere in your code you should have a block of declarations that look like this:

Joystick Joystick1;
Joystick Joystick2;
Jaguar LeftMotors;
Jaguar RightMotors;

...Or some such thing. Can you show us the declarations of those objects? Or, post your code so we can get a better picture.
__________________

2013 Alamo Regional Woodie Flowers Finalist Award Winner
2012 Texas Robot Roundup Volunteer of the Year
Texas Robot Roundup Planning Committee, 2012-present
FRC 6357 Mentor, 2016-
FRC 2789 Mentor, 2009-2016 -- 2 Golds, 2 Silvers, 8 Regional Elimination Appearances

FRC 41 Mentor 2007-2009
FLL Mentor 2006
FRC 619 Mentor 2002
FRC 41 Student 1998-2000
  #9   Spotlight this post!  
Unread 20-01-2014, 17:20
Racer26 Racer26 is offline
Registered User
no team
Team Role: Alumni
 
Join Date: Apr 2003
Rookie Year: 2003
Location: Beaverton, ON
Posts: 2,229
Racer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond repute
Re: Can't get motors to spin correct way.

Does this not work?

Code:
class Robot() extends SimpleRobot{
RobotDrive myRobot = new RobotDrive(1,2,3,4);
Joystick leftStick = new Joystick(1);
Joystick rightStick = new Joystick(2);
...
public void OperatorControl(){
while( isOperatorControl() && isEnabled() ){
myRobot.TankDrive(leftStick,rightStick);
}
}

}
  #10   Spotlight this post!  
Unread 20-01-2014, 17:21
Wzup4021 Wzup4021 is offline
Registered User
FRC #4021 (igKnightion)
Team Role: Programmer
 
Join Date: Jan 2014
Rookie Year: 2014
Location: United States
Posts: 32
Wzup4021 is an unknown quantity at this point
Re: Can't get motors to spin correct way.

obotDrive chassis = new RobotDrive(1, 2);
private final Joystick leftStick = new Joystick(1);
private final Joystick rightStick = new Joystick(2);
Talon LeftMotors = new Talon(1);
Talon RightMotors = new Talon(2);
private double Joystick1;
private double Joystick2;
  #11   Spotlight this post!  
Unread 20-01-2014, 17:24
Racer26 Racer26 is offline
Registered User
no team
Team Role: Alumni
 
Join Date: Apr 2003
Rookie Year: 2003
Location: Beaverton, ON
Posts: 2,229
Racer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond repute
Re: Can't get motors to spin correct way.

Quote:
Originally Posted by Wzup4021 View Post
obotDrive chassis = new RobotDrive(1, 2);
private final Joystick leftStick = new Joystick(1);
private final Joystick rightStick = new Joystick(2);
Talon LeftMotors = new Talon(1);
Talon RightMotors = new Talon(2);
private double Joystick1;
private double Joystick2;
Yes, so simply putting:

Code:
chassis.TankDrive(leftStick,rightStick);
in your OperatorControl() function ought to take care of it. If motors spin the wrong direction at that point, flip the wires at the speed controller output.
  #12   Spotlight this post!  
Unread 20-01-2014, 17:24
jee7s jee7s is offline
Texan FIRSTer, ex-frc2789, ex-frc41
AKA: Jeffrey Erickson
FRC #6357
 
Join Date: Nov 2007
Rookie Year: 1997
Location: Dripping Springs, TX
Posts: 319
jee7s has a reputation beyond reputejee7s has a reputation beyond reputejee7s has a reputation beyond reputejee7s has a reputation beyond reputejee7s has a reputation beyond reputejee7s has a reputation beyond reputejee7s has a reputation beyond reputejee7s has a reputation beyond reputejee7s has a reputation beyond reputejee7s has a reputation beyond reputejee7s has a reputation beyond repute
Re: Can't get motors to spin correct way.

Quote:
Originally Posted by Wzup4021 View Post
obotDrive chassis = new RobotDrive(1, 2);
private final Joystick leftStick = new Joystick(1);
private final Joystick rightStick = new Joystick(2);
Talon LeftMotors = new Talon(1);
Talon RightMotors = new Talon(2);
private double Joystick1;
private double Joystick2;
Ah, now that looks like you are stepping on your own code. Does the RobotDrive class declare and instantiate the joysticks and talons? If it does, then you are trying to set values from two different places. That might be causing your complication.

From the other poster's comment, I think all you need is that first line where you instantiate a new RobotDrive.
__________________

2013 Alamo Regional Woodie Flowers Finalist Award Winner
2012 Texas Robot Roundup Volunteer of the Year
Texas Robot Roundup Planning Committee, 2012-present
FRC 6357 Mentor, 2016-
FRC 2789 Mentor, 2009-2016 -- 2 Golds, 2 Silvers, 8 Regional Elimination Appearances

FRC 41 Mentor 2007-2009
FLL Mentor 2006
FRC 619 Mentor 2002
FRC 41 Student 1998-2000
  #13   Spotlight this post!  
Unread 20-01-2014, 17:27
Racer26 Racer26 is offline
Registered User
no team
Team Role: Alumni
 
Join Date: Apr 2003
Rookie Year: 2003
Location: Beaverton, ON
Posts: 2,229
Racer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond repute
Re: Can't get motors to spin correct way.

Quote:
Originally Posted by jee7s View Post
Ah, now that looks like you are stepping on your own code. Does the RobotDrive class declare and instantiate the joysticks and talons? If it does, then you are trying to set values from two different places. That might be causing your complication.

From the other poster's comment, I think all you need is that first line where you instantiate a new RobotDrive.
First 3. RobotDrive instantiates the motors on its own but does not instantiate the Joysticks. (though stop to think of it, I'm not sure what it instantiates them as... Talon, Jaguar, and Victor all extend the SpeedController class...)

EDIT: Looking at the WPIlib reference, they're instantiated as Victors. you can also pass SpeedController objects to the RobotDrive constructor if you want something other than Victors.

In this case, they could go:

Code:
Talon leftDrive = new Talon(1);
Talon rightDrive = new Talon(2);
RobotDrive chassis = new RobotDrive(leftDrive, rightDrive);

Last edited by Racer26 : 20-01-2014 at 17:30.
  #14   Spotlight this post!  
Unread 20-01-2014, 17:30
Wzup4021 Wzup4021 is offline
Registered User
FRC #4021 (igKnightion)
Team Role: Programmer
 
Join Date: Jan 2014
Rookie Year: 2014
Location: United States
Posts: 32
Wzup4021 is an unknown quantity at this point
Re: Can't get motors to spin correct way.

While I see what you're saying, I don't think that's the issue. We can control the speed and on/off of the motors fine, and the direction. Forward on the joystick is moving the wheels backwards, and backwards on the JS is moving the wheels forwards.
  #15   Spotlight this post!  
Unread 20-01-2014, 17:31
Matt C's Avatar
Matt C Matt C is offline
Registered User
FRC #1468 (J-Birds)
Team Role: Engineer
 
Join Date: Mar 2006
Rookie Year: 1999
Location: Islip Terrace, NY
Posts: 396
Matt C has a reputation beyond reputeMatt C has a reputation beyond reputeMatt C has a reputation beyond reputeMatt C has a reputation beyond reputeMatt C has a reputation beyond reputeMatt C has a reputation beyond reputeMatt C has a reputation beyond reputeMatt C has a reputation beyond reputeMatt C has a reputation beyond reputeMatt C has a reputation beyond reputeMatt C has a reputation beyond repute
Send a message via AIM to Matt C
Re: Can't get motors to spin correct way.

Have you verified the wiring?
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


All times are GMT -5. The time now is 02:47.

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