Trigger Help

Our trigger programming has stopped working and I don’t know how to fix it. Here it is, somebody please help.

if (OI.stick.getRawAxis(button) > 0)
            OI.shootMotor.set(1);
        else {
            OI.shootMotor.set(0);
        }

It’s super simple, which is why I can’t figure out why it isn’t working. Please help, thank you!

I just noticed this error is present, and I’m sure it is causing it. How can I fix it?

Warning at edu.wpi.first.wpilibj.DriverStation.reportJoystickUnpluggedWarning(DriverStation.java:1097): Joystick axis 10 on port 0 not available, check if controller is plugged in

Have you checked on the driver station if your joystick is in the right port and checked the trigger in the menu for that. You may have stuck the joystick into the wrong port on your laptop. I get that error when I have the joystick in the wrong port

1 Like

I’ll double check, thanks for the help!

The title for this topic is quite interesting without context… lol.

1 Like

Fair point I was in a hurry :joy:. Also it still isn’t solved so… :grimacing:

The error says Driver Station thinks the controller is unplugged. We get that error a scary amount of the time because our usb cords for our xbox controllers are garbage and dont work half the time. The first step is to make sure its plugged in, communicating and is in the right port in driver station especially if you have multiple controllers plugged in. You could also try a different controller if you have one, or try a different usb cord or port on the laptop.

Also, when this does start working, I would add a deadzone because if there is any amount of controller drift, it will always be shooting.

1 Like

Close, it actually says the axis is not found. I’ve never seen a joystick in FRC-land that has 10 axes.

@runtime_terror, your code calls getRawAxis(button). Was this a typo? The triggers are analog (variable value) axes, not buttons. I’m willing to bet that button has a value of 10, which is likely not the value you intend to use. What type of controller are you using? If you look at the USB tab on the driver station, which bar moves when you press/activate the “trigger”?

2 Likes

To be fair, usually the error is because the controller is not plugged in. All the DS can tell is that it asks for a certain button on a port and sees whether it’s there. If we ask it for the wrong thing…Once again, computers don’t know what we really want.

1 Like

Originally it was a button, but I changed it to a trigger. In that button variable I call a trigger, which is an axis, so the fact it’s labeled button doesn’t matter.

I’ve tried three different controllers, I’m running out of ideas and we have a week one comp

Can you post your full code? It may be caused be something somewhere else

1 Like

But what is the value of button?

Yes, posting your entire code would definitely help in debugging. Preferably with GitHub

1 Like

@Fletch1373 is right. Unless you have a custom built controller, it probably doesn’t have an axis 10. It looks like you’re trying to use a trigger as a button so it would probably be easier to set it up with a button. If you’re out of buttons, and you want your driver to move an axis on your joystick to turn on the shooter, and you have verified ‘button’ is an actual axis number you could try

if (math.abs(OI.stick.getRawAxis(button) > 0.1)
     OI.shootMotor.set(1);
else {
        OI.shootMotor.set(0);
    }

That will help with the deadzone.
If you want to use a button, it returns a boolean so you could do it like this

if (OI.stick.getRawButtonPressed(button) 
    OI.shootMotor.set(1); ... etc.
3 Likes

Did the code stop working after you changed it from a button to a trigger?

1 Like

Yes, in DS it shows trigger is getting values, but the code is not responding to it. I’m going to refrain from posting the full code just because there’s a lot of AI / Neural Networking I’ve done and I want to keep that to us for our first comp.

Ok I don’t know what I did, but the error is gone now. Thanks for the advice!

1 Like

Alright good luck in your competition

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