Log in

View Full Version : Joystick Axis Problem: axis input is not being recognized


Cyborg Mustang
12-02-2015, 00:37
Hello there. I am writing on behalf of the programming/control team of Team 2647 Cyborg Mustangs.

Our team programs in Java and we use a Logitech Gamepad to control our bot. We were able to get our 2-motor drive train and 1-CIM elevator mechanism up and running yesterday. We mapped the elevator motor control to the digital triggers on the controller (left = -1, right = 1, and neither = 0, with speed control that adjusts the inputs by a selected fraction) and we mapped axis 1 and axis 3 (the left stick and right stick in forward and backward motion) to each motor in a tank drive setup, with an optional toggle for arcade drive mapped to the start button.

Today, however, the drive train was not functioning properly. Strangely enough, when we mapped the digital triggers to the drive train motors instead of the analog sticks, we were able to drive the robot just fine. After further testing, it turned out that only the digital buttons were able to control the bot, while all of the axes were not able to control anything whatsoever. We tested this with both the Logitech Gamepad and the Logitech Extreme 3D Joystick, which yielded the same results. We also tested the bot through USB and WiFi connection to the roboRIO, but neither seemed to have any effect.

While looking into the problem, we discovered that the FRC Dashboard recognized the controller and all axes and buttons but we were not able to use the axes when controlling the robot for some reason. Our programmer created a new control scheme that used only the digital buttons on the gamepad, but we are still concerned as to why we are not able to utilize the axes of any joystick.

I cannot post the code currently because I am not in the shop, but I will be sure to once I am back in the shop. Regardless, even with a default SampleRobot project with tank drive setup, the axes were still not able to control the drive train.

While it is not crucial to our robot this competition, any help is appreciated so that we can ensure our success in future competitions. Thank you all in advance, and Happy FIRSTing.

Cecil
12-02-2015, 00:40
We ran into this issue once using a Logitech F310 Gamepad. There is a button on the controller itself labelled "Mode". When this is pressed (the green LED next to it lights up), it disables the analog sticks on the gamepad. Perhaps this is the problem you are seeing.

Cyborg Mustang
12-02-2015, 00:48
Thank you so much. I'll be sure to take a look and see if that's the issue tomorrow in the shop. Don't know how we could have missed that. Thank you again.

Cyborg Mustang
12-02-2015, 18:43
Thank you for the help but that didn't end up being the problem. We'll be experimenting more to figure iut the problem and trying out another computer as a driver station in the future, but our controls are functional since we switched to a button-only control scheme.

Cyborg Mustang
01-03-2015, 17:22
BUMP

Ether
01-03-2015, 18:35
BUMP

It's possible you didn't get any more responses because your previous post (http://www.chiefdelphi.com/forums/showpost.php?p=1442832&postcount=4) gave the impression that you had a satisfactory work-around and you were going to run another test... and you never reported the results of that test.

Cyborg Mustang
01-03-2015, 19:27
Yes, that's probably why. I haven't had much time to update it.
In the meantie, we haven't found a reason why it is not functioning correctly, but it applies to all joysticks and still persists even with a standard SamleRobot TankDrive setup.

Ether
01-03-2015, 19:38
I cannot post the code currently because I am not in the shop, but I will be sure to once I am back in the shop.

Perhaps people were waiting for you to follow up on this^

... and when you didn't, they assumed you'd solved the problem.

Cyborg Mustang
01-03-2015, 19:52
Perhaps. We didn't solve it, we just made a workaround with button-only control so our robot could function and we hadn't found a solution so we had abandoned it for the time being.

Greg McKaskle
03-03-2015, 07:58
Can you better describe what the following means?
In the meantie, we haven't found a reason why it is not functioning correctly, but it applies to all joysticks and still persists even with a standard SamleRobot TankDrive setup.

What happens in the USB tab? What is your code that reads the joystick element? What do you expect it to do? What does it do instead?

Greg McKaskle

Cyborg Mustang
03-03-2015, 08:42
In the USB tab all axes and buttons are shown, but when we try to get the value of an axis in code, the console says the axis cannot be found on the joystick. Buttons work just fine though.

Greg McKaskle
03-03-2015, 08:45
Which axis? What code is used to get that axis? Remember, it is zero based.

Greg McKaskle

Cyborg Mustang
03-03-2015, 09:53
Axis 1 because it is the forward-backward axis on the left stick and Axis 3 because it is the forward-backward axis on the right stick. We purposely skipped 0 and 2, which are the sideways axes. To get the value of the axes we do "gamepad.getRawAxis(1)" and "gamepad.getRawAxis(3)" and store those in separate variables of type double. The speeds are then multiplied by a selected modifier in the array [0.25, 0.5, or 0.75] the index of which is determined by the press of 3 buttons. We then plug the modified speed in like so: "drive.TankDrive(modifiedSpeedLeft, modifiedSpeedRight)"

Cyborg Mustang
03-03-2015, 10:01
*drive.tankDrive(modifiedSpeedLeft, modifiedSpeedRight)"

Alan Anderson
03-03-2015, 12:50
On the Driver Station, which USB "slot" is your gamepad showing up in? How are you initializing your gamepad object?

Cyborg Mustang
03-03-2015, 13:44
It shows up in slot 0. We initialize the gamepad as a Joystick on USB slot 0 in the top of the Robot class.

Cyborg Mustang
04-03-2015, 18:18
I did some testing today and realized the problem was that the driverstation believed there to be a joystick plugged into USB slot 0 even though there was not a joystick in it. This "ghost" joystick persisted across reboots and caused any joysticks we plugged in to be on slot 1. The "ghost joystick" in slot 0 was recognized as our old gamepad, of which only the buttons worked, and any joysticks plugged in after it didn't work at all. That's how we fogured out it was the "ghost" joystick that was causing us problems.

We appreciate all your help in this issue, thank you. See you all at competition. Cheers and happy FIRSTing.