Have you added debug print statements for you code to see if your inputs and outputs make sense?
THat might help you get a quick sanity check of where your code is going wrong.
Is there's a reason you don't want to do something a little simpler?
Code:
float joyx = stick->GetRawAxis(0);
float joyy = stick->GetRawAxis(1);
if(stick->GetRawButton(10)){
multiplier = 0.4;
} else {
multiplier = 1;
}
rBot->ArcadeDrive(joyy * multiplier, joyx * multiplier);
Just change your multiplier variable to affect commanded rate of travel.
It doesn't give you X^2 scaling, but not sure you need that.
Keeping the x^2 implementation:
Code:
float joyx = stick->GetRawAxis(0);
float joyy = stick->GetRawAxis(1);
//#nostarmaster
joyx = joyx * abs(joyx);
joyy = joyy * abs(joyy);
if(stick->GetRawButton(10)){
multiplier = 0.4;
} else {
multiplier = 1;
}
rBot->ArcadeDrive(joyy * multiplier, joyx * multiplier);
I think this one does exactly what you were trying to do in your code.