Ejemplo n.º 1
0
task main()
{
	waitForStart();

	initializeRobot();



	// The amount of time the robot...

	// ...moves forward at an angle.
	const int forwardTimeA	= 150;
	// ...turns to line up perpendicular to the center rack.
	const int turnTimeB		= 40;
	// ...drives up to the peg before lifting the lift up.
	const int forwardTimeC	= 155;
	// ...lifts the claw to put a ring on (row 2).
	const int liftTimeF		= 79;
	// ...moves forward, putting the ring onto the peg.
	const int forwardTimeG	= 65;
	// ...lowers its lift to get rid of the ring.
	const int liftTimeH		= 55;
	// ...backs up and gets ready to go to a dispenser.
	const int backwardTimeI	= 300;

	// ...turns to face parallel to the walls.
	const int turnTimeJ		= 40;
	// ...moves forward to align itself with a dispenser.
	const int forwardTimeK	= 100;
	// ...turns to face the dispenser.
	const int turnTimeL		= 80;
	// ...moves forward to be under the dispenser.
	const int forwardTimeM	= 50;


	Move_Forward	(forwardTimeA, g_AccurateMotorPower);
	Turn_Left		(turnTimeB, g_AccurateMotorPower, g_AccurateMotorPower);
	Move_Forward	(forwardTimeC, g_AccurateMotorPower);
	Lift_Lift		(liftTimeF, g_AccurateMotorPower);
	Move_Forward	(forwardTimeG, g_AccurateMotorPower);

	// Lift power is negative so that the lift goes DOWN, not UP.
	Lift_Lift		(liftTimeH, (-1) * g_AccurateMotorPower);
	Move_Backward	(backwardTimeI, g_AccurateMotorPower);

	// Turn power doesn't need to be negative (turns in-place).
	Turn_Left		(turnTimeJ, g_AccurateMotorPower, g_AccurateMotorPower);
	Move_Forward	(forwardTimeK, g_AccurateMotorPower);
	Turn_Left		(turnTimeL, g_AccurateMotorPower, g_AccurateMotorPower);
	Move_Forward	(forwardTimeM, g_AccurateMotorPower);


	while (true)
	{
		PlaySoundFile("moo.rso");
		while(bSoundActive == true)
		{
			Time_Wait(1);
		}
	}



}
Ejemplo n.º 2
0
task main()
{
    // The IR signal strengh in all 5 directions.
    int IRdirA = 0;
    int IRdirB = 0;
    int IRdirC = 0;
    int IRdirD = 0;
    int IRdirE = 0;



    waitForStart();

    initializeRobot();



    // The amount of time the robot...
    const int forwardTimeAA	= 25;
    const int turnTimeA 	= 50;

    const int forwardTimeA 	= 170;
    const int turnTimeB 	= 110;
    const int forwardTimeB 	= 100;
    const int liftTimeB 	= 45;

    const int forwardTimeCA	= 110;	//TODO
    const int forwardTimeCB = 40;	//TODO
    const int turnTimeD 	= 152;
    const int forwardTimeD 	= 110;
    const int liftTimeD 	= 135;

    const int forwardTimeE 	= 95;	//TODO
    const int turnTimeF 	= 112;
    const int forwardTimeF 	= 80;
    const int liftTimeF 	= 47;

    const int liftTimeG		= 30;	//TODO
    const int backwardTimeG	= 100;	//TODO
    const int turnTimeG		= 70;	//TODO
    const int forwardTimeG	= 20;	//TODO

    const int liftTimeH		= 50;	//TODO
    const int backwardTimeH	= 90;	//TODO
    const int turnTimeH		= 100;	//TODO
    const int forwardTimeH	= 70;	//TODO

    const int liftTimeI		= 30;	//TODO
    const int backwardTimeI	= 130;	//TODO
    const int turnTimeI		= 70;	//TODO
    const int forwardTimeI	= 170;	//TODO

    const int forwardTimeJ	= 50;	//TODO
    const int turnTimeK		= 90;	//TODO
    const int liftTimeK		= 30;	//TODO
    const int forwardTimeK	= 50;	//TODO



    Move_Forward	(forwardTimeAA, g_AccurateMotorPower);
    Turn_Left		(turnTimeA, g_AccurateMotorPower, g_AccurateMotorPower);
    Move_Forward	(forwardTimeA, g_AccurateMotorPower);

    Time_Wait(50);
    HTIRS2readAllDCStrength(infrared, IRdirA, IRdirB, IRdirC, IRdirD, IRdirE);

    if ( (IRdirA+IRdirB+IRdirC+IRdirD+IRdirE) > g_IRthreshold )
    {
        Turn_Right		(turnTimeB, g_AccurateMotorPower, g_AccurateMotorPower);
        Lift_Up			(liftTimeB, g_AccurateMotorPower);
        Move_Forward	(forwardTimeB, g_AccurateMotorPower);

        Lift_Down		(liftTimeG, g_AccurateMotorPower);
        Move_Backward	(backwardTimeG, g_AccurateMotorPower);
        Turn_Right		(turnTimeG, g_AccurateMotorPower, g_AccurateMotorPower);

        Move_Forward	(forwardTimeG, g_AccurateMotorPower);
    }
    else
    {
        Move_Forward	(forwardTimeCA, g_AccurateMotorPower);
        Time_Wait(50);
        HTIRS2readAllACStrength(infrared, IRdirA, IRdirB, IRdirC, IRdirD, IRdirE);
        Move_Forward	(forwardTimeCB, g_AccurateMotorPower);

        if ( (IRdirA+IRdirB+IRdirC+IRdirD+IRdirE) > g_IRthreshold )
        {
            Turn_Right		(turnTimeD, g_AccurateMotorPower, g_AccurateMotorPower);
            Lift_Up			(liftTimeD, g_AccurateMotorPower);
            Move_Forward	(forwardTimeD, g_AccurateMotorPower);

            Lift_Down		(liftTimeH, g_AccurateMotorPower);
            Move_Backward	(backwardTimeH, g_AccurateMotorPower);
            Turn_Right		(turnTimeH, g_AccurateMotorPower, g_AccurateMotorPower);

            Move_Forward	(forwardTimeH, g_AccurateMotorPower);
        }
        else
        {
            Move_Forward	(forwardTimeE, g_AccurateMotorPower);

            Turn_Right		(turnTimeF, g_AccurateMotorPower, g_AccurateMotorPower);
            Lift_Up			(liftTimeF, g_AccurateMotorPower);
            Move_Forward	(forwardTimeF, g_AccurateMotorPower);

            Lift_Down		(liftTimeI, g_AccurateMotorPower);
            Move_Backward	(backwardTimeI, g_AccurateMotorPower);
            Turn_Right		(turnTimeI, g_AccurateMotorPower, g_AccurateMotorPower);

            Move_Forward	(forwardTimeI, g_AccurateMotorPower);
        }
    }
    Move_Forward	(forwardTimeJ, g_AccurateMotorPower);
    Turn_Right		(turnTimeK, g_AccurateMotorPower, g_AccurateMotorPower);
    Lift_Up			(liftTimeK, g_AccurateMotorPower);
    Move_Forward	(forwardTimeK, g_AccurateMotorPower);



    while (true)
    {
        PlaySoundFile("moo.rso");
        while(bSoundActive == true)
        {
            Time_Wait(1);
        }
    }
}