Go to Post These are words on a computer screen, please stop giving the text on this screen such incredible power over how you feel. - Stephen Kowski [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 08-02-2012, 22:51
neal's Avatar
neal neal is offline
Neal
FRC #1777 (Viking Robotics)
Team Role: Mentor
 
Join Date: Jan 2012
Rookie Year: 2009
Location: United States
Posts: 56
neal is an unknown quantity at this point
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");
	}

}
If I remove all other motors except leftJag, rightJag and drive, it works fine.
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!
Reply With Quote
  #2   Spotlight this post!  
Unread 09-02-2012, 00:22
BurtGummer BurtGummer is offline
Electrical/Mechanical/Programming
FRC #3020
Team Role: Engineer
 
Join Date: Feb 2009
Rookie Year: 2009
Location: Southern CA
Posts: 89
BurtGummer will become famous soon enoughBurtGummer will become famous soon enough
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.
__________________
I'm a mentor looking for a home in Southern California! I know Java, C++, electrical and mechanical.

Need Java or C++ help? Send me a PM!
Reply With Quote
  #3   Spotlight this post!  
Unread 09-02-2012, 00:28
jesusrambo jesusrambo is offline
Self-Proclaimed Programmer Messiah
AKA: JD Russo
FRC #2035 (Robo Rockin' Bots)
Team Role: Programmer
 
Join Date: Feb 2012
Rookie Year: 2010
Location: Carmel, CA
Posts: 114
jesusrambo is an unknown quantity at this point
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?
Reply With Quote
  #4   Spotlight this post!  
Unread 09-02-2012, 07:08
neal's Avatar
neal neal is offline
Neal
FRC #1777 (Viking Robotics)
Team Role: Mentor
 
Join Date: Jan 2012
Rookie Year: 2009
Location: United States
Posts: 56
neal is an unknown quantity at this point
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.
Reply With Quote
  #5   Spotlight this post!  
Unread 09-02-2012, 08:42
gpetilli gpetilli is offline
Registered User
FRC #1559
 
Join Date: Jan 2009
Location: Victor, NY
Posts: 285
gpetilli is a name known to allgpetilli is a name known to allgpetilli is a name known to allgpetilli is a name known to allgpetilli is a name known to allgpetilli is a name known to all
Re: Simple test code not working (for jaguar)

Quote:
Originally Posted by neal View Post
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.
Blinking yellow definately means the Jaguar does not have communications. Do all of them blink? Are you sure that the new Jaguars do not have duplicate IDs to the old ones? Can you hook up a PC and using BDC-Comm "see" all the Jaguars? I strongly recommend the PC as a way of diagnosing a wireing problem from a software problem before tearing apart your code.
Reply With Quote
  #6   Spotlight this post!  
Unread 09-02-2012, 10:43
neal's Avatar
neal neal is offline
Neal
FRC #1777 (Viking Robotics)
Team Role: Mentor
 
Join Date: Jan 2012
Rookie Year: 2009
Location: United States
Posts: 56
neal is an unknown quantity at this point
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.
Reply With Quote
  #7   Spotlight this post!  
Unread 09-02-2012, 11:28
eddie12390's Avatar
eddie12390 eddie12390 is offline
Registered User
AKA: Eddie
FRC #3260 (SHARP)
Team Role: Programmer
 
Join Date: Jan 2011
Rookie Year: 2011
Location: Pittsburgh
Posts: 285
eddie12390 is a glorious beacon of lighteddie12390 is a glorious beacon of lighteddie12390 is a glorious beacon of lighteddie12390 is a glorious beacon of lighteddie12390 is a glorious beacon of light
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.
Reply With Quote
  #8   Spotlight this post!  
Unread 09-02-2012, 11:36
neal's Avatar
neal neal is offline
Neal
FRC #1777 (Viking Robotics)
Team Role: Mentor
 
Join Date: Jan 2012
Rookie Year: 2009
Location: United States
Posts: 56
neal is an unknown quantity at this point
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!
Reply With Quote
  #9   Spotlight this post!  
Unread 09-02-2012, 11:52
eddie12390's Avatar
eddie12390 eddie12390 is offline
Registered User
AKA: Eddie
FRC #3260 (SHARP)
Team Role: Programmer
 
Join Date: Jan 2011
Rookie Year: 2011
Location: Pittsburgh
Posts: 285
eddie12390 is a glorious beacon of lighteddie12390 is a glorious beacon of lighteddie12390 is a glorious beacon of lighteddie12390 is a glorious beacon of lighteddie12390 is a glorious beacon of light
Re: Simple test code not working (for jaguar)

Quote:
Originally Posted by neal View Post
By ribbon cable, do you mean the cable that goes from the cRIO module to the Digital Sidecar?
Exactly.

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.
Reply With Quote
  #10   Spotlight this post!  
Unread 09-02-2012, 13:06
jesusrambo jesusrambo is offline
Self-Proclaimed Programmer Messiah
AKA: JD Russo
FRC #2035 (Robo Rockin' Bots)
Team Role: Programmer
 
Join Date: Feb 2012
Rookie Year: 2010
Location: Carmel, CA
Posts: 114
jesusrambo is an unknown quantity at this point
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.
Reply With Quote
  #11   Spotlight this post!  
Unread 10-02-2012, 06:59
BurtGummer BurtGummer is offline
Electrical/Mechanical/Programming
FRC #3020
Team Role: Engineer
 
Join Date: Feb 2009
Rookie Year: 2009
Location: Southern CA
Posts: 89
BurtGummer will become famous soon enoughBurtGummer will become famous soon enough
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");
	}

}
I fixed several things in your code. It 'should' work now, providing the wiring is correct. I don't normally like writing code for people, so I please ask that you read up on java, and use the provided API to make sure you aren't calling classes that don't exist. I have added comments on the above code for things that I have edited. If you need help on coding, you can PM me as well.

Let me know how the above code works.
__________________
I'm a mentor looking for a home in Southern California! I know Java, C++, electrical and mechanical.

Need Java or C++ help? Send me a PM!
Reply With Quote
  #12   Spotlight this post!  
Unread 10-02-2012, 12:02
neal's Avatar
neal neal is offline
Neal
FRC #1777 (Viking Robotics)
Team Role: Mentor
 
Join Date: Jan 2012
Rookie Year: 2009
Location: United States
Posts: 56
neal is an unknown quantity at this point
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!
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 12:50.

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