Hi, everyone
I just finished writing my code about controlling the robot. When I try all the buttons on Joystick, it works fine. However, when I try two joysticks on the controller, the motor turns at an extremely slower rate. Even though the direction is the same as I program, it rotates really slow. Adding more speed in programming does not help. Can anyone help me to solve this problem whether it should be the coding problem or other hardware problems? Thank you very much!
The following is my code:
int main() {
while(true){
Motor1.spin(directionType::fwd,Controller1.Axis2.position(percentUnits::pct),velocityUnits::pct);
Motor2.spin(directionType::fwd,Controller1.Axis3.position(percentUnits::pct),velocityUnits::pct);
Motor3.spin(directionType::fwd,Controller1.Axis1.position(percentUnits::pct),velocityUnits::pct);
Motor4.spin(directionType::fwd,Controller1.Axis4.position(percentUnits::pct),velocityUnits::pct);
if(Controller1.ButtonUp.pressing()){
Motor1.spin(directionType::fwd, 50, velocityUnits::pct);
Motor2.spin(directionType::fwd, 50, velocityUnits::pct);
}
else if(Controller1.ButtonDown.pressing()){
Motor1.spin(directionType::rev, 50, velocityUnits::pct);
Motor2.spin(directionType::rev, 50, velocityUnits::pct);
}
else if(Controller1.ButtonLeft.pressing()){
Motor3.spin(directionType::fwd, 50, velocityUnits::pct);
Motor4.spin(directionType::fwd, 50, velocityUnits::pct);
}
else if(Controller1.ButtonRight.pressing()){
Motor3.spin(directionType::rev, 50, velocityUnits::pct);
Motor4.spin(directionType::rev, 50, velocityUnits::pct);
}
//Else stop the arm and hold its current position
else{
Motor1.stop(brakeType::hold);
Motor2.stop(brakeType::hold);
Motor3.stop(brakeType::hold);
Motor4.stop(brakeType::hold);
}
}
}