Go to Post - Just because you can buy 50 giant pixie stix with your roommates Sam's club membership does not mean you should eat them all at once. - Not2B [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 18-03-2011, 13:25
SoulSaber1's Avatar
SoulSaber1 SoulSaber1 is offline
Registered User
AKA: Drew Parker
FRC #3011 (RoboWarriors)
Team Role: Programmer
 
Join Date: Jan 2011
Rookie Year: 2011
Location: Wiesbaden
Posts: 8
SoulSaber1 is an unknown quantity at this point
Bit of coding help

So, for autonamous we are using a modified line tracker code, with certain cases for different scenarios. After this loop we want the robot to go backwards, but we can't seem to make it happen.

Code:
case 7: //ALL SENSORS ON *OR* MAYBE AT CROSS
                        if (time > stopTime)
                        {
                            atCross = true;
                            speed = 0;
                            gripper.set(false);         //Closes gripper
                            gripper2.set(true);         // "     "
                            while (backCount < 5)
                            {
                                backCount++;
                                drive.arcadeDrive(-.5,0);
                            }
                        }
Any ideas?
__________________
"I don't care about what anything was DESIGNED to do, I care about what it CAN do." -Gene Kranz

"This lifestyle is DIY or GTFO" - lucid
Reply With Quote
  #2   Spotlight this post!  
Unread 18-03-2011, 13:32
Egg 3141592654's Avatar
Egg 3141592654 Egg 3141592654 is offline
Now a mentor, always a student
FRC #0810 (Mechanical Bulls)
Team Role: Programmer
 
Join Date: Feb 2010
Rookie Year: 2008
Location: Long Island
Posts: 53
Egg 3141592654 is on a distinguished road
Re: Bit of coding help

If you want the robot to move backwards, instead of using a while loop, replace with something like...

Code:
drive.arcadeDrive(-.5 , 0);
Timer.delay(/*insert time you want to go backwards in milliseconds*/);
drive.arcadeDrive(0 , 0);
To answer why your robot may not be moving backwards, the loop might be cycling too fast for you to actually notice, so 5 cycles would be instant. Remember to put the drive.arcadeDrive(0 , 0) or else your robot will keep driving backwards. Good luck out there!
__________________
"The answers to the book of life are not found in the back." Charlie Brown

Software Mentor - Team Apex Robotics 5803

Lead Programmer - Team 810 Mechanical Bulls '09-'11

Last edited by Egg 3141592654 : 18-03-2011 at 13:33. Reason: missed code tag
Reply With Quote
  #3   Spotlight this post!  
Unread 18-03-2011, 14:04
SoulSaber1's Avatar
SoulSaber1 SoulSaber1 is offline
Registered User
AKA: Drew Parker
FRC #3011 (RoboWarriors)
Team Role: Programmer
 
Join Date: Jan 2011
Rookie Year: 2011
Location: Wiesbaden
Posts: 8
SoulSaber1 is an unknown quantity at this point
Re: Bit of coding help

For some reason this isn't working either. did you mean like this?

Code:
case 7: //ALL SENSORS ON *OR* MAYBE AT CROSS
                        if (time > stopTime)
                        {
                            atCross = true;
                            speed = 0;
                            gripper.set(false);         //Closes gripper
                            gripper2.set(true);         // "     "
                            drive.arcadeDrive(-.5 , 0);
                            Timer.delay(1.0);
                            drive.arcadeDrive(0 , 0);
                                                                }
__________________
"I don't care about what anything was DESIGNED to do, I care about what it CAN do." -Gene Kranz

"This lifestyle is DIY or GTFO" - lucid
Reply With Quote
  #4   Spotlight this post!  
Unread 19-03-2011, 13:06
JosephC's Avatar
JosephC JosephC is offline
FF: Breakfast Company
AKA: Joseph Cupchack
no team (FiM Volunteer Extraordinaire)
 
Join Date: Sep 2010
Rookie Year: 2011
Location: Waterford, Michigan
Posts: 1,752
JosephC has a reputation beyond reputeJosephC has a reputation beyond reputeJosephC has a reputation beyond reputeJosephC has a reputation beyond reputeJosephC has a reputation beyond reputeJosephC has a reputation beyond reputeJosephC has a reputation beyond reputeJosephC has a reputation beyond reputeJosephC has a reputation beyond reputeJosephC has a reputation beyond reputeJosephC has a reputation beyond repute
Re: Bit of coding help

Quote:
Originally Posted by SoulSaber1 View Post
For some reason this isn't working either. did you mean like this?

Code:
case 7: //ALL SENSORS ON *OR* MAYBE AT CROSS
                        if (time > stopTime)
                        {
                            atCross = true;
                            speed = 0;
                            gripper.set(false);         //Closes gripper
                            gripper2.set(true);         // "     "
                            drive.arcadeDrive(-.5 , 0);
                            Timer.delay(1.0);
                            drive.arcadeDrive(0 , 0);
                                                                }

Okay so I can see one clear problem here I think.

Timer.delay is generally in milliseconds so you have it going backwardsfor 1 millisecond then stopping. Try increasing Timer.delay to a greater value, say 500, then try it again.

Remeber if it goes berserk and doesnt stop for some reason you have a stop button.
Reply With Quote
  #5   Spotlight this post!  
Unread 21-03-2011, 11:24
Egg 3141592654's Avatar
Egg 3141592654 Egg 3141592654 is offline
Now a mentor, always a student
FRC #0810 (Mechanical Bulls)
Team Role: Programmer
 
Join Date: Feb 2010
Rookie Year: 2008
Location: Long Island
Posts: 53
Egg 3141592654 is on a distinguished road
Re: Bit of coding help

Quote:
Timer.delay is generally in milliseconds
Timer.delay for wpilibj is in milliseconds, so 1 second would be
Code:
Timer.delay(1000);
__________________
"The answers to the book of life are not found in the back." Charlie Brown

Software Mentor - Team Apex Robotics 5803

Lead Programmer - Team 810 Mechanical Bulls '09-'11
Reply With Quote
  #6   Spotlight this post!  
Unread 21-03-2011, 17:26
Robby Unruh's Avatar
Robby Unruh Robby Unruh is offline
*insert random dial-up tone here*
FRC #3266 (Robots R Us)
Team Role: Coach
 
Join Date: Feb 2010
Rookie Year: 2010
Location: Eaton, OH
Posts: 338
Robby Unruh will become famous soon enough
Re: Bit of coding help

Quote:
Originally Posted by Egg 3141592654 View Post
Timer.delay for wpilibj is in milliseconds, so 1 second would be
Code:
Timer.delay(1000);
The javadoc only says this:

Quote:
delay

public static void delay(double seconds)
Pause the thread for a specified time. Pause the execution of the thread for a specified period of time given in seconds. Motors will continue to run at their last assigned values, and sensors will continue to update. Only the task containing the wait will pause until the wait time is expired.
Parameters:
seconds - Length of time to pause
Note; "seconds". I'm pretty sure it's just in normal seconds. So one second would be

Code:
Timer.delay(1.0); // only accepts doubles as an argument
My team has had no problems using this, as opposed to using milliseconds(?).


However, when using other functions in the Timer class, like get(), it will return in microseconds. For our minibot deployment, we start a timer and have a condition timer.get()/1000000 > 110, if true it will deploy. If false, it'll let the user know you can't deploy yet.
__________________
[Robots R Us #3266]
2015: Georgia Southern Classic (Winners / Thanks 1319 & 1648!), Queen City
2014: Crossroads, Queen City
2013: Buckeye, Queen City, Crossroads
2012: Buckeye, Queen City

2011: Buckeye
2010: Buckeye

Last edited by Robby Unruh : 21-03-2011 at 17:30.
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 13:23.

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