Go to Post I feel like I need to rinse out my brain with drain cleaner - dlavery [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 11-06-2010, 22:59
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,077
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: no control of bot when kicker is operating

What you've posted is essentially a state machine, where the state variable is the value of kickTimer.

A generic state machine might look like this:


Quote:
// Set kicking loop to start when button 7 on gamepad is pressed and not in loop already


switch(kickState) {

case 0: // kicking is not in progress

if(gamePad.getRawButton(7) == true) {
start_the_kick_sequence_and_initialize_variables_a s_necessary();
kickState = 1;
}
break;

case 1:

if case_1_timer_or_event_has occurred(){
perform_case_1_action();
initialize_variables_for_case_2_as_necessary();
kickState=2;
}
break;

case 2:

if case_2_timer_or_event_has occurred(){
perform_case_2_action();
initialize_variables_for_case_3_as_necessary();
kickState=3;
}
break;

.
.
.


case n:

if case_n_timer_or_event_has occurred(){
perform_casen2_action();
initialize_variables_for_case_0_as_necessary();
kickState=0;
}
break;

}

The above has the advantage that it's a little easier to see how to use events (like limit switches etc) to change states, instead of being strictly timer-based.


~

Last edited by Ether : 12-06-2010 at 00:53.
  #2   Spotlight this post!  
Unread 12-06-2010, 00:44
synth3tk's Avatar
synth3tk synth3tk is offline
Volunteer / The Blue Alliance
AKA: David Thomas
no team
Team Role: Alumni
 
Join Date: Jan 2007
Rookie Year: 2007
Location: Ohio
Posts: 2,005
synth3tk has a reputation beyond reputesynth3tk has a reputation beyond reputesynth3tk has a reputation beyond reputesynth3tk has a reputation beyond reputesynth3tk has a reputation beyond reputesynth3tk has a reputation beyond reputesynth3tk has a reputation beyond reputesynth3tk has a reputation beyond reputesynth3tk has a reputation beyond reputesynth3tk has a reputation beyond reputesynth3tk has a reputation beyond repute
Re: no control of bot when kicker is operating

Thanks for the suggestions. I should have also stated:

I'm a non-student member (I guess a mentor, in some ways), and our team is extremely small. I couldn't even coerce any students to learn programming, so I had to learn Java with some small help from the team mentor (who knew very little more about Java than I did) and the internet starting 2 days from Kick-Off.

We were just getting the bare minimum working. But I'll keep that in mind for the future, if/when we teach the new programmers.
  #3   Spotlight this post!  
Unread 13-06-2010, 09:51
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,077
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: no control of bot when kicker is operating

I've seen the following kicker approach successfully implemented in LabVIEW. The same approach could be used in Java or C++.

put the following code in a separate concurrent periodic task using your language of choice. for a kicker, 20Hz is probably plenty fast enough.

Code:
/*
to establish the 50ms period (20Hz frequency) put your code here 
to block wait for 50ms to elapse, releasing the CPU so this task 
does not run at high speed and use CPU resources unnecessarily 
when not kicking
*/

if (kickRequested && !kicking) {

kicking=1; // prevent reentrancy

/*
put your sequential kicking code here. if your code has places where it needs to wait for an event, like elapsed time or a limit switch for example, make sure you code it so that the CPU will be released to use that time to service other tasks while waiting for the event. if your code uses data from other tasks, make sure the access is protected.
*/ kicking=0; }

"kickRequested" is a global boolean that is used by your code in Autononmous and/or TeleOp to request that a kick be performed.

"kicking" is a local boolean to control reentrancy: If a kick is presently in progress when the request is made, the request will be ignored (so as not to interrupt the ongoing kick cycle)
  #4   Spotlight this post!  
Unread 17-06-2010, 02:29
timothyb89 timothyb89 is offline
code monkey
FRC #1977 (Loveland High Robotics)
Team Role: Alumni
 
Join Date: Oct 2008
Rookie Year: 2009
Location: Loveland, Colorado
Posts: 45
timothyb89 will become famous soon enough
Re: no control of bot when kicker is operating

One thing I liked doing for the kicker code was making sure you couldn't violate the timing rules (2 seconds between extensions out of the main robot body), and tossing in a few extra threads made it fit together nicely. Obviously reload time can make this unneeded, so it might not even be needed, depending.

Example code here.
__________________
FRC-DB: A detailed, web-based scouting database for FRC teams with lots of interesting statistics.
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
842 Kicker On Bot kE7JLM General Forum 36 29-01-2010 11:51
How & where do you build the bot when it snows and your robo-base (school) is closed? Elgin Clock General Forum 28 03-03-2008 00:12
paper: Control an FRC bot with a Wiimote Greg Marra Extra Discussion 8 21-01-2008 12:41
1189 - Human-Bot Arm Control jmcr8on Robot Showcase 50 13-10-2007 22:58


All times are GMT -5. The time now is 03:32.

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