Command scheduled when Joystick not plugged in

Every time we enable the robot without joysticks plugged into the driver station, the robot will add the command to roll our intake wheels to the scheduler. The command in question is only supposed to be run when we hold a joystick button down. What’s even more weird is said command is never scheduled by itself, but rather it is a part of a commandgroup where multiple commands are all being called, however none of those commands are scheduled when we enable, just the roll intake wheels command. The command in question is not a default command for the subsystem and I have checked everywhere to make sure it is never being scheduled in the code besides the commandgroup that adds it in parallel with a bunch of other commands when a button is pressed down.

Similarly when joysticks are plugged in, the command will schedule itself in autonomous even if we tell the robot to do nothing, but as soon as teleop init is called, it will no longer being scheduled

To summarize, a command is being scheduled when it should not be, and I was wondering if anyone had any insight as to why it is

Its certainly weird, any chance you can post the entirety of your code? Preferably on GitHub. It would make debugging and troubleshooting much easier.

A couple other things, would be posting the state of the button to the dashboard withbutton.get()to see if for some reason it says the button is pressed.

Have you tried commenting out the command in the CommandGroup to see if it still happens?

If you don’t have any default command that sets the intake motors to 0.0, are you making sure that when you initialize your motor controllers you set them to 0.0?

I messaged you privately

I have seen that When we unplug our 3rd joystick (Lauchpad) and tether via USB to the robot it fires commands as well when we enable the robot.

How are you scheduling these commands?

ME? button presses. I wondered if the DS somehow is confused and registered the Roborio as a joystick or maybe some buffered data exists.

If we use a second laptop to tether (Code download) there is no ill actions. The problem only happens if we try to tether to the driverstation laptop and need to use USB where there are only 3 USB ports and currently 3 Joysticks. When we unplug one Joystick for the tether.

It turns out our issue is when the Joystick is not plugged in and it cannot see a POV button it will schedule the command. I’m unaware why, but thank you @ExploitSage for pointing this out

It sounds like a logic issue! Post your code and we’ll be happy to see what we can do!

1 Like

My best guess (haven’t looked into it yet), is that when a joystick isn’t plugged in, the Joystick just returns 0 for everything… including the POV Hat. In this case, that means that anything checking it would think the POV Hat was being pressed in the UP position. Which just so happened to be a position being used in the code.

It seemed to return -1

@Smosher104 I would recommend trying to put the initialization of your joysticks/buttons in a try catch, so it only uses the buttons if the joystick is found

1 Like

You do have to be careful with POV. Teams often have code that looks for a non-zero POV, expecting 0 to be the default, but when a gamepad isn’t plugged in POV returns -1 instead of 0.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.