A picture of our square-bot that would attempt to navigate its way through the tile maze
**Note the wheel encoders
A video of another group's run (immediately after ours).
I'll post a video of our run later, because my phone decided not to save the video I took.
RobotC Maze Code
#pragma config(Sensor, in2, rightEncoder, sensorRotation)
#pragma config(Sensor, in3, leftEncoder, sensorRotation)
#pragma config(Motor, port2, LEFT, tmotorNormal, openLoop)
#pragma config(Motor, port3, RIGHT, tmotorNormal, openLoop, reversed)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
#define square 124
#define fleft 65
#define fright 63
#define rleft -63
#define rright -61
void turnLeft( int turnTicks ){
SensorValue[rightEncoder] = 0;
SensorValue[leftEncoder] = 0;
motor[LEFT] = rleft; //left
motor[RIGHT] = fright;
while (SensorValue[rightEncoder] < turnTicks);
motor[LEFT] = 0;
motor[RIGHT] = 0;
int RightTurns = SensorValue[rightEncoder];
int LeftTurns = SensorValue[leftEncoder];
}
void turnRight( int turnTicks ){
SensorValue[rightEncoder] = 0;
SensorValue[leftEncoder] = 0;
motor[LEFT] = fleft; //right
motor[RIGHT] = rright;
while (SensorValue[rightEncoder] < turnTicks);
motor[LEFT] = 0;
motor[RIGHT] = 0;
int RightTurns = SensorValue[rightEncoder];
int LeftTurns = SensorValue[leftEncoder];
}
void goForward( int goticks ){
SensorValue[rightEncoder] = 0;
SensorValue[leftEncoder] = 0;
motor[LEFT] = fleft; //foward
motor[RIGHT] = fright;
while (SensorValue[rightEncoder] < goticks);
motor[LEFT] = 0;
motor[RIGHT] = 0;
int RightTurns = SensorValue[rightEncoder];
int LeftTurns = SensorValue[leftEncoder];
}
task main( )
{
goForward( square*4.5 );
wait1Msec(200);
turnLeft( 99 );
wait10Msec(20);
goForward(square*2);
wait10Msec(20);
turnLeft(99);
wait10Msec(20);
goForward(square*4);
wait10Msec(20);
turnRight(99);
wait10Msec(20);
goForward(square*2);
wait10Msec(20);
turnRight(99);
wait10Msec(20);
goForward(square*6);
wait10Msec(20);
turnRight(99);
goForward(square*4);
turnRight(99);
turnLeft(45);
turnRight(140);
turnLeft(500);
}
No comments:
Post a Comment