allwpilib icon indicating copy to clipboard operation
allwpilib copied to clipboard

Incorporate kS term in LinearSystemSim

Open shueja opened this issue 2 years ago • 0 comments

Is your feature request related to a problem? Please describe. In the LinearSystemSim-based physics modelers, static friction is not modeled, and any voltage supplied produces a movement. This adds a level of complexity and confusion to newer sim users because "it moves in sim when I command 0 velocity".

Describe the solution you'd like With the sysid-enabled encouragement of using kV and kA to set up the simulator, there is an opportunity in the user API to also specify kS, which would be internally subtracted out of the input when the input is set by the user.

Describe alternatives you've considered Currently, in 6995's code, we have a static util method, so it looks like sim.setInput(NomadMathUtil.subtractkS(voltage, kS)); This is fairly clean, but still an extra step and a team-supplied utility. The logic inside that utility method is

    public static double subtractkS(double voltage, double kS) {
        if(Math.abs(voltage) <= kS) {
            voltage = 0;
        }
        else {
            voltage -= Math.copySign(kS, voltage);
        }
        return voltage;
    }

shueja avatar May 14 '22 23:05 shueja