We are using the following code the following code we made to control the robots movements with the left joystick, but we can only move forward <-> backward or left <-> right. We would like to include some forward <-> right movement.
Anyone has any suggestions?
[FONT=Consolas]int[/FONT] threshold = 10; [FONT=Consolas]//* esto le da un rango de movimiento al control. NO cambie este numero *//[/FONT]
[FONT=Consolas]while/FONT
{
[FONT=Consolas]// – Para Joystick que tiene Canal A MANO Izquierda -------------------------------------[/FONT]
[FONT=Consolas]if[/FONT](getJoystickValue(ChC) > threshold || getJoystickValue(ChC) < -threshold)
{
[FONT=Consolas]if[/FONT](getJoystickValue(ChC) > threshold)
{
setMotorSpeed(izquierdo, getJoystickValue(ChC));
setMotorSpeed(derecho, -getJoystickValue(ChC));
}
[FONT=Consolas]else[/FONT]
{
setMotorSpeed(izquierdo, getJoystickValue(ChC));
setMotorSpeed(derecho, -getJoystickValue(ChC));
}
}
[FONT=Consolas]else[/FONT]
{
[FONT=Consolas]if[/FONT](getJoystickValue(ChA) > threshold || getJoystickValue(ChA) < -threshold)
{
setMotorSpeed(izquierdo, getJoystickValue(ChA));
setMotorSpeed(derecho, getJoystickValue(ChA));
}
[FONT=Consolas]else[/FONT]
{
setMotorSpeed(izquierdo, 0);
setMotorSpeed(derecho, 0);
}
}
}