Go to Post I am the person I am because I have come to accept the mistakes I have made, not because I try to change them. - IronicDeadBird [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 05-04-2016, 04:45 PM
rlounds's Avatar
rlounds rlounds is offline
Registered Usr
AKA: Ryan Lounds
FRC #0865 (Warp7)
Team Role: Operator
 
Join Date: Jan 2016
Rookie Year: 2015
Location: Toronto
Posts: 14
rlounds is a splendid one to beholdrlounds is a splendid one to beholdrlounds is a splendid one to beholdrlounds is a splendid one to beholdrlounds is a splendid one to beholdrlounds is a splendid one to beholdrlounds is a splendid one to behold
Question Mecanum Java Code

Hi, so on my teams demo robot we're using mecanum wheels, a 4 slot cRIO and some victor 884s and we cant seem to get it working right. I don't know that much about code so it'd be great if I could get some help.

The code can be found below, any suggestions/correction are very much appreciated.
Code:
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;
import edu.wpi.first.wpilibj.Victor;

public class RobotTemplate extends SimpleRobot {

    RobotDrive myDrive;
    Joystick driveStick;
    
    public void robotInit() {
        driveStick = new Joystick(1);
        Victor frontLeft = new Victor(1);
        Victor frontRight = new Victor(2);
        Victor rearLeft = new Victor(3);
        Victor rearRight = new Victor(4);
        myDrive = new RobotDrive(frontLeft, rearLeft, frontRight, rearRight);
        System.out.println("Sample Text");
    }
    
    public void autonomous() {
        
    }

    public void operatorControl() {
        while (isOperatorControl() && isEnabled()) {
            myDrive.mecanumDrive_Cartesian(driveStick.getX(), driveStick.getY(), driveStick.getTwist(), 0);
            Timer.delay(0.01);
      
        }
    }
    
    public void test() {
    
    }
}
Reply With Quote
  #2   Spotlight this post!  
Unread 05-04-2016, 05:01 PM
Ben Wolsieffer Ben Wolsieffer is offline
Dartmouth 2020
AKA: lopsided98
FRC #2084 (Robots by the C)
Team Role: Alumni
 
Join Date: Jan 2011
Rookie Year: 2011
Location: Manchester, MA (Hanover, NH)
Posts: 520
Ben Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud of
Re: Mecanum Java Code

What problems are you having with it? Are you getting errors? Does the robot move at all?

Quickly looking it over I don't see any problems.
__________________



2016 North Shore District - Semifinalists and Excellence in Engineering Award
2015 Northeastern University District - Semifinalists and Creativity Award
2014 Granite State District - Semifinalists and Innovation in Control Award
2012 Boston Regional - Finalists
Reply With Quote
  #3   Spotlight this post!  
Unread 05-04-2016, 06:16 PM
rlounds's Avatar
rlounds rlounds is offline
Registered Usr
AKA: Ryan Lounds
FRC #0865 (Warp7)
Team Role: Operator
 
Join Date: Jan 2016
Rookie Year: 2015
Location: Toronto
Posts: 14
rlounds is a splendid one to beholdrlounds is a splendid one to beholdrlounds is a splendid one to beholdrlounds is a splendid one to beholdrlounds is a splendid one to beholdrlounds is a splendid one to beholdrlounds is a splendid one to behold
Re: Mecanum Java Code

3 of our wheels don't go in the same direction and one doesn't move unless told to turn on the spot. Tried swapping some PWMs and that didn't help. I'm also not getting any errors with the code either...
Reply With Quote
  #4   Spotlight this post!  
Unread 05-04-2016, 06:48 PM
Ben Wolsieffer Ben Wolsieffer is offline
Dartmouth 2020
AKA: lopsided98
FRC #2084 (Robots by the C)
Team Role: Alumni
 
Join Date: Jan 2011
Rookie Year: 2011
Location: Manchester, MA (Hanover, NH)
Posts: 520
Ben Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud of
Re: Mecanum Java Code

First, I would make sure you have the PWMs mapped correctly. If you are sure these are correct, it will make debugging everything else much easier.

Also, if you haven't already, put the robot on blocks so you can see what the motors are doing without having it try to drive around.

My guess is that you need to invert some of the motors. You can do this either in code (using myDrive.setInvertedMotor()), or by reversing the polarity of the wires that go from the Victor to the motor. When you push the joystick forward, all the wheels should move. If they don't you either have a problem with your joystick axes (what joystick are you using?) or your motor controller. Once all 4 wheels are moving when you command the robot to go forward, invert all the ones that are going backwards.
__________________



2016 North Shore District - Semifinalists and Excellence in Engineering Award
2015 Northeastern University District - Semifinalists and Creativity Award
2014 Granite State District - Semifinalists and Innovation in Control Award
2012 Boston Regional - Finalists
Reply With Quote
  #5   Spotlight this post!  
Unread 05-04-2016, 08:07 PM
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 7,997
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Mecanum Java Code

Quote:
Originally Posted by lopsided98 View Post
put the robot on blocks so you can see what the motors are doing
^^^THIS

Put the bot on blocks. In software, give the following commands, and for each, record what each of the wheels is doing:
Pure Forward

Pure Strafe Right

Pure Rotate clockwise
... then post your results. From those results, it will be possible to identify what needs to be changed.



Last edited by Ether : 05-04-2016 at 08:33 PM. Reason: clarified strafe direction
Reply With Quote
  #6   Spotlight this post!  
Unread 05-04-2016, 08:14 PM
rlounds's Avatar
rlounds rlounds is offline
Registered Usr
AKA: Ryan Lounds
FRC #0865 (Warp7)
Team Role: Operator
 
Join Date: Jan 2016
Rookie Year: 2015
Location: Toronto
Posts: 14
rlounds is a splendid one to beholdrlounds is a splendid one to beholdrlounds is a splendid one to beholdrlounds is a splendid one to beholdrlounds is a splendid one to beholdrlounds is a splendid one to beholdrlounds is a splendid one to behold
Re: Mecanum Java Code

When I'm back in our robotics space tomorrow I'll get the information about the wheels, and we're currently running the robot on top of a tote bin.
__________________

Head of Public Relations & Operator for FRC Team 865, Warp7

2016 GTR-C Quarter-Finalist (1310, 1325, 865)
2016 North Bay Regional Quarter-Finalist (2185, 4716, 865)
2016 Waterloo Regional Quarter-Finalist (2702, 5631, 865)

Reply With Quote
  #7   Spotlight this post!  
Unread 05-05-2016, 06:16 PM
rlounds's Avatar
rlounds rlounds is offline
Registered Usr
AKA: Ryan Lounds
FRC #0865 (Warp7)
Team Role: Operator
 
Join Date: Jan 2016
Rookie Year: 2015
Location: Toronto
Posts: 14
rlounds is a splendid one to beholdrlounds is a splendid one to beholdrlounds is a splendid one to beholdrlounds is a splendid one to beholdrlounds is a splendid one to beholdrlounds is a splendid one to beholdrlounds is a splendid one to behold
Re: Mecanum Java Code

So after trying some stuff out, here's the list of things you asked for Ether. We're also using a Logitech Extreme 3D Pro for our joystick.

Pure Forward:
Front Right = Spins forward
Front Left = Not working at all
Back Right = Spins forward
Back Left = Spins forward

Strafe Right:
Front Right = Spins forwards
Front Left = Not working at all
Back Right = Spins backwards
Back Left = Spins forwards

Rotating clockwise:
Front Right = Spins forwards
Front Left = Not working at all
Back Right = Spins forwards
Back Left = Spins backwards
***NOTE: FRONT LEFT TURNS FORWARDS WHEN TURNING COUNTER-CLOCKWISE
__________________

Head of Public Relations & Operator for FRC Team 865, Warp7

2016 GTR-C Quarter-Finalist (1310, 1325, 865)
2016 North Bay Regional Quarter-Finalist (2185, 4716, 865)
2016 Waterloo Regional Quarter-Finalist (2702, 5631, 865)


Last edited by rlounds : 05-05-2016 at 06:22 PM. Reason: Adding in the make of the joystick
Reply With Quote
  #8   Spotlight this post!  
Unread 05-06-2016, 01:50 PM
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 7,997
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Mecanum Java Code

Quote:
Originally Posted by Ether View Post
Put the bot on blocks. In software, give the following commands...
Quote:
Originally Posted by rlounds View Post
here's the list of things you asked for Ether. We're also using a Logitech Extreme 3D Pro for our joystick...
It sounds like you issued the commands by moving the joystick (hardware) instead of commanding them directly in software. Or am I misreading your post?


Quote:
Originally Posted by rlounds View Post
Pure Forward:
Front Left = Not working at all

Strafe Right:
Front Left = Not working at all

Rotating clockwise:
Front Left = Not working at all
There is obviously something very wrong here. I suggest you try to get to the bottom of this first:

Try swapping Front Right and Front Left PWM cables and re-run the test. See if the problem follows the cables.


Reply With Quote
  #9   Spotlight this post!  
Unread 05-12-2016, 06:35 PM
rlounds's Avatar
rlounds rlounds is offline
Registered Usr
AKA: Ryan Lounds
FRC #0865 (Warp7)
Team Role: Operator
 
Join Date: Jan 2016
Rookie Year: 2015
Location: Toronto
Posts: 14
rlounds is a splendid one to beholdrlounds is a splendid one to beholdrlounds is a splendid one to beholdrlounds is a splendid one to beholdrlounds is a splendid one to beholdrlounds is a splendid one to beholdrlounds is a splendid one to behold
Re: Mecanum Java Code

After all of the help I've received through this thread, we've manged to get everything working correctly. Thank you guys so much.
__________________

Head of Public Relations & Operator for FRC Team 865, Warp7

2016 GTR-C Quarter-Finalist (1310, 1325, 865)
2016 North Bay Regional Quarter-Finalist (2185, 4716, 865)
2016 Waterloo Regional Quarter-Finalist (2702, 5631, 865)

Reply With Quote
  #10   Spotlight this post!  
Unread 05-12-2016, 06:41 PM
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 7,997
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Mecanum Java Code

Quote:
Originally Posted by rlounds View Post
After all of the help I've received through this thread, we've manged to get everything working correctly. Thank you guys so much.
Please tell us why Front Left was not working at all.


Reply With Quote
  #11   Spotlight this post!  
Unread 05-12-2016, 06:43 PM
rlounds's Avatar
rlounds rlounds is offline
Registered Usr
AKA: Ryan Lounds
FRC #0865 (Warp7)
Team Role: Operator
 
Join Date: Jan 2016
Rookie Year: 2015
Location: Toronto
Posts: 14
rlounds is a splendid one to beholdrlounds is a splendid one to beholdrlounds is a splendid one to beholdrlounds is a splendid one to beholdrlounds is a splendid one to beholdrlounds is a splendid one to beholdrlounds is a splendid one to behold
Re: Mecanum Java Code

The motor controller wasn't working correctly. We replaced it with another Victor 884 and it worked just fine. We also had a little incident of it another 884 sparking out and dying today so we'll also be changing it to use Talon SRs shortly.
__________________

Head of Public Relations & Operator for FRC Team 865, Warp7

2016 GTR-C Quarter-Finalist (1310, 1325, 865)
2016 North Bay Regional Quarter-Finalist (2185, 4716, 865)
2016 Waterloo Regional Quarter-Finalist (2702, 5631, 865)

Reply With Quote
  #12   Spotlight this post!  
Unread 05-12-2016, 06:57 PM
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 7,997
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Mecanum Java Code


Quote:
Originally Posted by rlounds View Post
The motor controller wasn't working correctly
How did you determine that?

Was this part of the process of identifying that problem?
Quote:
Originally Posted by View Post
Try swapping Front Right and Front Left PWM cables and re-run the test. See if the problem follows the cables.

Reply With Quote
  #13   Spotlight this post!  
Unread 05-12-2016, 07:06 PM
rlounds's Avatar
rlounds rlounds is offline
Registered Usr
AKA: Ryan Lounds
FRC #0865 (Warp7)
Team Role: Operator
 
Join Date: Jan 2016
Rookie Year: 2015
Location: Toronto
Posts: 14
rlounds is a splendid one to beholdrlounds is a splendid one to beholdrlounds is a splendid one to beholdrlounds is a splendid one to beholdrlounds is a splendid one to beholdrlounds is a splendid one to beholdrlounds is a splendid one to behold
Re: Mecanum Java Code

The problem solving process was swapping PWM cables as well as remembering that our old mecanum drive train had a major problems with shorting Victor 884s. Under further inspection, the controller was also having trouble initializing and didn't initialize most of the time.
__________________

Head of Public Relations & Operator for FRC Team 865, Warp7

2016 GTR-C Quarter-Finalist (1310, 1325, 865)
2016 North Bay Regional Quarter-Finalist (2185, 4716, 865)
2016 Waterloo Regional Quarter-Finalist (2702, 5631, 865)

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 08:19 AM.

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