|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
||||
|
||||
|
Simple test code not working (for jaguar)
We were just trying out all our motors on the new robot. First we just tried with the drive motors, and it worked fine. After that I added other motors as well, and then nothing was working. I got no errors whatsoever. The lights on the jags were just blinking yellow. But even the drive motors stopped working too. So we tried to remove all the other motors and see if the drive motors still work, and it did. So I think the problem is something in the code for the other motors.
Here's my code: Code:
public class TestBot extends SimpleRobot {
private Gamepad gamepad1, gamepad2, gamepad3, gamepad4;
private UserMessages uM;
private Jaguar leftJag, rightJag;
private SpeedController shooterFeeder, shooter;
private SpeedController grabber;
private SpeedController arm;
private Relay angler;
private RobotDrive drive;
public void robotInit() {
uM = new UserMessages();
rightJag = new Jaguar(1);
leftJag = new Jaguar(2);
shooterFeeder = new Jaguar(3);
shooter = new Jaguar(4);
arm = new Jaguar(5);
grabber = new Jaguar(6);
drive = new RobotDrive(leftJag, rightJag);
angler = new Relay(1);
gamepad1 = new Gamepad(1);
gamepad2 = new Gamepad(2);
gamepad3 = new Gamepad(3);
gamepad4 = new Gamepad(4);
Watchdog.getInstance();
System.out.println("[robot] Robot Ready!\n");
}
public void autonomous() {
System.out.println("[mode] Autonomous started");
uM.write(1, "Autonomous Mode");
while (isAutonomous() && isEnabled()) {
getWatchdog().feed();
Timer.delay(0.005);
}
System.out.println("[mode] Autonomous stopped");
}
public void operatorControl() {
System.out.println("[mode] Tele-op started");
uM.write(1, "Tele-op Mode");
while (isOperatorControl() && isEnabled()) {
getWatchdog().feed();
drive.tankDrive(gamepad1.getAxis(2), gamepad1.getAxis(5));
grabber.set(gamepad1.getAxis(3));
shooter.set(gamepad2.getAxis(2));
shooterFeeder.set(gamepad2.getAxis(5));
if(gamepad1.getButton(3) || gamepad1.getButton(3)) {
angler.set(Relay.Value.kForward);
}
else if(gamepad1.getButton(4) || gamepad1.getButton(4)) {
angler.set(Relay.Value.kReverse);
}
else {
angler.set(Relay.Value.kOff);
}
Timer.delay(0.005);
}
System.out.println("[mode] Tele-op stopped");
}
}
We'd really appreciate if someone can figure out the problem so we don't have to test each part one by one on Saturday. Thanks in advance! |
|
#2
|
|||
|
|||
|
Re: Simple test code not working (for jaguar)
What type of motor controllers are you using; jaguars or victors?
Hint: In the code, make sure that the type of identifiers you make are consistent throughout the rest of the code. |
|
#3
|
|||
|
|||
|
Re: Simple test code not working (for jaguar)
Why do you declare shooterFeeder, shooter, grabber, and arm all as SpeedControllers instead of as Jaguars, if you're just going to initialize them as Jaguars?
Also, blinking yellow lights mean your Jags aren't getting input at all. When your robot is enabled and sitting still you want solid yellow, meaning they're getting an input of zero. Are you sure it's not throwing any exceptions in the netbeans console output? |
|
#4
|
||||
|
||||
|
Re: Simple test code not working (for jaguar)
We are using Jaguars.
I tried Jaguars first, then I saw some sample code that used SpeedController, so I tried that. And yes, there is no exception in console. I also tried printing joystick values to console, and that worked fine. I also tried to print leftJag.get(); and it returned the values it was supposed to have from joystick. Last edited by neal : 09-02-2012 at 07:11. |
|
#5
|
|||
|
|||
|
Re: Simple test code not working (for jaguar)
Quote:
|
|
#6
|
||||
|
||||
|
Re: Simple test code not working (for jaguar)
We aren't using CAN, we're using PWM. Does the ID still matter? Because we don't even have the serial to USB (or whatever is needed).
I understand that blocking yellow light means no signal is being received by the jaguars, but the thing is, if I remove all the other motors, it works. Also, if this makes sense -- if I just have one jaguar in the code and control it with Y axis, I can plug that PWM to all the jaguars one by one and they all work fine. |
|
#7
|
||||
|
||||
|
Re: Simple test code not working (for jaguar)
These are VERY similar to the problems that we received when using a broken/improperly made ribbon cable. Once we had more than 4 motors random motors would run or no motors would run at all.
|
|
#8
|
||||
|
||||
|
Re: Simple test code not working (for jaguar)
By ribbon cable, do you mean the cable that goes from the cRIO module to the Digital Sidecar? If so, we are using that same one we used last year. It's the old one that's really thick.
Even though I don't think that's the issue, I will still try a different one. You never know what's wrong. Thanks! |
|
#9
|
||||
|
||||
|
Re: Simple test code not working (for jaguar)
Quote:
If it's the same one that you are using from last year than it is most likely not the problem. We were using the one that we received this year and had exactly the same problems as you have described. |
|
#10
|
|||
|
|||
|
Re: Simple test code not working (for jaguar)
Grab a voltmeter and test your ribbon cable pin by pin. This definitely sounds like a wiring problem.
|
|
#11
|
|||
|
|||
|
Re: Simple test code not working (for jaguar)
So, you have used code that was like this, with Jaguar types instead of SpeedControllers?
Code:
public class TestBot extends SimpleRobot {
private Joystick gamepad1, gamepad2, gamepad3, gamepad4; // These need to be initialized as joysticks, not gamepads.
private UserMessages uM;
private Jaguar leftJag, rightJag;
private Jaguar shooterFeeder, shooter, grabber, arm;
private Relay angler;
private RobotDrive drive;
public void robotInit() {
uM = new UserMessages();
rightJag = new Jaguar(1);
leftJag = new Jaguar(2);
shooterFeeder = new Jaguar(3);
shooter = new Jaguar(4);
arm = new Jaguar(5);
grabber = new Jaguar(6);
drive = new RobotDrive(2, 1); // Constructor wants PWM channels.
angler = new Relay(1);
gamepad1 = new Joystick(1); // These need to be initialized as joysticks, not gamepads.
gamepad2 = new Joystick(2);
gamepad3 = new Joystick(3);
gamepad4 = new Joystick(4);
Watchdog.getInstance();
System.out.println("[robot] Robot Ready!\n");
}
public void autonomous() {
System.out.println("[mode] Autonomous started");
uM.write(1, "Autonomous Mode");
while (isAutonomous() && isEnabled()) {
getWatchdog().feed();
Timer.delay(0.005);
}
System.out.println("[mode] Autonomous stopped");
}
public void operatorControl() {
System.out.println("[mode] Tele-op started");
uM.write(1, "Tele-op Mode");
while (isOperatorControl() && isEnabled()) {
getWatchdog().feed();
drive.tankDrive(gamepad1.getAxis(2), gamepad1.getAxis(5));
grabber.set(gamepad1.getAxis(3));
shooter.set(gamepad2.getAxis(2));
shooterFeeder.set(gamepad2.getAxis(5));
if(gamepad1.getButton(3) || gamepad1.getButton(3)) {
angler.set(Relay.Value.kForward);
}
else if(gamepad1.getButton(4) || gamepad1.getButton(4)) {
angler.set(Relay.Value.kReverse);
}
else {
angler.set(Relay.Value.kOff);
}
Timer.delay(0.005);
}
System.out.println("[mode] Tele-op stopped");
}
}
Let me know how the above code works. |
|
#12
|
||||
|
||||
|
Re: Simple test code not working (for jaguar)
Gamepad is an extended class for Joystick that I wrote for a few things that I wanted to change, and that is not the problem since I tried using Joystick class as well.
For the RobotDrive, you can also have left SpeedController and right SpeedController instead of PWMs. I think it's something wrong in wiring. If I have just the drive motors in my code, it works fine. And if I have all the other motors except the drive motors, it works fine then also. But as soon as I include all the motors, everything stops working. Thanks! |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|