Go to Post “FIRST is your experience and you cannot let anyone else hinder what you can achieve.” - fuzzwaz [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 28-02-2005, 11:20
gacp gacp is offline
Registered User
AKA: Gilbert A. Castillo
#0928 (Secme)
Team Role: Programmer
 
Join Date: Feb 2005
Rookie Year: 2005
Location: Washington, DC
Posts: 2
gacp is an unknown quantity at this point
Autonomous Code (Help!!!)

I would like anyone who is good at programing to help me write a piece of code: For the autonomous mode, our robot has to move forward for, lets say 5 seconds at full speed. turn on relay 5, and then turn on relay 4. Then, the robot should go back for 2 second. could anybody help.
  #2   Spotlight this post!  
Unread 28-02-2005, 11:47
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,112
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: Autonomous Code (Help!!!)

Sure, I'll help.

Start by using a simple counter inside the autonomous mode communication loop. Set it to zero as soon as you enter the autonomous_mode function. Whenever you get new data, increment its value. That will happen about every 26 milliseconds, so 38 counts is very close to a second.

Then test the value of the counter after you increment it. If it's between 0 and 5*38, you're in the first five seconds, so you turn the drive motors on full forward. If it's between 5*38 and 7*38, you're in the next two seconds, so you activate the relays and turn the drive motors on in reverse. If it's greater than 7*38, turn off the drive motors.

That will do what you asked. You can get more detailed with timing of the relays if you wish, or you can add more steps with more actions.

For what it's worth, I'd expect most robots going five seconds at full speed this year will run into one of the mid-field goals. Some will likely be fast enough to run into the far goals if they manage to miss the mid-field ones -- assuming they also don't ram the opposing alliance's robots.
  #3   Spotlight this post!  
Unread 28-02-2005, 11:49
bombadier337's Avatar
bombadier337 bombadier337 is offline
1337 U53R
AKA: Shaver
None #1541 (MidloCANics)
Team Role: College Student
 
Join Date: Feb 2005
Rookie Year: 2005
Location: Richmond VA
Posts: 123
bombadier337 is just really nicebombadier337 is just really nicebombadier337 is just really nicebombadier337 is just really nice
Send a message via AIM to bombadier337
Re: Autonomous Code (Help!!!)

You could do something like this

in user_routines_fast

timer++;
if(timer<300)
{
pwm11=255;
pwm12=0;
}
else if(timer<310)
{
relay4_fwd=1;
}
else if(timer<320)
{
relay5_fwd=1;
relay4_fwd=0;
}
else if(timer<440)
{
pwm12=255;
pwm11=0;
}

BUT, you'll probably have to change the pwm's around to make it go forward. Also, you never said if you wanted the relays on fwd or rev. Also, all the times are only approximate, and relay4_fwd is only on for 1/6 of a second and relay5_fwd stays on forever, once relay4_fwd turns off. Hope that helps or gets you started.

Also, i just used arbitrarily 60 cycles as one second, which is wrong, so don't trust that.
__________________
Midlothian High School - Team 1541
2005 Radioshack Innovation in Control - NASA/VCU Regional
2005 Rookie Inspiration - NASA/VCU Regional
  #4   Spotlight this post!  
Unread 28-02-2005, 12:59
Gene F's Avatar
Gene F Gene F is offline
FIRST Fanatic
AKA: Gene Falendysz
#0343 (Metal in Motion)
Team Role: Engineer
 
Join Date: Mar 2002
Rookie Year: 2001
Location: Oconee County, SC
Posts: 218
Gene F is a splendid one to beholdGene F is a splendid one to beholdGene F is a splendid one to beholdGene F is a splendid one to beholdGene F is a splendid one to beholdGene F is a splendid one to beholdGene F is a splendid one to beholdGene F is a splendid one to behold
Send a message via AIM to Gene F
Re: Autonomous Code (Help!!!)

Quote:
Originally Posted by bombadier337
You could do something like this

in user_routines_fast

timer++;
if(timer<300)
{
pwm11=255;
pwm12=0;
}
else if(timer<310)
{
relay4_fwd=1;
}
else if(timer<320)
{
relay5_fwd=1;
relay4_fwd=0;
}
else if(timer<440)
{
pwm12=255;
pwm11=0;
}

BUT, you'll probably have to change the pwm's around to make it go forward. Also, you never said if you wanted the relays on fwd or rev. Also, all the times are only approximate, and relay4_fwd is only on for 1/6 of a second and relay5_fwd stays on forever, once relay4_fwd turns off. Hope that helps or gets you started.

Also, i just used arbitrarily 60 cycles as one second, which is wrong, so don't trust that.
Beware the 255! You shouldn't set the PWM to 255, the maximum value is 254. The radio packets are framed with 255 and if you use a value of 255 you'll mess up the communication. Other than that the code looks like it should do what you want.
__________________
- Gene Falendysz
Closed Thread


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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Out of the Box Camera Code russell Programming 9 21-10-2009 05:28
Team THRUST - Kevin's Code and Camera Code Combine Chris_Elston Programming 3 31-01-2005 22:28
heres the code. y this not working omega Programming 16 31-03-2004 15:18
InfraRed autonomous code ... mtrawls Programming 1 11-01-2004 00:25


All times are GMT -5. The time now is 10:55.

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