Go to Post Off season? More like on season, our season is always on. - joeweber [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 22-01-2015, 03:52
CavbotRyche CavbotRyche is offline
Registered User
FRC #5020
 
Join Date: Jan 2015
Location: Spartanburg
Posts: 6
CavbotRyche is an unknown quantity at this point
Programming Java help.

I realy hate asking for help,but I have no where else to turn. I am a mechanical mentor with a second year team with no programming mentors. I have been trusted into helping the kids, which is not a big deal, but I have no direction for them. Here is the situation.

We have a ruff program installed on this years robot and it turns the wrong direction when given commands. We are using the the AndyMark long chassis with two motors per gear box. Currently using ports 1,2,3,4 for the outputs from the roborio to the motor controllers. Motor 1 is the front left, motor 2 in front right, motor 3 is rear left, and motor 4 is rear right.

I really don't want the answer if someone know, would not turn it down, but these kids need to learn as much as I do. I would like resources to help them learn to code this drive system. Any help is appreciated.
  #2   Spotlight this post!  
Unread 22-01-2015, 07:22
otherguy's Avatar
otherguy otherguy is offline
sparkE
AKA: James
FRC #2168 (The Aluminum Falcons)
Team Role: Mentor
 
Join Date: Feb 2010
Rookie Year: 2009
Location: CT
Posts: 443
otherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to behold
Re: Programming Java help.

My guess is that you need to invert the outputs going to one set of motors (left or right).

For example, if you were to tell all motors to drive fwd by sending them the same signal, and they were all wired identically, they may ball rotate their output shaft in the clockwise direction. They are all traveling in the same direction, but they are mounted on the chassis in different orientations (the right motors are rotated 180 degrees from the left), so this results on one set driving fwd and the other driving backwards.

To test what needs to change in your code, take baby steps. Verify the motors on the right had side travel fwd when you press fwd on the joystick. Then do the same for the left motors. If one side is going in the wrong direction, invert the output being sent to the motor controllerscontrollers for that side of the drivetrain (multiply output value by -1).

If that doesn't resolve the problem, providing a copy of your drivetrain code, and a description of how the turning isn't working specifically will help us narrow it down for you guys.

If you haven't seen it already, there's a good collection of information on java programming here:
http://wpilib.screenstepslive.com/s/4485/m/13809
__________________
http://team2168.org

Last edited by otherguy : 22-01-2015 at 07:25. Reason: added screensteps link
  #3   Spotlight this post!  
Unread 22-01-2015, 07:52
CavbotRyche CavbotRyche is offline
Registered User
FRC #5020
 
Join Date: Jan 2015
Location: Spartanburg
Posts: 6
CavbotRyche is an unknown quantity at this point
Re: Programming Java help.

Thank you for responding. I will try to look up the info on how to invert the command. Will post after our next meeting sometime next week.
  #4   Spotlight this post!  
Unread 22-01-2015, 09:06
MamaSpoldi's Avatar
MamaSpoldi MamaSpoldi is offline
Programming Mentor
AKA: Laura Spoldi
FRC #0230 (Gaelhawks)
Team Role: Engineer
 
Join Date: Jan 2009
Rookie Year: 2007
Location: Shelton, CT
Posts: 307
MamaSpoldi has a brilliant futureMamaSpoldi has a brilliant futureMamaSpoldi has a brilliant futureMamaSpoldi has a brilliant futureMamaSpoldi has a brilliant futureMamaSpoldi has a brilliant futureMamaSpoldi has a brilliant futureMamaSpoldi has a brilliant futureMamaSpoldi has a brilliant futureMamaSpoldi has a brilliant futureMamaSpoldi has a brilliant future
Re: Programming Java help.

If it turns the wrong direction when given commands... like it turns left when you tell it to turn right, then this is not an inverted motor problem. If one side needed to be inverted it would turn when you told it to go straight.

Instead I suspect that it is very likely that you mixed up the PWM order when you create the RobotDrive object (presuming that you are using that class). The documentation defines the interface to the constructor as:
Quote:
RobotDrive (final int frontLeftMotor, final int rearLeftMotor, final int frontRightMotor, final int rearRightMotor)
Based on the info you provided about your robot motor configuration here:
Quote:
Originally Posted by CavbotRyche View Post
Currently using ports 1,2,3,4 for the outputs from the roborio to the motor controllers. Motor 1 is the front left, motor 2 in front right, motor 3 is rear left, and motor 4 is rear right.
The proper way to create that object would be RobotDrive(1,3,2,4). If you have the PWM numbers in a different order it would send the wrong commands to the motors and would not drive as expected.

Of course, it could also be a combination of both the order of the PWMs and inverted motors. I would suggest that you make sure the PWM numbers are in the right order first, then if it is acting incorrectly put the robot up on blocks so that you can watch the wheels move and see which ones are turning the wrong direction when you command it to drive forward.

Hope this helps.
__________________
  #5   Spotlight this post!  
Unread 22-01-2015, 09:15
otherguy's Avatar
otherguy otherguy is offline
sparkE
AKA: James
FRC #2168 (The Aluminum Falcons)
Team Role: Mentor
 
Join Date: Feb 2010
Rookie Year: 2009
Location: CT
Posts: 443
otherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to behold
Re: Programming Java help.

Something I forgot to mention, FIRST verify that your motors are all plugged into the correct PWM channels according to your code. From your description 1 and 3 are left motors and 2 and 4 are right motors. Verify this is correct in code. If left and right are swapped in code, you'll be able to drive fwd and reverse fine, but turning will be backwards.

Also, my first post assumes that you're using tank drive for your controls (skid steer - one joystick controls left wheels, another controls right wheels). But it's possible that your team is using arcade drive (a single joystick - point it where you want the robot to go).

If the latter is the case, then you won't be able to individually test each side of the chassis. You can however test everything without messing with your wiring. Test each side of the chassis individually to confirm everything is working as expected.
  • push the stick fwd
  • verify the right wheels move forward
  • push the stick backwards
  • verify the right wheel moves backwards
If fwd/reverse are backwards, invert the output (multiply by negative 1).
Then do the same procedure the left wheels


After that's working, verify turning works correctly
  • Push the stick to the right
  • Verify the left wheels move fwd
  • Push the stick to the left
  • Verify the right wheels move fwd
if the above doesn't work, you've likely got the left and right motors backwards in code or wiring. If this is the case, fix the problem, then start over from the beginning, verifying left and right motors move fwd/rev when the stick is moved fwd/rev.

If you happen to be using the RobotDrive class to handle controlling your motors, and you need to invert a motor, you can multiply your input to the respective motors by negative 1 as I described, or you can use the setInvertedMotor() method.
__________________
http://team2168.org
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:59.

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