Robot programming challenge (10)

Mission Brief

This paper is about the sensor in the virtual world challenge pack
"Arm Position Challenge", as shown in Figure 1. It is required to start from starting point A and advance to the box,
Then grab the box with the front paw and return to the starting point



Figure 1 arm position challenge interface

The robot used in this challenge is "clawbot IQ arm up", and the basic configuration is shown in Figure 2



Figure 2 basic configuration of robot

program

#pragma config(StandardModel, "Clawbot IQ With Sensors")
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

task main()
{
    /*  */
    short touched = false;
    const float speed = 100;

    /*   */
    while(true){
        // starts to go forward
        setMotorSpeed(leftMotor, speed);
        setMotorSpeed(rightMotor, speed);

        //
        if(getBumperValue(bumpSwitch) == 1){
            touched = true;

            //backward a litte
            setMotorSpeed(leftMotor, -speed);
            setMotorSpeed(rightMotor, -speed);
            sleep(300);

            //
            stopAllMotors();

            // strech claw
            setMotorTarget(clawMotor, -10, speed);
            waitUntilMotorStop(clawMotor);

            // get down the arm
            setMotorTarget(armMotor, -280, speed);
            waitUntilMotorStop(armMotor);

            // grab the block
            setMotorTarget(clawMotor, 5, speed);
            waitUntilMotorStop(clawMotor);

            // get up the arm
          setMotorTarget(armMotor, 280, speed);
            waitUntilMotorStop(armMotor);

            // backword
            setMotorTarget(leftMotor, 0, speed);
            setMotorTarget(rightMotor, 0, speed);
            waitUntilMotorStop(leftMotor);
            waitUntilMotorStop(rightMotor);
            break;
        }
    }
}

Figure 3 middle screenshot of robot running



Figure 3 middle screenshot of operation

The operation result is shown in Figure 4



Figure 4 operation results

Posted on Thu, 19 Mar 2020 14:24:07 -0400 by brad_fears