View Single Post
  #15   Spotlight this post!  
Unread 26-04-2004, 15:53
Mr. Lim Mr. Lim is offline
Registered User
AKA: Mr. Lim
no team
Team Role: Leadership
 
Join Date: Jan 2004
Rookie Year: 1998
Location: Toronto, Ontario
Posts: 1,125
Mr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond repute
Re: Multiple Auton's

Quote:
Originally Posted by Joe Clohessy
I was wondering of a way to do multiple auton modes. Please if you have any proven information let me know either in a PM or Email DragonMan@si.rr.com .


Can someone tell me why this theory wouldnt work ??
Does anyone have an auton mode that has a switch to change between modes that I can look at and pick apart. Thankyou
Joe, your theory should work just fine. We also used switches to customize our autonomous mode. We could use switches to determine which side of the field we started on, what path to drive, and whether to do it in high gear or low gear. It was all configurable on the field, so our autonomous mode selection was a match-time decision, often based on who was lined up opposite from us.

The code is pretty much what you have above, albeit much uglier. This is an earlier copy that wasn't cleaned up.

Cheers!

Code:
void User_Autonomous_Code(void)
{	
	static unsigned int auton_status = 0;
	static unsigned char left_set; // left motor speed set-point
	static unsigned char right_set; // right motor speed set-point
	static unsigned int counter; // used to take snapshot of clock for dead-reckoning moves
	unsigned int pressure;
	
	
  while (autonomous_mode)   /* DO NOT CHANGE! */
  {
    if (statusflag.NEW_SPI_DATA)      /* 26.2ms loop area */
    {
        Getdata(&rxdata);   /* DO NOT DELETE, or you will be stuck here forever! */
		
		relay2_fwd=1; //turns brake off.....

		if (Clock > Old_Clock) // Old_Clock and Clock are serviced by the IR Timer - this line ensures a new IR cycle has occured
		{
			Old_Clock = Clock;
			switch (auton_status)
			{
				case 0: 
					Left_Encoder_Count = 0;
					counter = Clock;
					left_set = 127;
					right_set = 127;
					relay2_fwd = 1;
					if (rc_dig_in10)
					{ 
						relay5_fwd=1;
					}
					else
					{
						relay5_fwd=0;
					}
					auton_status++;
					break;
			
			case 1:

		
		if (rc_dig_in11)

		{ 
			if ((Clock - counter) < 384) //this stops the robot in low gear right in front of the goal
					
					{
						left_set = 255;
						right_set = 225;//fudge factor
					}
				
					else 
					{
						left_set = 127;
						right_set = 127;
					    counter = Clock;
					}
					break;
		}

	
	

		if (rc_dig_in12)
		
		{	
			if ((Clock - counter) < 460) //this makes the robot hit the goal and go straight 3/4 of the way
					{
						left_set = 255;
						right_set = 225;//fudge factor
					}
				
					else 
					{
						left_set = 127;
						right_set = 127;
						counter = Clock;
					}
					break;

		}


		if (rc_dig_in13)

		{
				if ((Clock - counter) < 576) // rush down to the other end of the feild hitting the goal HIGH GEAR
					{
						left_set = 255;
						right_set = 255;
					}
				
					else 
					{
						left_set = 127;
						right_set = 127;
						counter = Clock;
					}
					break;
		}


		if (rc_dig_in14)

		{
				if ((Clock - counter) < 396) //stop beside the mobile goal,
						
						left_set = 225;
						right_set = 225;
					}
				
					else 
					{
						left_set = 127;
						right_set = 127;
					   	counter = Clock;
						auton_status=2;
					}
					break;
				
				case 2:
				
				if ((Clock - counter) < 15) //turn to face right back at you.
					{
						left_set = 0;
						right_set = 255;
					}
				
					else 
					{
						left_set = 127;
						right_set = 127;
					   	counter = Clock;
						auton_status=3;
					}
					break;
			
				case 3:
				
				if ((Clock - counter) < 10) //positions itself behind the goal
					{
						left_set = 255;
						right_set = 225;
					}
				
					else 
					{
						left_set = 127;
						right_set = 127;
						counter = Clock;
						auton_status=4;
					}
					break;

				case 4:
		
				if ((Clock - counter) < 15) //positions itself behind the goal
					{
						left_set = 0;
						right_set = 225;
					}
				
					else 
					{
						left_set = 127;
						right_set = 127;
					    	counter = Clock;
						auton_status=5;
					}
					break;
				
				case 5:
		
				if ((Clock - counter) < 384) //positions itself behind the goal
					{
						left_set = 255;
						right_set = 225;
					}
				
					else 
					{
						left_set = 127;
						right_set = 127;
					    	counter = Clock;
					}
					break;
				
		
		}

		
			}
		}
		
		// Carol's cubic transfer function that desensitizes small movements, but still allows full speed
		temp_p1_y = (signed long)left_set - 128;
	    pwm01 = (unsigned char)(((temp_p1_y * temp_p1_y * temp_p1_y)  >> 14) + 128);
  		temp_p2_y = (signed long)right_set - 128;
  		pwm02 = (unsigned char)(((temp_p2_y * temp_p2_y * temp_p2_y)  >> 14) + 128); 
		
		

// Run compressor
		  pressure = Get_Analog_Value(rc_ana_in16);
		  
		  if (pressure < 800)
		  	relay6_fwd = 1;
		  else if (pressure > 925)
		  	relay6_fwd = 0;

		// Get all 6 drive motors working together		
		pwm03 = pwm01;
  		pwm05 = pwm01;
  		pwm04 = pwm02;
  		pwm06 = pwm02;
        Putdata(&txdata);   /* DO NOT DELETE, or you will get no PWM outputs! */
    }
  }