![]() |
Deadzone Programming
I looked around a bit but couldn't find any resources on this for c++
How do you program in a deadzone for a attack 3 joystick? I wrote this code but it doesn't seem to be working. Code:
void driving(){ |
Re: Deadzone Programming
Try this, you need to set default values. Also I just cleaned it up a bit.
Code:
void driving(){ |
Re: Deadzone Programming
Ok, thanks, I'll try that at practice on monday.
Also, how does setting default values for those variables change it? |
Re: Deadzone Programming
Quote:
|
Re: Deadzone Programming
We've found the following to work great for dead zones. The main advantage is you can still generate values between 0 and .3. With the previously posted solution once you get out of the dead zone you're instantly outputting .3 or 30%. If you notice we have a lot of 127s in the middle of the array. Those provide the dead zone but we shift everything else over so that once your out of the dead zone it doesn't go straight to .3.
This was written on the old control system. Technically the cRio has enough power to run the equation we are using to generate the array. We've just never taken the time to switch it over. Code:
const char inputShape[255] = {0,1,3,4,5,6,7,9,10,11,12,13,15,16,17,18,19,21,22,23,24,25,27,28,29,30,31, |
Re: Deadzone Programming
Quote:
|
Re: Deadzone Programming
Quote:
|
Re: Deadzone Programming
Gah, wasnt paying attention lol
|
Re: Deadzone Programming
Quote:
Code:
#include <math.h>Code:
#include <math.h> |
Re: Deadzone Programming
Thanks! Also, did you mean abs() instead of fabs()?
|
Re: Deadzone Programming
abs() takes an int and returns an int. fabs() takes a float and returns a float.
Since Joystick::GetX() and GetY() return floats, he did mean fabs(). |
Re: Deadzone Programming
Ah, thanks for the correction.
|
| All times are GMT -5. The time now is 12:19. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi