for position control of our bot. I was wondering if there is a way to change the analog stick controls from linear control to an exponential type of output and still use the natural language commands. The reason for wanting to do this is our driver feels the bot is too “twitchy” for precise aiming tasks.
Natural language is implemented as functions in an included file, you can see the source by looking at the file NatLang_Cortex.c (easiest way is to right click on tankControl and use the goto definition menu item). The code for tank control is as follows.
That looks way more complicated than it really is due to using generic calls for setting motor speed etc. A simplified, cortex specific, version would be as follows.
void tankControl_custom(TVexJoysticks leftJoystick = Ch3, TVexJoysticks rightJoystick = Ch2, short threshold = 10)
{
short nRightSideSpeed;
short nLeftSideSpeed;
updateMotorDriveTrain();
// get joystick values.
nRightSideSpeed = vexRT rightJoystick ];
nLeftSideSpeed = vexRT leftJoystick ];
// if joystick is close to center then for to 0
if(abs(getJoystickValue(rightJoystick)) <= abs(threshold))
nRightSideSpeed = 0;
if(abs(getJoystickValue(leftJoystick)) <= abs(threshold))
nLeftSideSpeed = 0;
// set drive train motors
setMotorSpeeds(nRightSideSpeed, nLeftSideSpeed);
}
This still uses the “drive train” motors used by natural language.
An even simpler version would be;
void tankControl_custom(TVexJoysticks leftJoystick = Ch3, TVexJoysticks rightJoystick = Ch2, short threshold = 10)
{
short nRightSideSpeed;
short nLeftSideSpeed;
// get joystick values.
nRightSideSpeed = vexRT rightJoystick ];
nLeftSideSpeed = vexRT leftJoystick ];
// if joystick is close to center then for to 0
if(abs(getJoystickValue(rightJoystick)) <= abs(threshold))
nRightSideSpeed = 0;
if(abs(getJoystickValue(leftJoystick)) <= abs(threshold))
nLeftSideSpeed = 0;
// Set motors hers
motor port2 ] = nRightSideSpeed;
motor port3 ] = nLeftSideSpeed;
}
If you have more motors for left and right then set accordingly. From this point modify the two lines of code that get joystick values to your liking.