jessprogramminginc

 

Botball

Page history last edited by Jes Stayton 1 yr ago

Botball

 

Go to..

DHS Botball

http://dhsbotball.pbwiki.com/

 

Various Tutorials

 

Manuals

 

http://handyboard.com/software/icmanual/icmain.html

 

http://www.owlnet.rice.edu/~elec201/Book/icmanual.html

 

http://teams.kipr.org/2007/07-0026/public/ictutorial.htm

 

http://robotics.nasa.gov/courses/summer06/

 

http://handyboard.com/software/icmanual/node1.html

 

http://www.kipr.org/papers/xbc-iros05.pdf

 

Random Stuff

 

Links to information on the DHS Botball wikihttp://dhsbotball.pbwiki.com/InteractiveC

 

Links to information on the Botball websitehttp://www.botball.org/educational-resources/ic_manuals.php

 

programs by D. Millerhttp://i-borg.engr.ou.edu/~dmiller/create/

 

botball home site http://www.botball.org/

 

download roomba manual http://www.irobot.com/sp.cfm?pageid=29

 

Information on XBC camerahttp://www.acroname.com/robotics/info/ideas/cmucamhb/cmucamhb.html

 

IC Manual (accessible from the Help in IC)

 

Downloading and running the program on the XBC

Make sure your XBC is turned on and the serial port is plugged

in.

Click the “Download” icon on the IC menu bar. Program should

download.

Look at the XBC screen. The first menu item should be “Run

Hello

IC.exe”

Use the arrow keys to highlight the first menu selection. Press

the “A” key to run the program.

Display should clear and should print “Hello XBC!!” followed

by “Goodbye XBC!!” four seconds later.

 

Code

 

beep(xbc)

void main()

{

beep();

}

 

beepifcolor(xbc)

#use "xbccamlib.ic"

void main()

{

int x_val;//enters x and y coordinates of the color

int y_val;

int col_mod=0;//change this number to the color you want

while (b_button()==0)//Press the B button to exit

{

track_update();//updates image

x_val=track_x(col_mod,0);

y_val=track_y(col_mod, 0);

if (x==0 y==0)

{

beep();

}

 

else(x<0, y<0)

{

beep();

beep();

}

 

}

 

 

color tracking(xbc)

#use "xbccamlib.ic"

void main()

{

int x_val;//enters x and y coordinates of the color

int y_val;

int col_mod=0;//change this number(0) to the color you want

while (b_button()==0)//Press the B button to exit

{

track_update();//updates image

x_val=track_x(col_mod,0);

y_val=track_y(col_mod, 0);

display_clear();

printf("the x value is %d\n",x_val);//prints color coordinates

printf("the y value is %\n",y_val);

sleep(0.3);//keeps the screen readable

}

}

 

say hi(xbc)

void main()

{

printf ("Hi\n");

}

 

beep once for red, twice for green(xbc)

#use "xbccamlib.ic"

void main()

{

int col_mod;

while (b_button()==0)//Press the B button to exit

{

track_update();//updates image

if (col_mod=1)

{

beep();

}

if (col_mod=2)

{

beep();

beep();

}

 

else

{

beep();

beep();

beep();

}

}

}

 

go forward if light is on(xbc)

#include "botball.ic"

/* Botball.ic includes the functions: wait_for_light(int port)

and shut_down_in(float seconds)*/

void main()

{

wait_for_light(6); //light sensor in port 6

shut_down_in(1.9); //kill the robot after 1.9 seconds

my_botball_program();//call the function that does everything

 

}

void my_botball_program()

{

// while (b_button()==0)//while the light is on... {

fd(2);//make motor 2 go forward-

fd(1);//and motor 1-0 doesn't work

}

servo move(xbc)

void main()

{}

int servo_rad(float angle 45.0)

{}

void servo_on()

{}

void servo_off();

{}

 

go to the shelter and knock away cups(roomba create)

//(not my program)

#include "createlib.ic"

void main()

{

create_connect(); //creates connection

create_drive_straight(300); //Drives roomba forward

sleep(2.0); //stops driving straight after 2 sec.

create_spin_CCW(300); //Spin about 90 degrees

sleep(0.615); //stops spinning after 3 sec.

create_drive_straight(500);//goes straight into the Shelter

sleep(4.4); //Stops in the shelter after 2 seconds

create_spin_CW(1000); //Spins in place to kncok away cups

sleep(10.0); //stops spinning after 10 seconds

create_disconnect(); //disconnects the connection

}

 

go to the color(roomba create)

#use "createlib.ic"

#use "xbccamlib.ic"

/* This program causes the create to spin in place until it sees an object matching the color in color

model 0. It then chases that object until it runs into it,and stops

written by D. Miller 4/07 modified by me*/

void main()

{

int tx, lspeed, rspeed;//tx is the coordinate of the centroid of the tracked object; if tx=174, object is centered

init_camera(); // start up xbc camera system

create_connect(); // start up communication with the create

display_clear(); // clear display

while(!b_button()){// keep up the chase until the B button on the XBC is pressed

//printf("The chase is a foot!\n");

while(!b_button()){

track_update(); // get a new image into the xbc

create_sensor_update(); // get a new set of sensor values from the create

if(gc_lbump | gc_rbump gc_ldrop gc_rdrop // these are all globals set by create_sensor_update().

gc_fdrop gc_rcliff gc_rfcliff gc_lcliff gc_lfcliff)

{

//printf("Tag!!!!!\n"); // if sensor detects obstacle, give the tagee a chance to escape

create_drive(0,1); // stop any movement

break; // and jump out of the while loop

}

if (track_count(0)>0) { //if no obstacles, are there any blobs on channel 0?

tx=track_x(0,0); //if so, get the x coordinate of the centroid

rspeed = 250 + (174-tx)/2;//250 is default speed but if tx is off to right, right wheel slows

lspeed = 250 + (tx-174)/2;//and if tx is off to left, right wheel speeds up while left slows down

create_drive_direct(rspeed,lspeed);

}

else create_spin_CW(100); // if no obstacle and no colored object, spin until something appears

}

//gc_total_angle=0; // reset the Create's turn angle to 0

//while(gc_total_angle<180 && b_button()==0){ // this loop spins the robot CCW until the robot has turned 180 degrees

create_spin_CCW(150);

create_sensor_update(); // this will update the global gc_angle (among others)

}

gc_distance=0; // now that the robot is facing backwards, reset distance counter to 0

create_drive_straight(300); //drive forward at 300mm/sec

while(gc_distance < 100){ // this loop terminates normally when the robot has moved 100mm

create_sensor_update(); // update gc_distance and other sensor globals

if(gc_lbump gc_rbump gc_ldrop gc_rdrop //if an obstacle...

gc_fdrop gc_rcliff gc_rfcliff gc_lcliff gc_lfcliff | b_button())

{

create_drive(0,1); //...stop the robot

//printf("Dangerous terrain!\n"); //print out message that there was an unexpected obstacle

break;//get out of the while loop

}

}

create_drive(0,1);//stop the robot

}

// printf("The Chase has been canceled\n");

create_disconnect_s(); //return XBC serial port to talking with PC instead of robot.

//if the disconnect is not done, then the GBA has to be rebooted before the PC can talk with the XBC.

}

 

90 degree turn(xbc)

void main()

{

fd(1);

bk(2);

sleep(0.475);

fd(1);

fd(2);

sleep(5.0);

bk(1);

fd(2);

sleep(0.475);

fd(1);

fd(2);

sleep(5.0);

 

}

 

go forward then back(xbc)

void main()

{

fd (8);

sleep (2.0);

bk (8);

}

 

chase color(roomba create)

#use "createlib.ic"

#use "xbccamlib.ic"

/* This program causes the create to spin in place until it sees an object matching the color in color

model 0. It then chases that object until it runs into it, at which point it spins 180

goes a few inches and then resumes the search and chase

written by D. Miller 4/07

*/

void main()

{

int tx, lspeed, rspeed;//tx is the coordinate of the centroid of the tracked object; if tx=174, object is centered

init_camera(); // start up xbc camera system

create_connect(); // start up communication with the create

display_clear(); // clear display

while(!b_button()){// keep up the chase until the B button on the XBC is pressed

printf("The chase is a foot!\n");

while(!b_button()){

track_update(); // get a new image into the xbc

create_sensor_update(); // get a new set of sensor values from the create

if(gc_lbump | gc_rbump gc_ldrop gc_rdrop // these are all globals set by create_sensor_update().

gc_fdrop gc_rcliff gc_rfcliff gc_lcliff gc_lfcliff)

{

printf("Tag!!!!!\n"); // if sensor detects obstacle, give the tagee a chance to escape

create_drive(0,1); // stop any movement

break; // and jump out of the while loop

}

if (track_count(0)>0) { //if no obstacles, are there any blobs on channel 0?

tx=track_x(0,0); //if so, get the x coordinate of the centroid

rspeed = 250 + (174-tx)/2;//250 is default speed but if tx is off to right, right wheel slows

lspeed = 250 + (tx-174)/2;//and if tx is off to left, right wheel speeds up while left slows down

create_drive_direct(rspeed,lspeed);

}

else create_spin_CW(100); // if no obstacle and no colored object, spin until something appears

}

gc_total_angle=0; // reset the Create's turn angle to 0

while(gc_total_angle<180 && b_button()==0){ // this loop spins the robot CCW until the robot has turned 180 degrees

create_spin_CCW(150);

create_sensor_update(); // this will update the global gc_angle (among others)

}

gc_distance=0; // now that the robot is facing backwards, reset distance counter to 0

create_drive_straight(300); //drive forward at 300mm/sec

while(gc_distance < 100){ // this loop terminates normally when the robot has moved 100mm

create_sensor_update(); // update gc_distance and other sensor globals

if(gc_lbump gc_rbump gc_ldrop gc_rdrop //if an obstacle...

gc_fdrop gc_rcliff gc_rfcliff gc_lcliff gc_lfcliff | b_button())

{

create_drive(0,1); //...stop the robot

printf("Dangerous terrain!\n"); //print out message that there was an unexpected obstacle

break;//get out of the while loop

}

}

create_drive(0,1);//stop the robot

}

printf("The Chase has been canceled\n");

create_disconnect_s(); //return XBC serial port to talking with PC instead of robot.

//if the disconnect is not done, then the GBA has to be rebooted before the PC can talk with the XBC.

}

 

Drive to shelter(xbc)

void main()

{

fd(1);

fd(2);

sleep(1.7); //drive out of box

beep();

fd(1);

bk(2);

sleep(1.0);

beep();

fd(1);

fd(2);

sleep(4.0);

beep();

fd(1);

fd(2);

sleep(2.0);

beep();

off(1);

off(2);

}

 

go forward when light is on(xbc)

#include "botball.ic"

/* Botball.ic includes the functions: wait_for_light(int port)

 

and shut_down_in(float seconds)*/

 

void main()

{

 

wait_for_light(6); //light sensor in port 6

 

shut_down_in(119.9); //kill the robot after 1.9 seconds

 

my_botball_program();//call the function that does everything

 

}

void my_botball_program()

{

 

// while (b_button()==0)//while the light is on... {

 

motor(1, 100);

motor(2, 100);

sleep(2.0);

motor(1, 100);

motor(2, -100);

 

 

}

 

Park in greenhouse(xbc)

void main()

{

fd(1);

fd(2);

sleep(1.7); //drive out of box

beep();

fd(1);

bk(2);

sleep(1.2); //turn left

 

beep();

fd(1);

fd(2);

sleep(2.1); //drive straight towards shelter

beep();

 

fd(1);

bk(2);

sleep(1.5); //turn left towards bridge

 

fd(1);

fd(2);

sleep(1.7); //drive straight towards bridge, knock it over

beep();

 

bk(1);

// fd(2);

sleep(1.0); //turn while backingback up a bit

 

bk(1);

fd(2);

sleep(0.7); //point to solarium

 

bk(1);

bk(2);

sleep(0.2); //back up

 

beep();

beep();

off(1);

off(2);

}

 

Drive to shelter(xbc)

void main()

{

fd(1);

fd(2);

sleep(1.7); //drive out of box

beep();

fd(1);

bk(2);

sleep(0.9); //turn left

 

beep();

fd(1);

fd(2);

sleep(4.0); //drive straight to shelter

beep();

fd(1);

fd(2);

sleep(1.9);

beep();

off(1);

off(2);

}

 

Reflection Questions

What was the most interesting aspect of the Botball project?

I think the most interesting part of the Botball project was the programming itself, and the wealth of information that is available online. What does what in programming is very interesting, and I enjoyed learning about programming and the many databases available on interactive c.

What was the most difficult aspect of the Botball project?

The most difficult aspect of the Botball project was also the programming. Many aspects of the programming are confusing, and it is especially hard because if you get a single little detail wrong then the program doesn't compile right. Sometimes you don't even know what is wrong. Also, many tutorials and databases use terms and vocabulary that I do not understand.

What was the effect of your classmates on your efforts in the project?

My classmates made want to work harder on the project because many of them didn't do much, which made me want to do more. If everyone helped and participated in class, I probably wouldn't have done as much because I'm not very good at programming in general, and would have felt that the programming was best left up to the people who were good at it, and i should probably do rules or the like.

What kept you from being able to do more on the project?

Lack of time was mostly what kept me from doing more on the project because I am very busy after school most days and there wasn't much time in class. My parents also do not like me staying after school very late. Another thing that kept me from doing more on the project was my lack of programming expertise. I would have gotten a lot more done if I hadn't had to stop and spend hours looking things up.

What could you have done to make the project more successful?

I could have made the project more successful by staying after school more than I did, and going to the Botball competition. I also could have recruited people to go to the Botball competion.

Comments (0)

You don't have permission to comment on this page.