![]() |
Deadband Help
Hello we have a working mecanum code but we need to add dead band for a little better control. can any one help?
Code:
#include "WPILib.h" |
Re: Deadband Help
I described the way our team has been doing it the past few years here.
Hopefully sooner than later we will create a wrapper class for joystick objects so it's easier for ourselves and others to use this in the future. Let me know if you have any questions. |
Re: Deadband Help
That looks great but where/how would I add that into my code?
|
Re: Deadband Help
Give the following a try. I have a more object oriented version but don't have a robot to test it on so I don't want to distribute it yet. If it gives you any problems you can't figure out let me know. I don't have WindRiver handy to compile it but it should build.
In order to apply a dead band to a given axis you just need to pass the result of get axis method into InputShape. Then use the result that InputShape returns where you were using the get axis methods. ex. float x = InputShape(stick->GetX()); Code:
#include "WPILib.h" |
Re: Deadband Help
It looks good. but this is the error we are getting when trying to build it...
C:/WindRiver/wrwb-debugmode-workspace/SimpleTemplate/MyRobot.cpp: In member function `virtual void RobotDemo::OperatorControl()': C:/WindRiver/wrwb-debugmode-workspace/SimpleTemplate/MyRobot.cpp:69: error: base operand of `->' has non-pointer type `Joystick' C:/WindRiver/wrwb-debugmode-workspace/SimpleTemplate/MyRobot.cpp:70: error: base operand of `->' has non-pointer type `Joystick' C:/WindRiver/wrwb-debugmode-workspace/SimpleTemplate/MyRobot.cpp:71: error: base operand of `->' has non-pointer type `Joystick' C:\WindRiver\vxworks-6.3\host\x86-win32\bin\make.exe: *** [SimpleTemplate_partialImage/Debug/Objects/SimpleTemplate/MyRobot.o] Error 1 Build Failed in Project 'SimpleTemplate' (Process Exit Value was 2): 2013-02-15 09:38:49 (Elapsed Time: 00:06) |
Re: Deadband Help
Alright i just fixed it. All i did was instead of stick->get... i did stick.get..
thanks! |
Re: Deadband Help
Sorry about that. Glad you were able to figure it out. I guess that's what I get for copy and pasting.
|
Re: Deadband Help
How would you adjust the dead band in this?
|
Re: Deadband Help
Quote:
Let "d" be your desired +/- deadband. Let "out" be your modified joystick command (incorporating the deadband). Then: Code:
if (J>d) out = (J-d)/(1-d);"d" is the deadband tuning parameter in the range 0 <= d < 1 |
Re: Deadband Help
Quote:
|
Re: Deadband Help
1 Attachment(s)
Quote:
|
Re: Deadband Help
Another way to create deadzone-behaviour is to square the joystick X, Y, or Z value (and preserve the original sign, so a negative joystick value gives a negative result). For example, a js value of 0.5 gives a square of 0.25, but the maximum value of 1.0 still gives 1.0.
The way I learned this is an example of why I love to be a mentor. I'd written the algebra to implement a dead zone and with two slopes - it was complicated and when I tried to teach it at a WRRF programming workshop I confused most of the students. Afterwards a student (I think from FRC1700, Gatorbotics) told me about the square trick - it did what I wanted and was far easier to teach and implement. |
Re: Deadband Help
1 Attachment(s)
Quote:
|
| All times are GMT -5. The time now is 12:03. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi