Go to Post Picking up tetra's is going to be as easy as picking up a person of the opposite sex. While a select few will master it; others will be bumbling maroons.. - Elgin Clock [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 06-11-2012, 15:39
y-aji y-aji is offline
Registered User
FRC #3734
 
Join Date: Dec 2011
Location: Lake Forest
Posts: 38
y-aji is an unknown quantity at this point
Lost our last programmer

Welp, it's nearing that time of year yet again and sadly, we have lost our Java programmer. We have yet to get any response out of our robot outside of the hello world program. Would someone verify if the following code (pulled from the generic tutorial) should work?

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;

public class GroundZeroTemplate extends SimpleRobot {
    
    RobotDrive drive = new RobotDrive(1,3,2,4);
    Joystick leftStick = new Joystick(1);
    Joystick rightStick = new Joystick(2);
            
    /**
     * This function is called once each time the robot enters autonomous mode.
     */
    public void autonomous() {
        /*getWatchdog().setEnabled(true);
        getWatchdog().setExpiration(0.5);
        drive.drive(1,0);
        Timer.delay(2);
        drive.drive(0,0);*/
        for (int i = 0; i < 4; i++) {
            drive.drive(0.5, 0.0); // drive 50% fwd 0% turn
            Timer.delay(2.0); // wait 2 seconds
            drive.drive(0.0, 0.75); // drive 0% fwd 0% turn
        }
    }

    /**
     * This function is called once each time the robot enters operator control.
     */
    public void operatorControl() {
        while (true && isOperatorControl() && isEnabled()) // loop until change
        {
            drive.tankDrive(leftStick, rightStick); // drive w/ joysticks
            Timer.delay(0.005);
        }
    }
}
The only unique aspect of our setup is that we are using 4 motors connected to 4 jaguars in our setup instead of the default 2.

When we activate this code in both autonomous as well as user-driven modes, we get no visual response from the jaguars whatsoever nor any movement. Should I look at something in this code or do I need to start looking at electrical problems?

Thank you!
Reply With Quote
  #2   Spotlight this post!  
Unread 06-11-2012, 16:02
joelg236 joelg236 is offline
4334 Retired Mentor & Alumni
AKA: Joel Gallant
no team
Team Role: Mentor
 
Join Date: Dec 2011
Rookie Year: 2012
Location: Calgary
Posts: 733
joelg236 has a reputation beyond reputejoelg236 has a reputation beyond reputejoelg236 has a reputation beyond reputejoelg236 has a reputation beyond reputejoelg236 has a reputation beyond reputejoelg236 has a reputation beyond reputejoelg236 has a reputation beyond reputejoelg236 has a reputation beyond reputejoelg236 has a reputation beyond reputejoelg236 has a reputation beyond reputejoelg236 has a reputation beyond repute
Re: Lost our last programmer

Make sure to remove this part:
Quote:
/*getWatchdog().setEnabled(true);
/* starts a comment. // is appropriate there.
__________________
All opinions are my own.
Reply With Quote
  #3   Spotlight this post!  
Unread 06-11-2012, 16:12
BigJ BigJ is online now
Registered User
AKA: Josh P.
FRC #1675 (Ultimate Protection Squad)
Team Role: Engineer
 
Join Date: Jan 2007
Rookie Year: 2007
Location: Milwaukee, WI
Posts: 947
BigJ has a reputation beyond reputeBigJ has a reputation beyond reputeBigJ has a reputation beyond reputeBigJ has a reputation beyond reputeBigJ has a reputation beyond reputeBigJ has a reputation beyond reputeBigJ has a reputation beyond reputeBigJ has a reputation beyond reputeBigJ has a reputation beyond reputeBigJ has a reputation beyond reputeBigJ has a reputation beyond repute
Re: Lost our last programmer

The above post notes that all your actions in autonomous are commented out.

I would try outputting the joystick values in the teleop code (try System.out.println() to print to Netbeans' console) to make sure you are getting input from the joysticks. If the jaguar lights still stay solid yellow when you know joystick values are going through, I'd check the signal wiring.
Reply With Quote
  #4   Spotlight this post!  
Unread 06-11-2012, 16:31
y-aji y-aji is offline
Registered User
FRC #3734
 
Join Date: Dec 2011
Location: Lake Forest
Posts: 38
y-aji is an unknown quantity at this point
Re: Lost our last programmer

Yeah, that block is commented out by design. The commented section is what was originally there, which I removed. Is watchdog required for the robot to operate? I know it's required to be legal in play.

Let me try outputting my joysticks this afternoon and I'll get back to you. That would be a major start.
Reply With Quote
  #5   Spotlight this post!  
Unread 06-11-2012, 17:34
y-aji y-aji is offline
Registered User
FRC #3734
 
Join Date: Dec 2011
Location: Lake Forest
Posts: 38
y-aji is an unknown quantity at this point
Re: Lost our last programmer

Cool. I threw this in and am testing it now:

Code:
    public void operatorControl() {
        while (true && isOperatorControl() && isEnabled()) // loop until change
        {
            drive.tankDrive(leftStick, rightStick); // drive w/ joysticks
            Timer.delay(0.005);
            System.out.print("Left:");
            System.out.println(leftStick);
            System.out.print("right:");
            System.out.println(rightStick);
        }
I'll update this thread when I get results.
Reply With Quote
  #6   Spotlight this post!  
Unread 06-11-2012, 17:37
F22Rapture's Avatar
F22Rapture F22Rapture is offline
College Student, Mentor
AKA: Daniel A
FRC #3737 (4H Rotoraptors)
Team Role: Mentor
 
Join Date: Jan 2012
Rookie Year: 2012
Location: Goldsboro, NC
Posts: 476
F22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant future
Re: Lost our last programmer

It doesn't look like you're feeding the watchdog, which means your control is expiring after only half a second. I'd suggest commenting it out entirely, changing .setEnabled(false), or making sure you put in a statement to feed it periodically by calling feed().

As the comment above mentioned, /* is for when you need to make a long block comment -- you need to replace that with //

The Java starter guide is slightly outdated as well, I'd suggest using the WPILib Cookbook if you haven't seen it already.

http://www.wbrobotics.com/attachment...ibCookbook.pdf
__________________
Research is what I’m doing when I don’t know what I’m doing.
- Wernher von Braun
Attending: Raleigh NC Regional
Reply With Quote
  #7   Spotlight this post!  
Unread 06-11-2012, 23:07
y-aji y-aji is offline
Registered User
FRC #3734
 
Join Date: Dec 2011
Location: Lake Forest
Posts: 38
y-aji is an unknown quantity at this point
Re: Lost our last programmer

Thanks for all the replies!

My responses don't seem to be going through, so if suddenly 5 replies come out of this from me, I apologize. We got the code to work, but still can't seem to get it to drive. I've gotten a response out of button presses with the suggested code. I left the whole block regarding watchdog off as it's in the autonomous section, anyway, which we are currently not working with. In fact, let me post the following to clarify what lines we're working with at this point:

Code:
/*----------------------------------------------------------------------------*/
/* Copyright (c) FIRST 2008. All Rights Reserved.                             */
/* Open Source Software - may be modified and shared by FRC teams. The code   */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project.                                                               */
/*----------------------------------------------------------------------------*/

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.Relay;
import edu.wpi.first.wpilibj.Relay.Value;
/**
 * The VM is configured to automatically run this class, and to call the
 * functions corresponding to each mode, as described in the SimpleRobot
 * documentation. If you change the name of this class or the package after
 * creating this project, you must also update the manifest file in the resource
 * directory.
 */
public class AwesomO extends SimpleRobot {
    
    RobotDrive drive = new RobotDrive(1,2);
    Joystick leftStick = new Joystick(1);
    Joystick rightStick = new Joystick(2);
    Relay firingMechanism;
    
    public void robotInit() {   
        firingMechanism = new Relay(1);
    }
    
    public void autonomous() {
        //not using autonomous atm
    }

    public void operatorControl() {
        while (true && isOperatorControl() && isEnabled()) // loop until change
        {
            drive.tankDrive(leftStick, rightStick); // drive w/ joysticks
            Timer.delay(0.005);
            System.out.println("Left: "+leftStick.getX()+", "+leftStick.getY());
            System.out.println("Right: "+rightStick.getX()+"' "+rightStick.getY());
            
            if(rightStick.getTrigger()){
                firingMechanism.set(Value.kReverse);
            }
            if(leftStick.getTrigger()){
                firingMechanism.set(Value.kForward);
            }
        }
    }
}
Currently everything works except driving. It reads the controller positions as well as pushes out relay commands (we can see blinks on the controller of red and green), however, the jaguar's are still not responding. Do they only work whenever watchdog is correctly configured? I can throw watchdog.setenabled(false) into robotInit.
Reply With Quote
  #8   Spotlight this post!  
Unread 07-11-2012, 07:35
PAR_WIG1350's Avatar
PAR_WIG1350 PAR_WIG1350 is offline
Registered User
AKA: Alan Wells
FRC #1350 (Rambots)
Team Role: Alumni
 
Join Date: Dec 2009
Rookie Year: 2009
Location: Rhode Island
Posts: 1,190
PAR_WIG1350 has a reputation beyond reputePAR_WIG1350 has a reputation beyond reputePAR_WIG1350 has a reputation beyond reputePAR_WIG1350 has a reputation beyond reputePAR_WIG1350 has a reputation beyond reputePAR_WIG1350 has a reputation beyond reputePAR_WIG1350 has a reputation beyond reputePAR_WIG1350 has a reputation beyond reputePAR_WIG1350 has a reputation beyond reputePAR_WIG1350 has a reputation beyond reputePAR_WIG1350 has a reputation beyond repute
Re: Lost our last programmer

Quote:
Originally Posted by y-aji View Post
Code:
   drive.drive(0,0);*/
Actually, they do end the block comment. below that is the 'for' loop containing the active autonomous routine.
__________________
Reply With Quote
  #9   Spotlight this post!  
Unread 07-11-2012, 09:46
y-aji y-aji is offline
Registered User
FRC #3734
 
Join Date: Dec 2011
Location: Lake Forest
Posts: 38
y-aji is an unknown quantity at this point
Re: Lost our last programmer

Bah! These messages aren't going through. Test? Can I post yet?
Reply With Quote
  #10   Spotlight this post!  
Unread 07-11-2012, 10:57
F22Rapture's Avatar
F22Rapture F22Rapture is offline
College Student, Mentor
AKA: Daniel A
FRC #3737 (4H Rotoraptors)
Team Role: Mentor
 
Join Date: Jan 2012
Rookie Year: 2012
Location: Goldsboro, NC
Posts: 476
F22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant future
Re: Lost our last programmer

Quote:
Originally Posted by y-aji View Post
Bah! These messages aren't going through. Test? Can I post yet?
Yes
__________________
Research is what I’m doing when I don’t know what I’m doing.
- Wernher von Braun
Attending: Raleigh NC Regional
Reply With Quote
  #11   Spotlight this post!  
Unread 07-11-2012, 11:20
joelg236 joelg236 is offline
4334 Retired Mentor & Alumni
AKA: Joel Gallant
no team
Team Role: Mentor
 
Join Date: Dec 2011
Rookie Year: 2012
Location: Calgary
Posts: 733
joelg236 has a reputation beyond reputejoelg236 has a reputation beyond reputejoelg236 has a reputation beyond reputejoelg236 has a reputation beyond reputejoelg236 has a reputation beyond reputejoelg236 has a reputation beyond reputejoelg236 has a reputation beyond reputejoelg236 has a reputation beyond reputejoelg236 has a reputation beyond reputejoelg236 has a reputation beyond reputejoelg236 has a reputation beyond repute
Re: Lost our last programmer

Code looks all good from what I can tell. Why not try
Quote:
drive.tankDrive(leftStick.getY(), rightStick.getX());
instead of passing the joystick objects?
__________________
All opinions are my own.
Reply With Quote
  #12   Spotlight this post!  
Unread 07-11-2012, 11:54
y-aji y-aji is offline
Registered User
FRC #3734
 
Join Date: Dec 2011
Location: Lake Forest
Posts: 38
y-aji is an unknown quantity at this point
Re: Lost our last programmer

I'll give that a shot and see if it changes anything this afternoon and update this post on its success or failure.

Thanks for the help! We are much further along today than we were yesterday. Just getting some response out of the machine saying that it sees our joysticks is a big leap forward to me.
Reply With Quote
  #13   Spotlight this post!  
Unread 07-11-2012, 15:22
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 8,590
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
Re: Lost our last programmer

What are the LEDs of the jaguars doing?
Reply With Quote
  #14   Spotlight this post!  
Unread 07-11-2012, 17:23
y-aji y-aji is offline
Registered User
FRC #3734
 
Join Date: Dec 2011
Location: Lake Forest
Posts: 38
y-aji is an unknown quantity at this point
Re: Lost our last programmer

That did it. The jaguars were blinking as if they were receiving no signal. I started nosing around at the wiring and found that the signal cables were reversed. Thanks guys. The final problems found were as follows:

24v was being handed out to the ni9201 instead of 12v.
the command cables from the sidecar were plugged in backwards.
The getX(),getY() needed to be added.

After all that, it's driving and receiving commands. Thank you guys for helping me tackle getting this thing up and running. For reference, the final successful code for our tank drive template is as follows:

Code:
/*----------------------------------------------------------------------------*/
/* Copyright (c) FIRST 2008. All Rights Reserved.                             */
/* Open Source Software - may be modified and shared by FRC teams. The code   */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project.                                                               */
/*----------------------------------------------------------------------------*/

/* 
 * Ground Zero Template
 * This Template is to be utilized to troubleshoot the robot. Please make no
 * changes to this code. It's to be copied and branched off of for new projects
 * and is for reference only.
*/

package edu.wpi.first.wpilibj.templates;

import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.Relay;
import edu.wpi.first.wpilibj.Relay.Value;
import edu.wpi.first.wpilibj.RobotDrive;
import edu.wpi.first.wpilibj.SimpleRobot;
import edu.wpi.first.wpilibj.Timer;

/**
 * The VM is configured to automatically run this class, and to call the
 * functions corresponding to each mode, as described in the SimpleRobot
 * documentation. If you change the name of this class or the package after
 * creating this project, you must also update the manifest file in the resource
 * directory.
 */
public class GroundZeroTemplate extends SimpleRobot {
    
    RobotDrive drive = new RobotDrive(1,2);
    Joystick leftStick = new Joystick(1);
    Joystick rightStick = new Joystick(2);
    
    Relay firingMechanism;
    
    public void robotInit() {
        firingMechanism = new Relay(1);
    }
    
    /**
     * This function is called once each time the robot enters autonomous mode.
     */
    public void autonomous() {
        /*getWatchdog().setEnabled(true);
        getWatchdog().setExpiration(0.5);
        drive.drive(1,0);
        Timer.delay(2);
        drive.drive(0,0);*/
        for (int i = 0; i < 4; i++) {
            drive.drive(0.5, 0.0); // drive 50% fwd 0% turn
            Timer.delay(2.0); // wait 2 seconds
            drive.drive(0.0, 0.75); // drive 0% fwd 0% turn
        }
    }

    /**
     * This function is called once each time the robot enters operator control.
     */
    public void operatorControl() {
        while (true && isOperatorControl() && isEnabled()) // loop until change
        {
            drive.tankDrive(leftStick.getY(), rightStick.getX()); // drive w/ joysticks
            Timer.delay(0.005);
            System.out.println("Left: "+leftStick.getX()+", "+leftStick.getY());
            System.out.println("Right: "+rightStick.getX()+"' "+rightStick.getY());
            
            if(rightStick.getTrigger()){
                firingMechanism.set(Value.kReverse);
            }
            if(leftStick.getTrigger()){
                firingMechanism.set(Value.kForward);
            }
        }
    }
}
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:51.

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