Go to Post kids these days, with their fancy aluminum sprockets, don't know how good they have it. - AllenGregoryIV [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 24-02-2013, 15:40
tuXguy15's Avatar
tuXguy15 tuXguy15 is offline
Team Mentor
AKA: Devin Kolarac
FRC #2559 (Normality Zero)
 
Join Date: Apr 2012
Rookie Year: 2012
Location: Harrisburg, PA
Posts: 127
tuXguy15 is an unknown quantity at this point
Autonomous Moving Backwards

Can you guys help me with making our robot drive backwards and turn right in autonomous mode
Reply With Quote
  #2   Spotlight this post!  
Unread 24-02-2013, 16:38
F22Rapture's Avatar
F22Rapture F22Rapture is offline
College Student, Mentor
AKA: Daniel A
FRC #3737 (4H Rotoraptors)
Team Role: Mentor
 
Join Date: Jan 2012
Rookie Year: 2012
Location: Goldsboro, NC
Posts: 476
F22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant future
Re: Autonomous Moving Backwards

What sensors are you using? What language?

Generally it's done by creating commands to drive or turn in X direction for a set distance (via encoder) or time, then chaining those commands together in a command group. This only applies in the text languages, I'm not sure how it works in LabVIEW
__________________
Research is what I’m doing when I don’t know what I’m doing.
- Wernher von Braun
Attending: Raleigh NC Regional
Reply With Quote
  #3   Spotlight this post!  
Unread 24-02-2013, 18:05
tuXguy15's Avatar
tuXguy15 tuXguy15 is offline
Team Mentor
AKA: Devin Kolarac
FRC #2559 (Normality Zero)
 
Join Date: Apr 2012
Rookie Year: 2012
Location: Harrisburg, PA
Posts: 127
tuXguy15 is an unknown quantity at this point
Re: Autonomous Moving Backwards

We use java for our programming
jaruar1 is our left drive motor
jaguar2 is our right drive motor
Reply With Quote
  #4   Spotlight this post!  
Unread 24-02-2013, 18:48
MagiChau's Avatar
MagiChau MagiChau is offline
Registered User
AKA: Michael Chau
FRC #0085 (B.O.B. (Built on Brains))
Team Role: Alumni
 
Join Date: Jan 2010
Rookie Year: 2010
Location: Zeeland, Michigan
Posts: 875
MagiChau is just really niceMagiChau is just really niceMagiChau is just really niceMagiChau is just really nice
Re: Autonomous Moving Backwards

Quote:
Originally Posted by Zer0 View Post
We use java for our programming
jaruar1 is our left drive motor
jaguar2 is our right drive motor
Unless your team has used them already you should have E4P US Digital Optical Encoders from previous years' Kit of Parts. Mounting this on a drive shaft would allow you to detect the shaft's rotation to calculate the distance or speed the robot is travelling at. You can use this to tell your robot to drive a distance autonomous and then stop once it reaches that distance.

There is a gyro and an accelerometer included in the Kit of Parts. The gyro is an analog sensor that detects change in angle. Mounting this on the robot parallel to the ground allows you to tell the robot to turn until it reaches 90 degrees (right.)

If you do not use an encoder, gyro, or any other sensor to detect the robot position then the only alternative is a timer based autonomous. You can specify through logic (while statement for SimpleRobot & if then statement for IterativeRobot) to turn on the motors at specific times and turn it off when it shouldn't be running.

Example code of how a timer based autonomous could run. In the example the robot drives backwards for 1 second, sits still for 1 second, and then turn right in place for 1 second.

Code:
Timer timer = new Timer();
Jaguar leftDrive = new Jaguar(1);
Jaguar rightDrive = new Jaguar(2);

autonomousInit() {
  timer.start();
  timer.reset();
}

autonomousPeriodic() {
  double currentTime = timer.get() * MathUtils.pow(10, -6);
  if (currentTime < 2) { //if time is less than 2 seconds
    leftDrive.set(-0.5); //drive left motors backwards
    rightDrive.set(-0.5); //drive right motors backwards
  } else if (currentTime  >= 2 && currentTime < 3) { //time between 2&3 secs.
      leftDrive.set(0);
      rightDrive.set(0);
  } else if (currentTime >= 3 && currentTime < 4) { //time between 3&4 secs.
     leftDrive.set(0.5); //set left forward to turn right
     rightDrive.set(-0.5); //set right backward to turn right in place
  }
}

Last edited by MagiChau : 24-02-2013 at 19:59.
Reply With Quote
  #5   Spotlight this post!  
Unread 24-02-2013, 19:09
F22Rapture's Avatar
F22Rapture F22Rapture is offline
College Student, Mentor
AKA: Daniel A
FRC #3737 (4H Rotoraptors)
Team Role: Mentor
 
Join Date: Jan 2012
Rookie Year: 2012
Location: Goldsboro, NC
Posts: 476
F22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant future
Re: Autonomous Moving Backwards

Just out of curiosity Magi, what does MathUtils.pow(10, 6) do?
__________________
Research is what I’m doing when I don’t know what I’m doing.
- Wernher von Braun
Attending: Raleigh NC Regional
Reply With Quote
  #6   Spotlight this post!  
Unread 24-02-2013, 19:39
MagiChau's Avatar
MagiChau MagiChau is offline
Registered User
AKA: Michael Chau
FRC #0085 (B.O.B. (Built on Brains))
Team Role: Alumni
 
Join Date: Jan 2010
Rookie Year: 2010
Location: Zeeland, Michigan
Posts: 875
MagiChau is just really niceMagiChau is just really niceMagiChau is just really niceMagiChau is just really nice
Re: Autonomous Moving Backwards

Quote:
Originally Posted by F22Rapture View Post
Just out of curiosity Magi, what does MathUtils.pow(10, 6) do?
It raises the first parameter (10) to the second parameter (-6) power. So the result is 10^-6. I probably should use scientific notation instead. I am multiplying the time by this assuming the javadocs is correct that the timer returns the time in micro seconds.

Last edited by MagiChau : 24-02-2013 at 19:59.
Reply With Quote
  #7   Spotlight this post!  
Unread 24-02-2013, 19:49
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,089
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: Autonomous Moving Backwards

Quote:
Originally Posted by MagiChau View Post
It raises the first parameter (10) to the second parameter (6) power. So the result is 10^6. I probably should use scientific notation instead. I am multiplying the time by this assuming the javadocs is correct that the timer returns the time in micro seconds.
You should probably multiply it by 10-6 (if you want seconds).



Reply With Quote
  #8   Spotlight this post!  
Unread 24-02-2013, 19:59
MagiChau's Avatar
MagiChau MagiChau is offline
Registered User
AKA: Michael Chau
FRC #0085 (B.O.B. (Built on Brains))
Team Role: Alumni
 
Join Date: Jan 2010
Rookie Year: 2010
Location: Zeeland, Michigan
Posts: 875
MagiChau is just really niceMagiChau is just really niceMagiChau is just really niceMagiChau is just really nice
Re: Autonomous Moving Backwards

Quote:
Originally Posted by Ether View Post
You should probably multiply it by 10-6 (if you want seconds).

Oops, fixed it now.
Reply With Quote
  #9   Spotlight this post!  
Unread 24-02-2013, 21:41
tuXguy15's Avatar
tuXguy15 tuXguy15 is offline
Team Mentor
AKA: Devin Kolarac
FRC #2559 (Normality Zero)
 
Join Date: Apr 2012
Rookie Year: 2012
Location: Harrisburg, PA
Posts: 127
tuXguy15 is an unknown quantity at this point
Re: Autonomous Moving Backwards

Our team is not using encoders for the drive system only the shooter this year. I just want the robot to drive backwards when the first 3 shots are fired. That takes about 9 seconds i have it for and then it will switch to low gear. then i want it to just drive straight back for the rest of the autonomous period.
Reply With Quote
  #10   Spotlight this post!  
Unread 24-02-2013, 22:07
F22Rapture's Avatar
F22Rapture F22Rapture is offline
College Student, Mentor
AKA: Daniel A
FRC #3737 (4H Rotoraptors)
Team Role: Mentor
 
Join Date: Jan 2012
Rookie Year: 2012
Location: Goldsboro, NC
Posts: 476
F22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant future
Re: Autonomous Moving Backwards

Quote:
Originally Posted by Zer0 View Post
Our team is not using encoders for the drive system only the shooter this year. I just want the robot to drive backwards when the first 3 shots are fired. That takes about 9 seconds i have it for and then it will switch to low gear. then i want it to just drive straight back for the rest of the autonomous period.
In that case, you would want something similar to Magi's example, since that's based on time.

You could also create a commands for driving, shooting, etc. and then string them together in a command group and have them execute in-order. That would require a bit less tuning to get right, though it might take longer to initially program.
__________________
Research is what I’m doing when I don’t know what I’m doing.
- Wernher von Braun
Attending: Raleigh NC Regional
Reply With Quote
  #11   Spotlight this post!  
Unread 25-02-2013, 10:20
eddie12390's Avatar
eddie12390 eddie12390 is offline
Registered User
AKA: Eddie
FRC #3260 (SHARP)
Team Role: Programmer
 
Join Date: Jan 2011
Rookie Year: 2011
Location: Pittsburgh
Posts: 285
eddie12390 is a glorious beacon of lighteddie12390 is a glorious beacon of lighteddie12390 is a glorious beacon of lighteddie12390 is a glorious beacon of lighteddie12390 is a glorious beacon of light
Re: Autonomous Moving Backwards

Quote:
Originally Posted by Zer0 View Post
then i want it to just drive straight back for the rest of the autonomous period.
Be careful that you do not cross the center-of-the-field line
__________________
Any post that I make expresses only my opinions. I do not represent the opinions of my team or of any entity affiliated with my team.

As a Mentor:
2016 - Engineering Inspiration at Greater Pittsburgh Regional

As a Driver:
2014 - Winner of Greater Pittsburgh Regional
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 11:42.

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