Following the black line with a Rover.

12 replies [Last post]
Precision
Title: MiniBot
Joined: 06/21/2011
Posts:
BotPoints: 29
User offline. Last seen 7 years 22 weeks ago.

Posting our conversation as requested.

alright well, i'm copying your black line example and trying to plugin the parts i need to myself.

#define RightRM 1
#define LeftRM 3
#define LEFTSERVO 3
#define RIGHTSERVO 0
float distance;
float rotation;
#define TpC 41.23//re-configure values based on wheel size
#define TpD 14.9694//re-configure values based on wheel size

void Lift_Basket_half()//Lift basket .5 way up
{
set_servo_position(LEFTSERVO,2047);
set_servo_position(RIGHTSERVO,0);
}

void Lift_Basket_all()//Lift basket 100% way up
{
set_servo_position(LEFTSERVO,2047);
set_servo_position(RIGHTSERVO,0);
}

void Basket_down()// move basket down
{
set_servo_position(LEFTSERVO,2047);
set_servo_position(RIGHTSERVO,2047);
}

void Dump_balls() //dump balls into tower
{
int i = 0;

for(i = 0; i < 600; i+= 10)
{
set_servo_position(LEFTSERVO,i);
set_servo_position(RIGHTSERVO,i);
msleep(250); //quarter second sleep
}
}

void MoveFwd(int speed, float centimeters)//move forward distance
{
distance = centimeters * TpC;

mrp(RightRM,speed,(long)distance);
mrp(LeftRM,speed,(long)distance);
bmd(RightRM);
bmd(LeftRM);
}

void MoveBack(int speed, float centimeters)//move backward distance
{
distance = centimeters * TpC;
mrp(RightRM,speed,-(long)distance);
mrp(LeftRM,speed,-(long)distance);
bmd(RightRM);
bmd(LeftRM);
}

void RightTurn(int speed, float deg)//right turn by degree
{
rotation = deg * TpD;
mrp(RightRM,speed,(long)rotation);
mrp(LeftRM,speed,-(long)rotation);
bmd(RightRM);
bmd(LeftRM);
}

void touch_s()
{
while(1){
bk(1);
bk(3);
if(digital(14)){
Dump_balls();
sleep(3);
ao();}
break;
}
}

void rotateRight(int speed, int ticks)
{
resetEncoders();
value = SensorRaw[lightSensor];
while((rightMotorEncoderTicks > -ticks) && (value > notBlackLine))
{
value = SensorRaw[lightSensor];
mav(rightMotor, -1000);
mav(leftMotor,1000);
}
}

void rotateLeft(int speed, int ticks)
{
resetEncoders();
value = SensorRaw[lightSensor]; //again with value undeclared and SensorRaw and LightSensor.
while((leftMotorEncoderTicks > -ticks) && (value > notBlackLine))
{
value = SensorRaw[lightSensor];
mav(rightMotor, 1000); // RightMotor and LeftMotor undefined, i know i need to make a sub program for each motor, but i don't know how without having to give it a set distance to cover.
mav(leftMotor,-1000);
}
}

void LeftTurn(int speed, float deg)//left turn by degree
{
rotation = deg * TpD;

mrp(RightRM,speed,-(long)rotation);
mrp(LeftRM,speed,(long)rotation);
bmd(RightRM);
bmd(LeftRM);
}

void black_line ()
{
float i;
while(1)

{
value = SensorRaw[analog10(2)]; //the complie doesn't understand what SensorRaw is, i don't know what it is eaither, so i can't make a void for it. also "value" is undeclared
fd(1);
fd(3);
i = 5.0;
while(analog10(2)<650) //while not on the line
{
i*=1.5;
rotateLeft(1000,(int)2); //first look left
i*=1.5;
rotateRight(1000,(int)2); // then look right
if(digital(14)){
Dump_balls();
sleep(3);
ao();}
break;
}
}
}

This time i gave you the whole program before the int main.

Delete message

Precision
06/29/2011 - 10:04
all of the errors are just "undefined" errors.

Delete message

Precision
06/29/2011 - 10:31
i did this, and got rid of your rotateright and left sub programs, and stopped calling on them. this complies, about to test it in a second.

void black_line ()
{
float i;
while(1)

{
if(analog10(2)>650) //the complie doesn't understand what SensorRaw is, i don't know what it is eaither, so i can't make a void for it. also "value" is undeclared
fd(1);
fd(3);
i = 5.0;
while(analog10(2)<650) //while not on the line
{
i*=1.5;
RightTurn(1000,10); //first look left
i*=1.5;
LeftTurn(1000,10); // then look right
if(digital(14)){
Dump_balls();
sleep(3);
ao();}
break;
}
}
}

Delete message

wmyers
06/29/2011 - 18:16
Okay? I guess let me know what doesn't work. Also, please continue posting to the discussion board. This could help others.

Block authorDelete message

Precision
06/29/2011 - 18:50
your black line program ended up not working for us, we instead took the idea of yours and embedded it inside our own: The below makes the robot follow the line the way we want to.

void black_line ()
{
float i;
while(1)

{
if(analog10(2)>650)
mav(3,300);
mav(1,-1000);
i = 5.0;
//while(analog10(2)<650) //while not on the line
{
//i*=1.5;
//RightTurn(1000,60); //first look left
//i*=1.5;
//LeftTurn(1000,60); // then look right
while(analog10(2)<650){
mav(3,-1000);
mav(1,300);

while(digital(14))
{
ao();
Dump_balls();

}
}
}
}
}

Delete message

Precision
06/29/2011 - 18:50
as you can see, your part is "//"ed out.

peterseo
peterseo's picture
Title: NooBot
Joined: 08/07/2018
Posts:
BotPoints: 60
User offline. Last seen 18 weeks 3 days ago.

Respecting the time and exertion you put into your site and point by point data you offer!.. General