Announcement

Collapse
No announcement yet.

help with setMotorTarget command in RobotC

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

  • help with setMotorTarget command in RobotC

    Hello all,

    My team has gotten frustrated in trying to perform a simple programming tasks using the setMotorTarget command. The idea is that after a joystick button is pushed to have motors go to a initial position, close a claw, then return to where it came from. The program they wrote is below. In the below, the program goes to the initial “0” point, but then stops. Does anyone see any errors in the approach? Any help would be appreciated. Thanks.

    if(getJoystickValue(BtnEDown) == 1)

    {
    // Determine current position of motors
    int ipoint= getMotorEncoder(point);
    int ilarm= getMotorEncoder(leftArm);
    int irarm= getMotorEncoder(rightArm);
    //
    // Move motors back to start point
    //
    setMotorTarget(point, 0, -50);
    setMotorTarget(leftArm,0, 50);
    setMotorTarget(rightArm,0, 50);
    //
    //close claw
    setMotorSpeed(claw, -50);
    wait(125, milliseconds);
    //
    //go back to where you started from
    //
    setMotorTarget(point, ipoint, 50);
    setMotorTarget(leftArm, ilarm, -50);
    setMotorTarget(rightArm, irarm, -50);
    }


  • #2
    You need time for the setMotorTargets to finish. A wait until motor-zero-velocity == true (something like that) will allow the motion to finish.

    Comment

    Working...
    X