View unanswered posts | View active topics It is currently Sat Oct 25, 2014 3:47 am






Reply to topic  [ 4 posts ] 
I have a complicated autonomos problem I need help with. 
Author Message
Rookie

Joined: Thu Nov 14, 2013 11:13 am
Posts: 2
Post I have a complicated autonomos problem I need help with.
I need my robot to move up until the IR sensor reaches a defined value then stop. I need that about of time to be taken as a value i can use to tell it how far it moves backwards. How could I do that?


Thu Nov 14, 2013 11:18 am
Profile
Site Admin
Site Admin

Joined: Thu May 24, 2012 12:15 pm
Posts: 596
Post Re: I have a complicated autonomos problem I need help with.
What code do you have so far? Please post what you have so far using the [code] tags and we'll be more than happy to take a look at with you.

Also, try listing the behaviors you want the robot to perform (move forward until IR sensor reaches a value, stop, record amount of time, move backwards for amount of time) and then slowly break each behavior down into smaller behaviors, which can then be broken down into individual lines of code. As always, make sure to start with your first behavior (move forward until IR sensor reaches a value) before moving on to the other behaviors.

_________________
Check out our Blog! And our Facebook page!
Need help? Take a look at our Wiki and our Forums.

I just met you,
And this is crazy,
But here's my code now,
So fix it, maybe?
~ Carly Rae Jepsen parody


Thu Nov 14, 2013 1:41 pm
Profile
Rookie

Joined: Thu Nov 14, 2013 11:13 am
Posts: 2
Post Re: I have a complicated autonomos problem I need help with.
#include"JoystickDriver.c"
#include"hitechnic-irseeker-v2.h"
#define IRSEEKER
#define s3

task main()
{
int IRSEEKER s3

hi; while (1 == 1)
{

if ((HTIRS2_AC_DIR) < 7)
{
motor[leftback] = 100;
motor[leftfront] = 100;
motor[rightfront] = -100;
motor[rightback] = -100;
}
if ((HTIRS2_AC_DIR) > 7)
{
motor[leftback] = -100;
motor[leftfront] = -100;
motor[rightfront] = 100;
motor[rightback] = 100;
}
else
{
motor[leftback] = 0;
motor[leftfront] = 0;
motor[rightfront] = 0;
motor[rightback] = 0;
}

}
}


Fri Nov 15, 2013 9:57 am
Profile
Rookie
User avatar

Joined: Wed Jan 09, 2013 11:48 pm
Posts: 39
Location: Saint Paul, MN
Post Re: I have a complicated autonomos problem I need help with.
First off, your else statement will be contradicting your first if statement, so you might want to look at my fix. Im just assuming that < 7 means to move forward here. Here's some code with timers that I would use, I'm not sure if it works since I've never actually used the timer function but it should be fine.
Code:
#include"JoystickDriver.c"
#include"hitechnic-irseeker-v2.h"
#define IRSEEKER
#define s3

int valTime;//Your int representing your time

task main()
{
int IRSEEKER s3

ClearTimer[T1];//Set T1 to 0

hi; while (1 == 1)
{
if ((HTIRS2_AC_DIR) < 7)
{
motor[leftback] = 100;
motor[leftfront] = 100;
motor[rightfront] = -100;
motor[rightback] = -100;

valeTime = time1[T1]; //When you exit the loop, valTime will equal the number of msecs you were in it
}
if ((HTIRS2_AC_DIR) > 7)
{
motor[leftback] = -100;
motor[leftfront] = -100;
motor[rightfront] = 100;
motor[rightback] = 100;
}
if((HTIRS_AC_DIR) == 7)//No conflicts
{
motor[leftback] = 0;
motor[leftfront] = 0;
motor[rightfront] = 0;
motor[rightback] = 0;
}

}
}


So the int valTime is constantly being updated to the built in timer T1 while the IRSeeker is < 7. The ClearTimer function will set T1 to 0, I'm just assuming you start off in the process you want to time. If not then just clear it right before you do this. Then you can just use valTime in a wait1msec function. Hopefully that helps.

p.s. - im not sure what your "hi;" does, but I will just assume its part of hitechnic-irseeker-v2.h which I don't use, I just use SensorValue for the IRSeeker.

_________________
Head Programmer FTC Team 6699, Tempest

Code:
<Life>
   Fun
</Life>


Fri Nov 15, 2013 11:43 pm
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 4 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.