Go to Post I feel that I learned more last year than any previous year because of the challenges we faced. - paldrid [more]
Home
Go Back   Chief Delphi > Other > FIRST Tech Challenge
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
 
Thread Tools Rating: Thread Rating: 17 votes, 5.00 average. Display Modes
  #1   Spotlight this post!  
Unread 06-01-2014, 21:54
TheThings5926 TheThings5926 is offline
Registered User
FTC #5926
 
Join Date: Dec 2012
Location: Minnesota
Posts: 15
TheThings5926 is an unknown quantity at this point
[FTC]: IR Block for Block Party

My team (The Things 5926) are looking at using an IR sensor to drop a block in the basket to score a IR score for the block in autonomous.

What I want to do is drive for a set amount of time, look to see a value from IR sensor, move arm to drop block, all while driving the set mount of time.

I read online that I could tape over the sensor with electrical tape so that I would only get a reading if the sensor is right at the beacon.

Is this idea feasible?


Thanks,

Matt, The Things 5926
Reply With Quote
  #2   Spotlight this post!  
Unread 07-01-2014, 06:28
mfine mfine is offline
Registered User
FTC #6484
 
Join Date: Jan 2014
Location: United States
Posts: 12
mfine will become famous soon enoughmfine will become famous soon enough
Re: [FTC]: IR Block for Block Party

I think what a lot of people are doing is mounting the IR sensor at an angle, so that zone 5 (the smallest) corresponds with being directly in front of the IR beacon.
Reply With Quote
  #3   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
  #4   Spotlight this post!  
Unread 07-01-2014, 16:36
TheThings5926 TheThings5926 is offline
Registered User
FTC #5926
 
Join Date: Dec 2012
Location: Minnesota
Posts: 15
TheThings5926 is an unknown quantity at this point
Re: [FTC]: IR Block for Block Party

Thanks for the help! This will help a lot, this is what I wanted to do, just couldn't quite figure out how to do it.

I am also looking at putting a NXT ultrasonic sensor on the front of the robot. I will use this to keep from getting blocked or hitting our alliance partners robot.

Say the normal program would drive past the baskets, dump block, and then take a 180 degree left turn onto the ramp. This code would run unless the ultrasonic sensor sees something within 20cm. If an object is within 20cm the robot would turn around, and go up the other side of the ramp.

Thoughts?

Thanks,

Matt, The Things 5926
Reply With Quote
  #5   Spotlight this post!  
Unread 07-01-2014, 19:00
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

Hello,

Here is what I have written up for your application. This code contains the section of driving past the baskets and then tries to get on the ramp. It checks both sides for an opponent and if there is one it tries the other side of the ramp.

Adjust the times and powers as needed for your robot. As is it should work decently for a robot with 4" wheels with a 1:1 gear ratio on the drive.

Code:
#pragma config(Hubs,  S1, HTMotor,  HTServo,  none,     none)
#pragma config(Sensor, S2,     IR_Seeker,      sensorI2CCustom)
#pragma config(Sensor, S3,     Sonar,          sensorSONAR)
#pragma config(Motor,  mtr_S1_C1_1,     Right_Drive_Motor, tmotorTetrix, openLoop)
#pragma config(Motor,  mtr_S1_C1_2,     Left_Drive_Motor, tmotorTetrix, openLoop, reversed)
#pragma config(Servo,  srvo_S1_C2_1,    servo1,               tServoNone)
#pragma config(Servo,  srvo_S1_C2_2,    servo2,               tServoNone)
#pragma config(Servo,  srvo_S1_C2_3,    servo3,               tServoNone)
#pragma config(Servo,  srvo_S1_C2_4,    servo4,               tServoNone)
#pragma config(Servo,  srvo_S1_C2_5,    servo5,               tServoNone)
#pragma config(Servo,  srvo_S1_C2_6,    servo6,               tServoNone)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

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

const int AngleTurn_90 = 900; // time for a 90deg angle turn at 50% power (adjust for your robot)
const int AngleTurn_45 = AngleTurn_90/2+AngleTurn_90*0.07; // time for a 45deg angle turn at 50% power (adjust formula for your specific robot)

// Basic movement commands for the robot.  Allows easy modifications to auto
void stopRobot() // stop after each movement/turn to increase accuracy/repeatability
{
	motor[Left_Drive_Motor]=0;
	motor[Right_Drive_Motor]=0;
	wait1Msec(350);
}

void turnLeft(int time,int power = 50)
{
	motor[Left_Drive_Motor]=-power;
	motor[Right_Drive_Motor]=power;
	wait1Msec(time);
	stopRobot();
}

void turnRight(int time,int power = 50)
{
	motor[Left_Drive_Motor]=-power;
	motor[Right_Drive_Motor]=power;
	wait1Msec(time);
	stopRobot();
}

void driveForward(int time, int power = 30)
{
	motor[Left_Drive_Motor]=power;
	motor[Right_Drive_Motor]=power;
	wait1Msec(time);
	stopRobot();
}

void driveBackward(int time, int power = 30)
{
	motor[Left_Drive_Motor]=-power;
	motor[Right_Drive_Motor]=-power;
	wait1Msec(time);
	stopRobot();
}
// End of basic movement commands for the robot.

bool pathBlocked(int dist = 25) // returns if object in front of robot
{
	return (SensorValue[Sonar]==-1) ? false : (SensorValue[Sonar]<dist); // -1 is if can't see anything so ignore that condition and <25 b/c of reflection errors
}

void initRobot()
{
	SensorType[Sonar]=sensorSONAR;
	HTIRS2setDSPMode(IR_Seeker, DSP_1200);
	// rest of initialization for servos etc...
}

task main()
{
	initRobot();
	
	waitForStart();
	
	time1[T1]=0;
	motor[Left_Drive_Motor]=15;
	motor[Right_Drive_Motor]=15;
	while (time1[T1]<7200) // 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
		{
			stopRobot();
			driveForward(500, -15); // adjust this time to change how far robot goes after seeing the zone and change the power/sign of this to alter the direction the robot goes after finding the zone
			// 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;
	
	// get around end of baskets (more reliable than two 90deg turns)
	turnLeft(AngleTurn_45);
	driveForward(700);
	turnLeft(AngleTurn_45);
	
	driveForward(1500); // drive infront of first spot on the ramp (adjust time if needed)
	
	
	// if sonar points straight infront of robot:
	turnLeft(AngleTurn_90);
	
	if (pathBlocked(50)) // if robot is in the way (dist is 50 b/c want to ensure no robot even if there are reflection problems off their robot)
	{
		turnRight(AngleTurn_90);
		driveForward(850); // drive infront of the next spot on the ramp (adjust time if needed)
		turnLeft(AngleTurn_90);
		if (pathBlocked(50)) // if robot is in the way (dist is 50 b/c want to ensure no robot even if there are reflection problems off their robot)
		{
			driveForward(1350, 100); // try to push them out of the way and get on ramp (might want something else)
		}
		else // drive up on the ramp
		{
			driveForward(1350);
		}
	}
	else // drive up on the ramp
	{
		driveForward(1350);
	}
	// end of section for if sonar points striaght ahead
	
	// if sonar points off the side of the robot
	if (pathBlocked(50)) // if robot is in the way (dist is 50 b/c want to ensure no robot even if there are reflection problems off their robot)
	{
		driveForward(850); // drive infront of the next spot on the ramp (adjust time if needed)
		if (pathBlocked(50)) // if robot is in the way (dist is 50 b/c want to ensure no robot even if there are reflection problems off their robot)
		{
			turnLeft(AngleTurn_90);
			driveForward(1350, 100); // try to push them out of the way and get on ramp (might want something else)
		}
		else // drive up on the ramp
		{
			turnLeft(AngleTurn_90);
			driveForward(1350);
		}
	}
	else // drive up on the ramp
	{
		turnLeft(AngleTurn_90);
		driveForward(1350);
	}
	// end of section for if sonar points off the side of the robot
}

I didn't know how your sonar was mounted so included sections at the end for it pointing forward or sideways off the robot.

Hope this works for you,
Team 4211
Reply With Quote
  #6   Spotlight this post!  
Unread 13-01-2014, 17:34
MattRain MattRain is offline
AZ FTC AF, FTC #2844 and FTC #8640
FRC #1492 (Team Caution)
Team Role: RoboCoach
 
Join Date: Sep 2012
Rookie Year: 2008
Location: Chandler, Arizona
Posts: 318
MattRain has a brilliant futureMattRain has a brilliant futureMattRain has a brilliant futureMattRain has a brilliant futureMattRain has a brilliant futureMattRain has a brilliant futureMattRain has a brilliant futureMattRain has a brilliant futureMattRain has a brilliant futureMattRain has a brilliant futureMattRain has a brilliant future
Re: [FTC]: IR Block for Block Party

Quote:
Originally Posted by mfine View Post
I think what a lot of people are doing is mounting the IR sensor at an angle, so that zone 5 (the smallest) corresponds with being directly in front of the IR beacon.
Zone 5 is the biggest zone...
Reply With Quote
  #7   Spotlight this post!  
Unread 13-01-2014, 17:40
mfine mfine is offline
Registered User
FTC #6484
 
Join Date: Jan 2014
Location: United States
Posts: 12
mfine will become famous soon enoughmfine will become famous soon enough
Re: [FTC]: IR Block for Block Party

Looking back, you're right, I meant zone 4 or zone 6
Reply With Quote
  #8   Spotlight this post!  
Unread 13-01-2014, 21:20
TheThings5926 TheThings5926 is offline
Registered User
FTC #5926
 
Join Date: Dec 2012
Location: Minnesota
Posts: 15
TheThings5926 is an unknown quantity at this point
Re: [FTC]: IR Block for Block Party

I got this error when compiling the IR sensor

**Error**:Undefined procedure 'HTIRS2readACDir'.

Any thoughts? Am I missing something with sensor driver?

Thanks,

Matt, The Things 5926
Reply With Quote
  #9   Spotlight this post!  
Unread 14-01-2014, 06:18
mikets's Avatar
mikets mikets is offline
Software Engineer
FRC #0492 (Titan Robotics)
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2008
Location: Bellevue, WA
Posts: 672
mikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of light
Re: [FTC]: IR Block for Block Party

Quote:
Originally Posted by TheThings5926 View Post
I got this error when compiling the IR sensor

**Error**:Undefined procedure 'HTIRS2readACDir'.

Any thoughts? Am I missing something with sensor driver?

Thanks,

Matt, The Things 5926
Did you include Xander's IR sensor driver? HTIRS2readACDir is a function in his driver.
__________________
Reply With Quote
  #10   Spotlight this post!  
Unread 14-01-2014, 06:21
mikets's Avatar
mikets mikets is offline
Software Engineer
FRC #0492 (Titan Robotics)
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2008
Location: Bellevue, WA
Posts: 672
mikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of light
Re: [FTC]: IR Block for Block Party

Note that if your robot is driving parallel to the pendulum and if you mount the IR seeker pointing directly ahead, the zones to detect the IR beacon will become 2 if it is on the left side and 8 if it is on the right side. Both zone 2 and 8 are very narrow. Mounting this way will make your robot capable of detecting the IR beacon on both the left and the right side.
__________________
Reply With Quote
  #11   Spotlight this post!  
Unread 14-01-2014, 14:35
cadandcookies's Avatar
cadandcookies cadandcookies is offline
Director of Programs, GOFIRST
AKA: Nick Aarestad
FTC #9205 (The Iron Maidens)
Team Role: College Student
 
Join Date: Jan 2012
Rookie Year: 2009
Location: Minnesnowta
Posts: 1,552
cadandcookies has a reputation beyond reputecadandcookies has a reputation beyond reputecadandcookies has a reputation beyond reputecadandcookies has a reputation beyond reputecadandcookies has a reputation beyond reputecadandcookies has a reputation beyond reputecadandcookies has a reputation beyond reputecadandcookies has a reputation beyond reputecadandcookies has a reputation beyond reputecadandcookies has a reputation beyond reputecadandcookies has a reputation beyond repute
Re: [FTC]: IR Block for Block Party

I'm not a programming mentor (more CAD, strategy, and design), so I can't speak for the specifics of what the teams I've been working with are actually doing in the source code, but I can tell you that more than 1/2 of our teams have a very nearly 100% IR autonomous with just a straight-on IR sensor and a little servo-powered "flicker arm," which behaves almost exactly as you've described.

Even our teams that have dedicated floor pickup use this method, and they've been pretty successful at competition. There's something to be said for just keeping it as simple as possible...

I'll grab some pictures when I'm in the shop tonight of our setups.
__________________

Never assume the motives of others are, to them, less noble than yours are to you. - John Perry Barlow
tumblr | twitter
'Snow Problem CAD Files: 2015 2016
MN FTC Field Manager, FTA, CSA, Emcee
FLL Maybe NXT Year (09-10) -> FRC 2220 (11-14) -> FTC 9205(14-?)/FRC 2667 (15-16)
VEXU UMN (2015-??)
Volunteer since 2011
2013 RCA Winner (North Star Regional) (2220)
2016 Connect Award Winner (North Super Regional and World Championship) (9205)
Reply With Quote
  #12   Spotlight this post!  
Unread 03-09-2014, 10:45
Colton Mehlhoff Colton Mehlhoff is offline
Registered User
no team (HiTechnic)
 
Join Date: Jul 2011
Rookie Year: 2005
Location: MN USA
Posts: 4
Colton Mehlhoff is an unknown quantity at this point
Re: [FTC]: IR Block for Block Party

You can also get the raw values of each of the five sensors in the IRSeeker. Visit the sensor website for information of the ports http://www.hitechnic.com/cgi-bin/com...on&key=NSK1042. The sensor could look straight and you can read sensors 2 and 4. Keep going until they are equal values. Sensor 2 is in the direction of zone 3. Sensor 4 is in the direction of zone 7.

Colton Mehlhoff
HiTechnic
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 12:44.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi