Go to Post FIRST should come with a warning label. - Tim Sharp [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 28-01-2015, 17:39
LFRobotics's Avatar
LFRobotics LFRobotics is offline
Registered User
FRC #4623
 
Join Date: Jan 2014
Location: Little Falls, MN
Posts: 95
LFRobotics is on a distinguished road
Main Robot Code NOT Working

I uploaded this code to the robot and it won't work. Also a lot of the methods such as increment() and turnRight() in Chassis are "dead code" according to Eclipse. increment() and decrement() change the value of rspeed up and down.

Here is a link to the code on gitHub: https://github.com/LFRobotics/Robot2015

THANKS for the help!
Reply With Quote
  #2   Spotlight this post!  
Unread 28-01-2015, 19:58
Joey1939's Avatar
Joey1939 Joey1939 is offline
Registered User
AKA: Joey Holliday
FRC #1939 (Kuhnigits)
Team Role: Programmer
 
Join Date: Jan 2014
Rookie Year: 2014
Location: Kansas City, Missouri
Posts: 142
Joey1939 has a spectacular aura aboutJoey1939 has a spectacular aura aboutJoey1939 has a spectacular aura about
Re: Main Robot Code NOT Working

Okay, two easy issues to fix.

1. Code taken from DriveTele.java
Code:
protected void execute() {
        Robot.base.mecanumDrive(
                (XBox.LEFTJOY_X+XBox.LEFTJOY_Y)/2,
                (XBox.LEFTJOY_Y-XBox.LEFTJOY_X)/2,
                -(XBox.LEFTJOY_Y-XBox.LEFTJOY_X)/2,
                -(XBox.LEFTJOY_X+XBox.LEFTJOY_Y)/2);
    }
Right here XBox.LEFTJOY_X is an enum. It will always be the same value (definition of an enum). It appears this enum represents the number of the left x axis. Instead you should access the actual value from the joystick with:
Code:
Robot.oi.joystick.getLeftJoyX();
2. Code taken from Chasis.java
Code:
public void initDefaultCommand() {
        // Set the default command for a subsystem here.
        //setDefaultCommand(new DriveTele());
    }
You need to uncomment "setDefaultCommand(new DriveTele());" to tell the Chasis the run the DriveTele command and make your robot move.


Also you said that increment() and decrement() are dead, but they are just commented out...
Reply With Quote
  #3   Spotlight this post!  
Unread 29-01-2015, 08:00
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,586
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
The dead code is also caused by reading joystick constants, rather the joystick values.

XBox.RIGHTJOY_Y < 0 is always false, so the code in the if statement never executed and is thus dead code.
Reply With Quote
  #4   Spotlight this post!  
Unread 29-01-2015, 10:21
LFRobotics's Avatar
LFRobotics LFRobotics is offline
Registered User
FRC #4623
 
Join Date: Jan 2014
Location: Little Falls, MN
Posts: 95
LFRobotics is on a distinguished road
Re: Main Robot Code NOT Working

I commented out one pair of increment/decrement methods but left the other pair - I was testing which one worked better.

So .LEFTJOY_X is enum but .LEFTJOY_Y is not - those are pointers to getRawAxis() in the XBox class - I will try that but I don't know if it will do anything.

Why is XBox.RIGHTJOY_Y < 0 always going to be false - dont joystick axis return values from -1 to 1? How else would I make a program that would change the robots speed using the right joysticks X axis on an XBox controller?
Reply With Quote
  #5   Spotlight this post!  
Unread 29-01-2015, 10:35
Joey1939's Avatar
Joey1939 Joey1939 is offline
Registered User
AKA: Joey Holliday
FRC #1939 (Kuhnigits)
Team Role: Programmer
 
Join Date: Jan 2014
Rookie Year: 2014
Location: Kansas City, Missouri
Posts: 142
Joey1939 has a spectacular aura aboutJoey1939 has a spectacular aura aboutJoey1939 has a spectacular aura about
Re: Main Robot Code NOT Working

Quote:
Originally Posted by LFRobotics View Post
So .LEFTJOY_X is enum but .LEFTJOY_Y is not - those are pointers to getRawAxis() in the XBox class - I will try that but I don't know if it will do anything.
You need to use the methods in the class instead of the enum.
Code:
    public boolean getButtonA() {
     return getRawButton(A_BUTTON);
}
    
    public boolean getButtonB() {
        return getRawButton(B_BUTTON);
    }
    
    public boolean getButtonX() {
        return getRawButton(X_BUTTON);
    }
    
    public boolean getButtonY() {
        return getRawButton(Y_BUTTON);
    }
    
    public boolean getButtonRB() {
        return getRawButton(RB_BUTTON);
    }
    
    public boolean getButtonLB() {
        return getRawButton(LB_BUTTON);
    }
    
    public boolean getButtonRS() {
        return getRawButton(RS_BUTTON);
    }
    
    public boolean getButtonLS() {
        return getRawButton(LS_BUTTON);
    }
    
    public boolean getButtonStart() {
        return getRawButton(START_BUTTON);
    }
    
    public boolean getButtonBack() {
        return getRawButton(BACK_BUTTON);
    }
    
    public double getLeftJoyY() {
        return getRawAxis(LEFTJOY_Y);
    }
    
    public double getLeftJoyX() {
        return getRawAxis(LEFTJOY_X);
    }
    
    public double getRightJoyY() {
        return getRawAxis(RIGHTJOY_Y);
    }
    
    public double getRightJoyX(){
        return getRawAxis(RIGHTJOY_X);
    }
    
    public double getRightTrigger() {
        return -Math.min(getRawAxis(RIGHT_TRIGGER), 0);
    }
    
    public double getLeftTrigger() {
        return Math.max(getRawAxis(LEFT_TRIGGER), 0);
    }
The methods take the enum values that represent button and axis numbers and gets the actual feedback from the joystick.
Reply With Quote
  #6   Spotlight this post!  
Unread 29-01-2015, 11:38
LFRobotics's Avatar
LFRobotics LFRobotics is offline
Registered User
FRC #4623
 
Join Date: Jan 2014
Location: Little Falls, MN
Posts: 95
LFRobotics is on a distinguished road
Re: Main Robot Code NOT Working

Okay I changed all that.

Here's the updated code: https://github.com/LFRobotics/Robot2015

But when I upload it the DriverStation puts out an error and says the robot has no code.

Eclipse Build Output:

Code:
Buildfile: C:\Users\Kristen\Documents\GitHub\Robot2015\build.xml
Trying to override old definition of task classloader
clean:
   [delete] Deleting directory C:\Users\Kristen\Documents\GitHub\Robot2015\build
   [delete] Deleting directory C:\Users\Kristen\Documents\GitHub\Robot2015\dist
compile:
    [mkdir] Created dir: C:\Users\Kristen\Documents\GitHub\Robot2015\build
     [echo] [athena-compile] Compiling src with classpath=C:\Users\Kristen/wpilib/java/current/lib/WPILib.jar:C:\Users\Kristen/wpilib/java/current/lib/NetworkTables.jar to build
    [javac] Compiling 12 source files to C:\Users\Kristen\Documents\GitHub\Robot2015\build
jar:
     [echo] [athena-jar] Making jar dist/FRCUserProgram.jar.
    [mkdir] Created dir: C:\Users\Kristen\Documents\GitHub\Robot2015\dist
    [mkdir] Created dir: C:\Users\Kristen\Documents\GitHub\Robot2015\build\jars
     [echo] [athena-jar] Copying jars from C:\Users\Kristen/wpilib/java/current/lib/WPILib.jar:C:\Users\Kristen/wpilib/java/current/lib/NetworkTables.jar to build/jars.
     [copy] Copying 2 files to C:\Users\Kristen\Documents\GitHub\Robot2015\build\jars
      [jar] Building jar: C:\Users\Kristen\Documents\GitHub\Robot2015\dist\FRCUserProgram.jar
get-target-ip:
     [echo] Trying Target: roboRIO-4623.local
     [echo] roboRIO found via mDNS
dependencies:
     [echo] roboRIO image version validated
     [echo] Checking for JRE. If this fails install the JRE using these instructions: https://wpilib.screenstepslive.com/s/4485/m/13503/l/288822-installing-java-8-on-the-roborio-using-the-frc-roborio-java-installer-java-only
  [sshexec] Connecting to roboRIO-4623.local:22
  [sshexec] cmd : test -d /usr/local/frc/JRE
deploy:
     [echo] [athena-deploy] Copying code over.
      [scp] Connecting to roboRIO-4623.local:22
      [scp] done.
      [scp] Connecting to roboRIO-4623.local:22
      [scp] done.
     [echo] [athena-deploy] Starting program.
  [sshexec] Connecting to roboRIO-4623.local:22
  [sshexec] cmd : . /etc/profile.d/natinst-path.sh; /usr/local/frc/bin/frcKillRobot.sh -t -r;
  [sshexec] start-stop-daemon: warning: killing process 5656: No such process
BUILD SUCCESSFUL
Total time: 11 seconds
Driver Station Error:

Code:
ERROR Unhandled exception instantiating robot org.usfirst.frc.team4623.robot.Robot java.lang.ExceptionInInitializerError at [java.lang.Class.forName0(Native Method), java.lang.Class.forName(Class.java:259), edu.wpi.first.wpilibj.RobotBase.main(RobotBase.java:197)]
Reply With Quote
  #7   Spotlight this post!  
Unread 29-01-2015, 17:47
LFRobotics's Avatar
LFRobotics LFRobotics is offline
Registered User
FRC #4623
 
Join Date: Jan 2014
Location: Little Falls, MN
Posts: 95
LFRobotics is on a distinguished road
Re: Main Robot Code NOT Working

I am trying everything but I can't get it to work.
Reply With Quote
  #8   Spotlight this post!  
Unread 30-01-2015, 10:31
notmattlythgoe's Avatar
notmattlythgoe notmattlythgoe is offline
Flywheel Police
AKA: Matthew Lythgoe
FRC #2363 (Triple Helix)
Team Role: Mentor
 
Join Date: Feb 2010
Rookie Year: 2009
Location: Newport News, VA
Posts: 1,725
notmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond repute
Re: Main Robot Code NOT Working

In your Chassis class you have a RobotDrive that is using the same channels as the 4 Jaguars you created. What you want to do is pass those 4 Jaguars into the RobotDrive constructor, not pass in the channels again.

Code:
roborDrive = new RobotDrive(frontLeftMotor, rearLeftMotor, frontRightMotor, rearRightMotor);
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 18:07.

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