the robot is not allowed to cross the 2nd thingy.
I was wondering if there was a way to test this on my pc, since we have to hand it in on tuesday, and it'd be nice if it worked
I thought it was possible with windows robotics studio (or something like that) but I downloaded it, and I don't really get how I should be supposed to do that.
so, help would be quite welcome you can test it for me aswell if that's easier, it's not like I want to be able to test it myself, I want to be sure that it works
this is the script I made:
mutex moveMutex;
#define m1 50 //move speed 1 (forward motor 1)
#define m2 55 //move speed 2 (forward motor 2)
#define m3 70 //move speed 3 (turn motor)
#define w1 100 //wait time 1 (forward)
#define w2 900 //wait time 2 (90)
#define w3 1800 //wait time 3 (180)
#define Z 12 // off the line
#define R 4 // red's value
#define G 5 // yellow's value
#define d 7 // distance from robot to object
int r; //number of times robot passed red
int g; //number of times robot passed yellow
task rijden() //standard drive task
{
Acquire(moveMutex);
OnFwd(OUT_A,m1);
OnFwd(OUT_C,m2);
Wait(w1);
Float(OUT_AC);
Release(moveMutex);
}
task lijn() //checks if the robot's still on the line, if not it corrects
{
Acquire(moveMutex);
if (SensorUS(IN_1) == Z)
{
OnFwd(OUT_A,m2);
OnFwd(OUT_c,m1);
Wait(w1);
Float(OUT_AC);
}
Release(moveMutex);
}
task afstand() // checks if there's something in front of the robot
{
Acquire(moveMutex);
if (SensorUS(IN_2) <= d)
{
Off(OUT_AC);
Wait(w1);
}
Release(moveMutex);
}
task kleur() //checks if our robot is on a color
{
if (SensorUS(IN_1) == R)
{
r=r+1;
}
if (SensorUS(IN_1) == G)
{
g=g+1;
}
}
task rood() //does stuff for certain values of red
{
Acquire(moveMutex);
switch®
{
case 2: //turn to the right
OnFwd(OUT_A,m3);
OnRev(OUT_C,m3);
Wait(w2);
Off(OUT_AC);
break;
case 3: //180
OnFwd(OUT_A,m3);
OnRev(OUT_C,m3);
Wait(w3);
Off(OUT_AC);
break;
case 4: //turn left
OnFwd(OUT_C,m3);
OnRev(OUT_A,m3);
Wait(w2);
Off(OUT_AC);
break;
}
Release(moveMutex);
}
task geel() //does stuff for different values of yellow
{
Acquire(moveMutex);
switch(g)
{
case 1: //turns left
case 8:
case 5:
case 6:
OnFwd(OUT_C,m3);
OnRev(OUT_A,m3);
Wait(w2);
Off(OUT_AC);
break;
case 3: //180
OnFwd(OUT_A,m3);
OnRev(OUT_C,m3);
Wait(w3);
Off(OUT_AC);
break;
case 7: //forbidden cross over
OnFwdReg(OUT_AC,m1, OUT_REGMODE_SYNC);
Wait(w1);
Off(OUT_AC);
OnFwd(OUT_A,m3);
OnRev(OUT_C,m3);
Wait(w3);
Off(OUT_AC);
OnFwdReg(OUT_AC,m1, OUT_REGMODE_SYNC);
Wait(w1);
Off(OUT_AC);
break;
}
Release(moveMutex);
}
task main()
{
SetSensorLowspeed(IN_1);
SetSensorUltrasonic(IN_2);
r = 0;
g = 0;
while (r != 5)
{
Precedes(rijden, lijn, afstand, kleur, geel, rood);
}
}