Swerve Precise Mode using YAGSL?

I am programming our MK4i module using the YAGSL library, and I wanted to make an addition within the teleoperated mode, which is a slow mode that focuses on precision, that is, for example, while I hold down the B button on the joystick driver, the speed of engines is limited, this way I can drive more calmly and precisely, but I tried to implement it but I couldn’t do it, I wanted to know if you could help me implement this.

Code on GitHub

Make something to modify the scale of the translational and/or rotational axis requested to move?

i need to use an specific class, or only change de constants value when i press the button?

you can add a parameter to your teleop constructor that stores a boolean value of whether or not you want slow mode and then if that value is true you can reduce your velocities by whatever factor you want, then set your b button as the supplier for that boolean value

you can also have max speed constants for slow mode that you multiply the velocities by when the value is true and then use your normal max speed constants when it’s false

You can copy your teleop drive command and multiply joystick inputs by a factor to slow them down, quick and easy solution

We multiply our final drive vector by a factor that represents how hard the driver is pressing down on the trigger, that way our driver can “feather” boost mode. Here’s an example of how we tackle this:
image
image
image

This can also be adapted to slow down the robot: if (driverStick.getRawButton(B)) kBoostCoefficient *= 0.3; multiplies your final drive vector by 0.3 to get you 30% drive output.

We’ve done Swerve differently than other teams have - the entire code is posted here if you’d like to take a look!

If you are struggling with fine control I would first recommend using a smooth joystick. It usually just raises your input to the power of 2. If your input is between 0 and 1 then it still gives you access to max speed, while making it easier to have precise control. If you still need finer control then you can implement this slow down or slow down your normal control and then add a boost button.

I would also recommend binding this button to one of the triggers or buttons if you have space, so that you can keep your fingers on the sticks for better control.

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