View Single Post
  #1   Spotlight this post!  
Unread 07-01-2014, 12:22
FTC4211's Avatar
FTC4211 FTC4211 is offline
Registered User
AKA: John Stegeman
FTC #4211 (The Bombers)
Team Role: Programmer
 
Join Date: Jan 2014
Rookie Year: 2010
Location: Missouri
Posts: 11
FTC4211 is an unknown quantity at this point
Re: [FTC]: IR Block for Block Party

If you don't want to mount the IR sensor at an angle, one approach is to wait until the sensor changes state to a certain zone, and then use a set time/encoder distance to get the scoring mechanism to the center of the basket.


The benefits of this approach is that it is easily adjustable for where your block scoring mechanism is, it doesn't require hardware changes to adjust where it scores and it doesn't really matter what orientation/zone you seek the beacon with.

The downside is that the code is slightly more complex and as such could take longer to debug and get working properly.


We use this approach for scoring the block; so here is our code that we used for this. I took out our robot specific commands and just left the framework together to give you a jump start.

Code:
#include "C:\Program Files (x86)\Robomatter Inc\ROBOTC Development Environment\Sample Programs\NXT\3rd Party Sensor Drivers\drivers\hitechnic-irseeker-v2.h";

task main()
{
	time1[T1]=0;
	motor[Left_Drive_Motor]=15;
	motor[Right_Drive_Motor]=15;
	while (time1[T1]<6500) // used to provide a timeout on the drive time along the baskets, adjust if needed
	{
		if (HTIRS2readACDir(IR_Seeker)==2) // adjust the zone for your robot
		{
			motor[Left_Drive_Motor]=0;
			motor[Right_Drive_Motor]=0;
			wait1Msec(350);
			
			motor[Left_Drive_Motor]=-15;// change the power/sign of this to alter the direction the robot goes after finding the zone
			motor[Right_Drive_Motor]=-15;
			
			wait1Msec(500); // adjust this time to change how far robot goes after seeing the zone
			
			motor[Left_Drive_Motor]=0;
			motor[Right_Drive_Motor]=0;
			wait1Msec(350);
			
			// insert code here to dump the block
			
			motor[Left_Drive_Motor]=15; // restart the drive motors to reach the end
			motor[Right_Drive_Motor]=15;
		}
	}
	motor[Left_Drive_Motor]=0;
	motor[Right_Drive_Motor]=0;
	// rest of auto code ...
}

Hope this helps,
Team 4211
Reply With Quote