|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
||||
|
||||
|
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() {
}
}
|
|
#2
|
|||
|
|||
|
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. |
|
#3
|
||||
|
||||
|
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...
|
|
#4
|
|||
|
|||
|
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. |
|
#5
|
||||
|
||||
|
Re: Mecanum Java Code
Quote:
Put the bot on blocks. In software, give the following commands, and for each, record what each of the wheels is doing: Pure Forward... then post your results. From those results, it will be possible to identify what needs to be changed. Last edited by Ether : 04-05-2016 at 20:33. Reason: clarified strafe direction |
|
#6
|
||||
|
||||
|
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.
![]() |
|
#7
|
||||
|
||||
|
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 Last edited by rlounds : 05-05-2016 at 18:22. Reason: Adding in the make of the joystick |
|
#8
|
||||
|
||||
|
Re: Mecanum Java Code
Quote:
Quote:
Quote:
Try swapping Front Right and Front Left PWM cables and re-run the test. See if the problem follows the cables. |
|
#9
|
||||
|
||||
|
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.
|
|
#10
|
||||
|
||||
|
Re: Mecanum Java Code
Quote:
|
|
#11
|
||||
|
||||
|
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.
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|