Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Java (http://www.chiefdelphi.com/forums/forumdisplay.php?f=184)
-   -   Joysticks not reading (http://www.chiefdelphi.com/forums/showthread.php?t=137220)

Poseidon5817 12-05-2015 18:24

Joysticks not reading
 
I am reprogramming our 2014 robot, and the joysticks will not read in the code. However, the DS USB port tab does read the values properly. I have also tried multiple different controllers to no avail. This is using the pre-2015 control system.

Robot.java
Code:

package edu.wpi.first.wpilibj.templates;

import edu.wpi.first.wpilibj.IterativeRobot;
import edu.wpi.first.wpilibj.Joystick;

public class Robot extends IterativeRobot {
   
    Joystick driveStick;
   
    public void robotInit() {
        Storage.createObjects();
        driveStick = new Joystick(1);
    }

    public void autonomousPeriodic() {

    }

    public void teleopInit() {
       
    }
   
    public void teleopPeriodic() {
        System.out.println(driveStick.getRawAxis(4));
    }
   
    public void testPeriodic() {
   
    }
   
}

Storage.java
Code:

package edu.wpi.first.wpilibj.templates;

import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.RobotDrive;
import edu.wpi.first.wpilibj.Talon;

public class Storage {
   
    public static Talon leftTalon1, leftTalon2, rightTalon1, rightTalon2;
   
    public static RobotDrive drive;
   
    public static void createObjects() {
       
        leftTalon1 = new Talon(RobotMap.LEFT_TALON_1);
        leftTalon2 = new Talon(RobotMap.LEFT_TALON_2);
        rightTalon1 = new Talon(RobotMap.RIGHT_TALON_1);
        rightTalon2 = new Talon(RobotMap.RIGHT_TALON_2);
       
        drive = new RobotDrive(leftTalon1, leftTalon2, rightTalon1, rightTalon2);
        drive.setSafetyEnabled(true);
       
    }
   
}

RobotMap.java
Code:

package edu.wpi.first.wpilibj.templates;

public class RobotMap {
   
    public final static int LEFT_TALON_1 = 3;
    public final static int LEFT_TALON_2 = 4;
    public final static int RIGHT_TALON_1 = 1;
    public final static int RIGHT_TALON_2 = 2;
           
    public final static int LEFT_INTAKE = 7;
    public final static int RIGHT_INTAKE = 8;
           
    public final static int INTAKE_JAGUAR = 2;
           
    public final static int CATAPULT_LIMIT = 9;
           
    public final static int CATAPULT_LEFT = 5;
    public final static int CATAPULT_RIGHT = 4;
   
}

The print statement in teleopPeriodic() returns 0.0, and driveStick.getRawButton() at any button returns false.

Anyone got any ideas? I have no clue.

MaGiC_PiKaChU 12-05-2015 18:41

Re: Joysticks not reading
 
are you trying to deloy your code with eclipse? That might not work at all, go back to netbeans

Poseidon5817 12-05-2015 18:42

Re: Joysticks not reading
 
Quote:

Originally Posted by MaGiC_PiKaChU (Post 1481729)
are you trying to deloy your code with eclipse? That might not work at all, go back to netbeans

I'm sorry, I am in Netbeans, exactly as it was on kickoff day. If I upload the old robot project, the joysticks read properly.

After a quick check, the Joystick instance is non-null, it is being created, but it is only returning 0's.

I am using a red Afterglow Xbox 360 controller.

MaGiC_PiKaChU 12-05-2015 19:04

Re: Joysticks not reading
 
Have you tried printing values in autonomous init? robot init? just to have a look if your code actually runs :)

Poseidon5817 12-05-2015 19:05

Re: Joysticks not reading
 
robotInit() runs. I haven't tested autonomousInit(). It still works in old projects but won't work in this one.

GeeTwo 12-05-2015 19:54

Re: Joysticks not reading
 
As I recall, the axis numbers changed from 2014 to 2015. Oh well, joystick axis 4 appears to be the horizontal on the right joystick both years.

Is your controller perhaps mapping to a different number than control 1? Have you tried 0 or 2 as the argument to new Joystick() in robotInit? Actually, even easier as you seem to have the hardware, you could try plugging in "multiple different controllers" at the same time and see if any of them works.

Poseidon5817 12-05-2015 20:17

Re: Joysticks not reading
 
Quote:

Originally Posted by GeeTwo (Post 1481743)
As I recall, the axis numbers changed from 2014 to 2015. Oh well, joystick axis 4 appears to be the horizontal on the right joystick both years.

Is your controller perhaps mapping to a different number than control 1? Have you tried 0 or 2 as the argument to new Joystick() in robotInit? Actually, even easier as you seem to have the hardware, you could try plugging in "multiple different controllers" at the same time and see if any of them works.

I've already tried all of that, with gamepads, Xbox controllers, and actual joysticks. All of them had the same issue.

MaGiC_PiKaChU 12-05-2015 20:29

Re: Joysticks not reading
 
also, the joystick mapping start at 0, so try changing your joystick port on your DS in the usb section

GeeTwo 12-05-2015 20:46

Re: Joysticks not reading
 
Did you back-load (or do you still have) the 2014 driver station software installed on your classmate/laptop, or are you running 2015 driver station? I understand that there were significant protocol changes from 2014 to 2015.

Poseidon5817 12-05-2015 20:53

Re: Joysticks not reading
 
I am running the 2015 DS with the option for 2014 DS and FMS mode selected.

Pault 12-05-2015 21:21

Re: Joysticks not reading
 
Quote:

Originally Posted by Poseidon1671 (Post 1481758)
I am running the 2015 DS with the option for 2014 DS and FMS mode selected.

That doesn't seem to be what that mode is supposed to do.

From the wpilib screensteps documentation:

Quote:

FMS Protocol - This controls which version of the DS to FMS communication protocol to use. This control is only needed when connecting to a 2014 FMS such as at a Week Zero event, where it should be set to '14. This control will reset to '15 (the setting required for 2015 Competition Events) each time the DS is started.

Poseidon5817 12-05-2015 22:01

Re: Joysticks not reading
 
Regardless, the joystick reads in our main program (although axis mapping is messed up), but not this one.

GeeTwo 13-05-2015 04:38

Re: Joysticks not reading
 
Quote:

Originally Posted by Poseidon1671 (Post 1481771)
Regardless, the joystick reads in our main program (although axis mapping is messed up), but not this one.

By "our main program", do you mean the driver station? If so, then that's what Pault was saying would happen. It appears that the legacy mode is only for connections via the FMS, not direct connections. Here, it's not FMS that is the old version, but the robot computer. I believe that you will have to run the 2014 driver station or a work alike.

Poseidon5817 13-05-2015 09:28

Re: Joysticks not reading
 
By main program I meant our main robot code from last year. The joystick returns values when the robot runs that program, but there is no difference (that I see) in how the joysticks are created and called in the new program, and it does not work.

Poseidon5817 14-05-2015 18:25

Re: Joysticks not reading
 
Just an update, it WAS the joystick ports that were wrong. I created the Joystick object in port 1 and moved the controller to 0 instead of 1 on the DS and it worked. Thanks for the help guys!


All times are GMT -5. The time now is 10:49.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi