But I am unsure of what some of the stuff is. I am an amateur programer, and have no idea what some of this stuff means. Particularly the deadzone,the X and Y and Channels. Please help!
I realize that this code will not strafe, and if someone could help me with that too that would be great!!
I am by no means a professional, but I can read the code.
Dead zone is the feature frequently used in any joystick programming. Basically, the way we program a joystick to motor is giving the reading of the joystick to the motor. When we do not want motors to move, we allow the joystick to go back to its original position. However the original position is usually not a precise 0 reading. Without dead zone, your motor may possibly keep drifing when the joystick is not moved. So dead zone is a command saying that if joystick reading is under a certain value, just stop the motors. And in the program sample the programmer used absolute value to simplify the code, but basically it is the same principle.
The addition and subtraction below is the command for holonomic mecanum drive. Basically a mecanum drive uses same driver code as an X drive. Easy c does this for you in one block, but giving addition and subtraction values of joystick channel readings to motors is the principle programming an arcade holonomic drive.
Edit: if you are using easy c, joystick deadzone is automatically prepared and holonomic drive has an easy setup block. This is just the bare-bone code behind it.
That definitely clears it up! Thank you so much! I’m trying to make sure that I understand the code before actually trying to use it (and or fix what ever happened when I tested it).
Thank you again to everyone who posted, but can anyone help me with the strafing? Omni wheels is ok too, but my team has been talking and we are sure that strafing is something we definitely want to at least attempt. Thanks for the help!
This will set all motors which have a low power to zero, even if you want them to be set to a low value (ie. arm hold code in lifts). Also, it will not check the last motor which could cause one side of a lift to hold, while the other goes down (resulting in a tipped robot and/or bent metal).
task main()
{
while(1)
{
// Ch1 ontrols arm
if( abs(vexRT Ch1 ]) > 15 )
{
motor[port1] = vexRT Ch1 ];
motor[port10] = vexRT Ch1 ];
}
else
{
// Hold power
motor[port1] = 19;
motor[port10] = 19;
}
// Other code in here
// That takes time to execute
// unfortunate deadband
for (int i=0;i<9;i++) {
if (abs(motor*)<20) {
motor*=0;
}
}
wait1Msec(25);
}
}
There are two potential issues.
As you said, if you want some small value sent to the motors then this code will override that.
It may cause the motors to “jitter” if other small values are sent. The operating system is using the values in the “motor” array and sends them out to the motors approximately every 20mS. If you set in your code values between 1 and 19, these may be sent before the deadband code changes them back to 0. Values higher than 10 to so can cause the motor to move, in other words, the motor may turn quickly on and off.
These are minor issues and may not be noticeable. Better solution if you want to do this is to use an intermediate variable for motor values and then send those once to the motors at the end of the while loop.**