Analog sticks provide low values in the corners

Our teams driver insists on having single stick arcade drive. I already have programmed tank and dual stick arcade using PROS (CLI, not in an IDE).
However, I don’t know if it’s possible to have full range of control over both turn and linear speed with a single stick, because when the stick is pushed to a “corner” (representing full forward and turn simultaneously) I read analogue values of around 110 - 90 on both axes rather than say, the full 127 that would be possible on both axes with dual stick.
Any remedy to this or do I just tell the driver to deal with the dual stick? Even a real issue?

2 Likes

There is no single best way of clipping joystick inputs and mapping them to control values of your motor.

It is a matter of personal preference, but here is what people have been doing in the past:

Also, you could study end of the season code submissions fro the past seasons:

3 Likes

@jpearman posted a code fragment to expose the behaviour you’re dealing with: I am wondering why the vex controller joy sticks aren't "Nice" - #26 by jpearman They’re just numbers at that point, so you can try anything you like to transform them into something that works well for you as illustrated by @weilin 's collection. For example, if you desperately want those corners back, truncate x and y at the edges of a square that touches the midpoints of the arcs and rescale everything.

3 Likes

Thank you for the resources. I read that the values are maxing out before getting to the physical limit of the controller and I made a function to kind of correct for this:

int cvals(int analog) { //control values function, returns control value for inputs
        if (std::abs(analog) < 110) {
                return std::round(analog * 1.154545);
        }
        else {
                return std::copysign(127, analog);
        }
}
1 Like

That’s believable. I want to suggest working with floating point values (I think they’re doubles?) all the way through because integers don’t help you specifically, and you’ll probably want to shape it a bit further to give slower motion and turning for small deflections of the stick. IIRC, normalizing to -1<=stickx and sticky<=1 and using a * stick+b * stick^5 works well once you’ve settled on a and b coefficients. Opinion will vary enormously, and it should, because you should consider optimizing the response of the controls to your drivers, not vice-versa if you can. And they’re all very different. (There’s also the question of picking wheel speeds from a set of 256 per mode, but that might not necessarily be noticeable - test, write up, get notebook kudos.)

2 Likes

I believe this is what you are looking for, to simply stretch the circle to a square:

https://www.geogebra.org/calculator/kwtbc9ja

1 Like

Have a look at jpearman’s graph - the rounded corners come from the limits of the housing, not from a characteristic of the two axes of the stick. If you square a circle that isn’t there in this case, when the driver moves the stick to steer, the speed will change, and if they try to accelerate while turning, it’ll turn less. Linear scaling is more appropriate. But, squaring circles is interesting - there’s more of a survey of different approaches here: https://arxiv.org/pdf/1509.06344

2 Likes