Recent Changes - Search:

TEAMS Academy Wiki

Explore TEAMS!
for visiting sophomores & juniors

Robotics

EnvBioTech

Bat Design

Assistive Tech


Students


Instructors

TEAMS Forum

TEAMS Calendar

TEAMS Web Site

Wiki Info

edit Student.SideBar

RuggWimp

/* Add comment

 	- Allison Rugg
	- cohort
	- assignment
	- date
	- and overview here 
  • /

// Include the Command Module API

  1. include "create.h"
  2. define safe (!cr8->wheeldrop_right && !cr8->wheeldrop_left && !cr8->wheeldrop_caster)

// Pointer to the Sensor Data structure cr8_t *cr8;

// Declare any new function prototypes here: // For example: int dashboard(int counter, char partnumber);

// Declare GLOBAL constants used in program:

// Declare GLOBAL Variables used in program:

// Initialize GLOBAL Variables used in program:

// Declaraion for function "main" int main(void) {

  // Allocate memory for sensor data structure
	cr8 = cr8_alloc();

  /* Initialize the Create and Command Module
     Sync communications settings.     */

	cr8_init(cr8);

  // Declare LOCAL constants used in function main:

  	// For example:  const int Pi100 = 314; 

  // Declare LOCAL Variables used in function main:
	int d; 

	int theta; 

	// For example:  int i, j; 				

  // Initialize LOCAL Variables used in function main:
	d = cr8->dist_mm; 

	theta = 0; 

  /*

   write code for main here!

  */ 

cr8_stopwatch_start();

while((cr8_stopwatch_time()<=300))

	{ 
	cr8_drive_direct(0,0);

	while(safe !cr8->button_play)//wait for play to be pressed 

		{
		if (cr8_stopwatch_time()%2)
			{
			cr8_set_leds(1,0,100,255);
			}
		else		
			{
			cr8_set_leds(0,0,100,255);
			}

			cr8_update(cr8);
		}

	while(safe && (cr8_stopwatch_time()<=300))//set 30-second time limit 

		{
		cr8->dist_m = 0;
		cr8->dist_mm = 0;

		cr8_stopwatch_time();

		cr8_update(cr8);

		lcd_print_4vars(cr8->dist_m, cr8->dist_mm, 0, 0, 0, 0);//show distance travelled

		d = cr8->dist_mm + (cr8->dist_mm * 1000);


		while(safe && (cr8_stopwatch_time()<=300) && cr8->dist_mm + (cr8->dist_mm * 1000) <= d)//if robot is moved
			{
			cr8_update(cr8);
			}

		d = (cr8->dist_mm + (cr8->dist_m * 1000) + 1219);	

		while(safe && (cr8_stopwatch_time()<=300) && ((cr8->dist_mm + (cr8->dist_m * 1000))<=d))//drive 4 feet
			{
			cr8_drive_direct(250,250);
			cr8_update(cr8);
			lcd_print_4vars(cr8->dist_m, cr8->dist_mm, cr8->angle, 0, 0, 0);//show distance travelled

			if(cr8->bumper_right)//if bumper is pressed while 'escaping'
				{
				theta = (cr8->angle + (cr8->revolutions * 360) + 180);

				while(safe && (cr8_stopwatch_time()<=300) && ((cr8->angle	+ cr8->revolutions*360) <= theta))
					{
					cr8_drive_direct(250,0);
					cr8_update(cr8);
					cr8_delay(100);
					d=(cr8->dist_mm + (cr8->dist_m * 1000) + 1219);
					lcd_print_4vars(cr8->dist_m, cr8->dist_mm, cr8->angle, 0, 0, 0);//show distance travelled

					}
				}	

			if(cr8->bumper_left)
				{
				theta = (cr8->angle + (cr8->revolutions*360) + 180);

				while(safe && (cr8_stopwatch_time()<=300) && ((cr8->angle	+ cr8->revolutions*360) <= theta))
					{
					cr8_drive_direct(0,250);
					cr8_update(cr8);
					cr8_delay(100);
					d=(cr8->dist_mm + (cr8->dist_m * 1000) + 1219);
					lcd_print_4vars(cr8->dist_m, cr8->dist_mm, cr8->angle, 0, 0, 0);						
					}
				}
			}
			cr8_update(cr8);	
		}

	if(!safe) cr8_beep_error;	

	while(!safe)
		{
		cr8_drive_direct(0,0);	
		cr8_update(cr8);
		} 
	}
  cr8_free(cr8);
  return(0);

} // End of function main

/* Declare other functions you create here...

For example, to define function xxxxx of type integer (int)

with two input parameters, sample_num and code...

int xxxxx(int sample_num, char code) {

	// Declare LOCAL constants used in function xxxxx: 


	// Declare LOCAL Variables used in function xxxxx: 

	// Initialize LOCAL Variables ised in function xxxxx: 

	// Write code for function XXXXX here:




  //Return int value for function xxxxx: 
  return(1);      You must always return a value to sending program
			--in this case a 1 to indicate fn done with no problems.

} // End of function xxxxx

  • /
Edit - History - Print - Recent Changes - Search
Page last modified on March 13, 2009, at 04:36 PM