Go to Post I really think we need to keep our pitchforks sheathed and torches unlit until we here more news and get more details. - IndySam [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 02-27-2012, 05:49 PM
touchdownjesus4's Avatar
touchdownjesus4 touchdownjesus4 is offline
Registered User
AKA: Tyler Vonderhaar
FRC #4028 (Eagle Robotics)
Team Role: Programmer
 
Join Date: Jan 2012
Rookie Year: 2012
Location: Cincinnati, OH
Posts: 64
touchdownjesus4 is on a distinguished road
Help Programming Autonomous

Hello all,

So first off I am using the command based robot template from WPI, and I need to create a command group that will be run during our autonomous period. We are just going to shoot the balls that are in our robot and that's it for autonomous, nothing complicated.

Basically what I need the robot to do is:
1) Begin running shooter motor (this will be running throughout autonomous)
2) Wait 3 seconds or so (for motor to spin up)
3) run our ball delivery motor for ~1.5 sec
4) stop ball delivery motor
5) Run conveyor motor to put 2nd ball in place
6) run ball delivery motor again
7) stop motors

I have commands written to do all of these functions, I just need a way to put them together into a command group with a delay in-between. Can anyone offer any guidance that has worked with the command based template?
Reply With Quote
  #2   Spotlight this post!  
Unread 02-27-2012, 06:39 PM
Ginto8's Avatar
Ginto8 Ginto8 is offline
Programming Lead
AKA: Joe Doyle
FRC #2729 (Storm)
Team Role: Programmer
 
Join Date: Oct 2010
Rookie Year: 2010
Location: Marlton, NJ
Posts: 174
Ginto8 is a glorious beacon of lightGinto8 is a glorious beacon of lightGinto8 is a glorious beacon of lightGinto8 is a glorious beacon of lightGinto8 is a glorious beacon of light
Re: Help Programming Autonomous

http://www.chiefdelphi.com/forums/sh....php?p=1129175
This was for a slightly different issue, but it explains the ideas required and provides CommandSequence, which you might find useful yourself!
Reply With Quote
  #3   Spotlight this post!  
Unread 02-27-2012, 11:06 PM
Jeanne Boyarsky Jeanne Boyarsky is offline
Java Mentor
FRC #0694 (StuyPulse)
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2010
Location: New York
Posts: 97
Jeanne Boyarsky has much to be proud ofJeanne Boyarsky has much to be proud ofJeanne Boyarsky has much to be proud ofJeanne Boyarsky has much to be proud ofJeanne Boyarsky has much to be proud ofJeanne Boyarsky has much to be proud ofJeanne Boyarsky has much to be proud ofJeanne Boyarsky has much to be proud ofJeanne Boyarsky has much to be proud of
Re: Help Programming Autonomous

There is WaitCommand() for the delay part. And you already have the other commands written as you note above. The next step is to create a new class that extends CommandGroup and add all the commands to it.
__________________
Team 694 mentor 2010-present, FIRST Volunteer and Co-organizer of FIRST World Maker Faire Tent
2012 NYC Woodie Flowers Finalist
2015 NYC Volunteer of the Year
Reply With Quote
  #4   Spotlight this post!  
Unread 02-27-2012, 11:35 PM
touchdownjesus4's Avatar
touchdownjesus4 touchdownjesus4 is offline
Registered User
AKA: Tyler Vonderhaar
FRC #4028 (Eagle Robotics)
Team Role: Programmer
 
Join Date: Jan 2012
Rookie Year: 2012
Location: Cincinnati, OH
Posts: 64
touchdownjesus4 is on a distinguished road
Re: Help Programming Autonomous

Ok so this is what I have set up, will the Timer.delay(3) delay the next command from running for three seconds, or do I have to use something else?

Quote:
public class AutonomousCommand extends CommandGroup {

public AutonomousCommand() {
addParallel(new AutonomousShoot());
Timer.delay(3);
addSequential(new AutonomousDeliver());
addSequential(new AutonomousConveyor());
addSequential(new AutonomousDeliver());
addSequential(new AllStop());
Reply With Quote
  #5   Spotlight this post!  
Unread 02-27-2012, 11:39 PM
Sunstroke Sunstroke is offline
Programmer
AKA: Joe Grinstead
FRC #3504 (Girls of Steel)
Team Role: Mentor
 
Join Date: Apr 2009
Rookie Year: 2009
Location: New England
Posts: 49
Sunstroke is an unknown quantity at this point
Re: Help Programming Autonomous

Quote:
Originally Posted by touchdownjesus4 View Post
Ok so this is what I have set up, will the Timer.delay(3) delay the next command from running for three seconds, or do I have to use something else?
100% don't do that! You'll end up pausing all commands for 3 seconds...

Instead of Timer.delay(3), you want addSequential(new WaitCommand(3));
Reply With Quote
  #6   Spotlight this post!  
Unread 02-27-2012, 11:53 PM
touchdownjesus4's Avatar
touchdownjesus4 touchdownjesus4 is offline
Registered User
AKA: Tyler Vonderhaar
FRC #4028 (Eagle Robotics)
Team Role: Programmer
 
Join Date: Jan 2012
Rookie Year: 2012
Location: Cincinnati, OH
Posts: 64
touchdownjesus4 is on a distinguished road
Re: Help Programming Autonomous

Quote:
Originally Posted by Sunstroke View Post
100% don't do that! You'll end up pausing all commands for 3 seconds...

Instead of Timer.delay(3), you want addSequential(new WaitCommand(3));

haha alright thanks, new programmer here so I don't exactly know what everything does. Didn't know there was such a thing as WaitCommand() but thanks!

Last edited by touchdownjesus4 : 02-27-2012 at 11:55 PM.
Reply With Quote
  #7   Spotlight this post!  
Unread 03-15-2012, 07:08 PM
touchdownjesus4's Avatar
touchdownjesus4 touchdownjesus4 is offline
Registered User
AKA: Tyler Vonderhaar
FRC #4028 (Eagle Robotics)
Team Role: Programmer
 
Join Date: Jan 2012
Rookie Year: 2012
Location: Cincinnati, OH
Posts: 64
touchdownjesus4 is on a distinguished road
Alright so I got a chance to test the autonomous today and it doesn't work. What happens is that when I run the shooter motor runs but then the delivery wheel runs right away as well. The wait command doesn't seem to be doing anything and the other commands don't timeout when they are supposed to. (I have the others using setTimeout()).

Can anyone offer any insight into what might be going wrong?
__________________
2012 Boilermaker Regional Champions (With 1756 & 1501)
Team Captain, Programmer, Lead Driver
Reply With Quote
  #8   Spotlight this post!  
Unread 03-16-2012, 02:33 AM
AlexD744 AlexD744 is offline
Registered User
FRC #0744 (744 Shark Attack)
Team Role: Alumni
 
Join Date: Jan 2009
Rookie Year: 2008
Location: Ft. Lauderdale, FL
Posts: 638
AlexD744 has a reputation beyond reputeAlexD744 has a reputation beyond reputeAlexD744 has a reputation beyond reputeAlexD744 has a reputation beyond reputeAlexD744 has a reputation beyond reputeAlexD744 has a reputation beyond reputeAlexD744 has a reputation beyond reputeAlexD744 has a reputation beyond reputeAlexD744 has a reputation beyond reputeAlexD744 has a reputation beyond reputeAlexD744 has a reputation beyond repute
Re: Help Programming Autonomous

As far as timeOuts for commands, although you are setting the timeout, did you change the isFinished() method to read "return isTimedOut();" I had an issue with this before i buckled down and decided to actually read the documentation more thoroughly.

if you want to know what our code looks like, it's a simple three line command sequence.

addParallel(new TmAutonPrepareShooter(1.0));
addSequential(new WaitCommand(3.0));
addSequential(new TmAutonShootBall(5));

The first command simply sets the shooter to a speed to 1.0 and then returns. The second command is a 3 second delay while the shooter actually gets up to speed (notice that the first command says Parallel, while the second says Sequential). And the last command turns on the motors that feed into the shooter at a slow enough speed to allow time for the shooter to regain it's momentum. (The parameter is 5 seconds, speed is set within the class). In your case, you are breaking up the two motors that I'm controlling in one command. It seems like you are doing most of this, another thing to check is to make sure the in the end() and interrupted() methods of each command that you are stopping the motors. Not sure if this will solve you problem but I hope it helps.
__________________
www.sharkattack744.com
Reply With Quote
  #9   Spotlight this post!  
Unread 03-16-2012, 06:53 PM
touchdownjesus4's Avatar
touchdownjesus4 touchdownjesus4 is offline
Registered User
AKA: Tyler Vonderhaar
FRC #4028 (Eagle Robotics)
Team Role: Programmer
 
Join Date: Jan 2012
Rookie Year: 2012
Location: Cincinnati, OH
Posts: 64
touchdownjesus4 is on a distinguished road
Thanks! I'll try to make the changes tonight and see if that fixes the issue tomorrow morning.
__________________
2012 Boilermaker Regional Champions (With 1756 & 1501)
Team Captain, Programmer, Lead Driver
Reply With Quote
  #10   Spotlight this post!  
Unread 03-17-2012, 01:16 AM
AlexD744 AlexD744 is offline
Registered User
FRC #0744 (744 Shark Attack)
Team Role: Alumni
 
Join Date: Jan 2009
Rookie Year: 2008
Location: Ft. Lauderdale, FL
Posts: 638
AlexD744 has a reputation beyond reputeAlexD744 has a reputation beyond reputeAlexD744 has a reputation beyond reputeAlexD744 has a reputation beyond reputeAlexD744 has a reputation beyond reputeAlexD744 has a reputation beyond reputeAlexD744 has a reputation beyond reputeAlexD744 has a reputation beyond reputeAlexD744 has a reputation beyond reputeAlexD744 has a reputation beyond reputeAlexD744 has a reputation beyond repute
Re: Help Programming Autonomous

I hope you read this before competition, but it's also good to have initialization code that simply turns everything off when you start each state (teleop, auto and disabled). In each of our subsystems we have an init() method that simply turns off the motors associated with the subsystems and is called in each of the main init methods (teleopInit, autonomousInit and disabledInit). That could explain why your motors are starting up right away, they could be reading leftovers from the last time you were in teleop. But on second thought, this is unlikely after a power cycle, so I'm not sure. Regardless it's a good practice.
__________________
www.sharkattack744.com
Reply With Quote
  #11   Spotlight this post!  
Unread 03-17-2012, 11:30 AM
touchdownjesus4's Avatar
touchdownjesus4 touchdownjesus4 is offline
Registered User
AKA: Tyler Vonderhaar
FRC #4028 (Eagle Robotics)
Team Role: Programmer
 
Join Date: Jan 2012
Rookie Year: 2012
Location: Cincinnati, OH
Posts: 64
touchdownjesus4 is on a distinguished road
Thanks so much! It worked perfectly. After we got the speed right on the shooter motor we were able to score during autonomous!
__________________
2012 Boilermaker Regional Champions (With 1756 & 1501)
Team Captain, Programmer, Lead Driver
Reply With Quote
  #12   Spotlight this post!  
Unread 03-18-2012, 01:00 AM
AlexD744 AlexD744 is offline
Registered User
FRC #0744 (744 Shark Attack)
Team Role: Alumni
 
Join Date: Jan 2009
Rookie Year: 2008
Location: Ft. Lauderdale, FL
Posts: 638
AlexD744 has a reputation beyond reputeAlexD744 has a reputation beyond reputeAlexD744 has a reputation beyond reputeAlexD744 has a reputation beyond reputeAlexD744 has a reputation beyond reputeAlexD744 has a reputation beyond reputeAlexD744 has a reputation beyond reputeAlexD744 has a reputation beyond reputeAlexD744 has a reputation beyond reputeAlexD744 has a reputation beyond reputeAlexD744 has a reputation beyond repute
Re: Help Programming Autonomous

No problem! I'm happy I could help! And CONGRATULATIONS on your win!!! That's AWESOME! Hope to see you guys in St. Louis!
__________________
www.sharkattack744.com
Reply With Quote
  #13   Spotlight this post!  
Unread 03-18-2012, 01:02 AM
touchdownjesus4's Avatar
touchdownjesus4 touchdownjesus4 is offline
Registered User
AKA: Tyler Vonderhaar
FRC #4028 (Eagle Robotics)
Team Role: Programmer
 
Join Date: Jan 2012
Rookie Year: 2012
Location: Cincinnati, OH
Posts: 64
touchdownjesus4 is on a distinguished road
Quote:
Originally Posted by AlexD744 View Post
No problem! I'm happy I could help! And CONGRATULATIONS on your win!!! That's AWESOME! Hope to see you guys in St. Louis!
Thanks!! We had an awesome alliance and were able to get 2 triples in the elimination matches. We are so pumped for nationals!

Here's a pic of our triple.
Attached Thumbnails
Click image for larger version

Name:	ImageUploadedByTapatalk1332046958.881887.jpg
Views:	22
Size:	189.2 KB
ID:	12342  
__________________
2012 Boilermaker Regional Champions (With 1756 & 1501)
Team Captain, Programmer, Lead Driver
Reply With Quote
  #14   Spotlight this post!  
Unread 03-18-2012, 01:09 AM
AlexD744 AlexD744 is offline
Registered User
FRC #0744 (744 Shark Attack)
Team Role: Alumni
 
Join Date: Jan 2009
Rookie Year: 2008
Location: Ft. Lauderdale, FL
Posts: 638
AlexD744 has a reputation beyond reputeAlexD744 has a reputation beyond reputeAlexD744 has a reputation beyond reputeAlexD744 has a reputation beyond reputeAlexD744 has a reputation beyond reputeAlexD744 has a reputation beyond reputeAlexD744 has a reputation beyond reputeAlexD744 has a reputation beyond reputeAlexD744 has a reputation beyond reputeAlexD744 has a reputation beyond reputeAlexD744 has a reputation beyond repute
Re: Help Programming Autonomous

That's interesting, I didn't expect to see many ramp bots this year, but I guess that's what 1501 did? Also, if you ever have any other questions, feel free to PM me and I'll try to help as best I can. And if you're having trouble at nationals stop by our pit and we'll see if we can help. Best of luck!!
__________________
www.sharkattack744.com
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 07:48 AM.

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