Announcement

Collapse
No announcement yet.

Four motors for two sticks.

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Four motors for two sticks.

    Hi guys, I'm from 5703 Doppler Effect and my name is CJ. I'm wanting to map four motors to make this go like this.
    The Left stick would allow the robot to go forward and backward.
    The Right stick would allow the robot to go right and left.
    left = -gamepad1.left_stick_y + gamepad1.right_stick_x;
    right = -gamepad1.left_stick_y - gamepad1.right_stick_x;
    My question is how do I map all four motors to this basic code.
    All help is useful. Thanks.
    Good luck to all you.

  • #2
    The first question is: are your four wheels anything special? e.g. mecanum wheels, Omni-wheels arranged in diamond formation? In other words, can the robot travel sideways? If not, then it's very simple, make the front wheel the same as the rear wheel.
    Code:
    double drivePower = -gamepad1.left_stick_y;
    double turnPower = gamepad1.right_stick_x;
    double leftPower = Range.clip(drivePower + turnPower, -1.0, 1.0);
    double rightPower = Range.clip(drivePower - turnPower, -1.0, 1.0);
    leftFrontMotor.setPower(leftPower);
    leftRearMotor.setPower(leftPower);
    rightFrontMotor.setPower(rightPower);
    rightRearMotor.setPower(rightPower);

    Comment

    Working...
    X