Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Java (http://www.chiefdelphi.com/forums/forumdisplay.php?f=184)
-   -   Java Autonomous Help (http://www.chiefdelphi.com/forums/showthread.php?t=118905)

TenaciousDrones 03-09-2013 13:50

Java Autonomous Help
 
I'm David and I am part of Team 4780 and we are a second year team that is switching from LabVIEW to Java. I'm currently having a problem programming autonomous. I have no idea how turn the robot. I know you can turn it by changing the curve value, but can I turn it stationary (pivot). Or even the ratios for different turns at 1/2 speed for whatever amount of time.

ekapalka 03-09-2013 18:31

Re: Java Autonomous Help
 
Is your robot using differential steering? If so, to turn in place you would simply set one side of your drivetrain to a particular speed and the other to the opposite of that. What is your chassis like (and what is this curve value)?

Joe Ross 03-09-2013 18:35

Re: Java Autonomous Help
 
The drive (ie ratio curve) method in wpilib will do a turn in place if you set curve to 1 or -1. The outputMagnitude will determine how fast it will turn in place.

I've always found it simpler to use arcadeDrive or tankDrive in autonomous, and haven't really used the ratio curve method. I recommend using whichever one you used in LabVIEW.

TenaciousDrones 04-09-2013 09:04

Re: Java Autonomous Help
 
I'm a little lost because this is my first year programming. I'm starting from scratch because our old programmer forgot the password and I had to reimage the our computer so I don't have any of our previous data.

By differential steering, do you mean chassis.drive(ROBOT_TASK_PRIORITY, ROBOT_TASK_PRIORITY);?

So if I were to use the curve, it only works at 1.0 or -1.0.

Also I can just use arcade/tank drive to turn? Can you possibly explain how?

Thank you for the help guys.

Also, I have our robot set for arcade drive in teleop and fowards and backwards are fine but the left and right are flipped. Basically up is foward, back is backwards, left is right, and right is left. I can't remember if our robot was like that last year. Is there any way to fix that.

Pault 04-09-2013 17:51

Re: Java Autonomous Help
 
Quote:

Originally Posted by TenaciousDrones (Post 1289870)
I'm a little lost because this is my first year programming. I'm starting from scratch because our old programmer forgot the password and I had to reimage the our computer so I don't have any of our previous data.

By differential steering, do you mean chassis.drive(ROBOT_TASK_PRIORITY, ROBOT_TASK_PRIORITY);?

So if I were to use the curve, it only works at 1.0 or -1.0.

Also I can just use arcade/tank drive to turn? Can you possibly explain how?

Thank you for the help guys.

Also, I have our robot set for arcade drive in teleop and fowards and backwards are fine but the left and right are flipped. Basically up is foward, back is backwards, left is right, and right is left. I can't remember if our robot was like that last year. Is there any way to fix that.

Basically, to use arcade drive during autonomous, create a method in your chassis subsystem that takes in 2 parameters: double speed, double turnRate. The method only needs to contain 1 line: chassis.arcadeDrive(speed, turnRate); From there, just put it into a command like normal, feeding it the speed and turnRate values. To turn in place, just feed it (0, 1) or (0, -1). A similar process applies to tankDrive, only now your parameters are double leftSpeed, double rightSpeed, your line of code is chassis.tankDrive(leftSpeed, rightSpeed); and to turn in place you feed it (1, -1) or (-1, 1).

About the teleop question: are you using 1 joystick, 2 joysticks, or 1 gamepad to drive (only to control the drivetrain, don't include what your operator uses). And could you post the line of code that controls the drivetrain (chassis.arcadeDrive(...);)

TenaciousDrones 04-09-2013 20:26

Re: Java Autonomous Help
 
I'm using one joystick. And the code line is

public void operatorControl() {
chassis.setSafetyEnabled(true);
while (isOperatorControl() && isEnabled())
chassis.arcadeDrive(rightStick);
Timer.delay(0.01);
}

Pault 05-09-2013 15:15

Re: Java Autonomous Help
 
Quote:

Originally Posted by TenaciousDrones (Post 1289941)
I'm using one joystick. And the code line is

public void operatorControl() {
chassis.setSafetyEnabled(true);
while (isOperatorControl() && isEnabled())
chassis.arcadeDrive(rightStick);
Timer.delay(0.01);
}

Oh, you are using the simple robot template. I recommend that you look into the command based robot template. Unless your team has a REALLY simple robot, the simple robot template is going to get really crowded and hard to read really fast. (Hence the name simple robot template).

Anyways... the solution might be a bit more complicated than this; I will check when I get home. Replace chassis.arcadeDrive(rightStick); with chassis.arcadeDrive(rightStick.getY(), - rightStick.getX()); That should invert the turn values.

TenaciousDrones 05-09-2013 20:12

Re: Java Autonomous Help
 
Quote:

Originally Posted by Pault (Post 1290058)
Oh, you are using the simple robot template. I recommend that you look into the command based robot template. Unless your team has a REALLY simple robot, the simple robot template is going to get really crowded and hard to read really fast. (Hence the name simple robot template).

Anyways... the solution might be a bit more complicated than this; I will check when I get home. Replace chassis.arcadeDrive(rightStick); with chassis.arcadeDrive(rightStick.getY(), - rightStick.getX); That should invert the turn values.

What do you mean by command based robot template? And I'll let you know if that fixed once I get to school tomorrow.

Pault 05-09-2013 22:22

Re: Java Autonomous Help
 
Quote:

Originally Posted by TenaciousDrones (Post 1290088)
What do you mean by command based robot template? And I'll let you know if that fixed once I get to school tomorrow.

I checked, this solution should work fine. Incase you didn't catch it, I made a small syntax error; the line of code should be chassis.arcadeDrive(rightStick.getY(), - rightStick.getX());

Basically, when you create a new project for a robot, you have 4 types of templates to choose from. The one that you are using (or at least I think you are using) is called SimpleRobotTemplate. In it, you are just given 1 page with places to put your code for autonomous, operatorControl, disabled, etc. It is very hard to properly organize large ammounts of code inside of this template. That is why the CommandBasedRobotTemplate exists to divide up your code into sections. It is based off of 3 main parts: subsystems, commands, and the OI. It is had to explain, but basically you create a subsystem in code for each subsystem on your robot. This subsystem contains information about that part of the robot. You then create commands for everything that you want your robot to be able to do. The commands use the subsystems to figure out how to do what they need to do. The OI (operator interface) simply figures out "if the driver does X, I should start running command Y".

TenaciousDrones 05-09-2013 22:35

Re: Java Autonomous Help
 
Ok I know what you're talking about now, that makes sense. Well I'll let you know how it works out.

TenaciousDrones 06-09-2013 09:29

Re: Java Autonomous Help
 
So I'm looking into the command based robot template along with the wpilib guide online and I'm a little bit lost. I get what it says I just don't know where to put everything. Would you or anyone else be able to send me a sample so I can better understand?

otherguy 06-09-2013 11:45

Re: Java Autonomous Help
 
There's a pretty good set of tutorials/guides here.

Navigate through the links on the left hand side for different topics.

You could also use the robotbuilder tool to generate complete command based robot projects.

Pault 06-09-2013 14:27

Re: Java Autonomous Help
 
Quote:

Originally Posted by TenaciousDrones (Post 1290171)
So I'm looking into the command based robot template along with the wpilib guide online and I'm a little bit lost. I get what it says I just don't know where to put everything. Would you or anyone else be able to send me a sample so I can better understand?

You could probably get a good sample by clicking on new project in NetBeans and looking in the samples folder.

However, IMHO the best way to learn are the videos on this channel. I have referred people to this channel many times before, and I will keep doing it, because I think it is an amazing resource that we have. You will notice that there are 2 playlists, one that uses robotbuilder and one that doesn't. You can check out otherguy's link to see if it's something that you want to use. FWIW, I highly recommend robotbuilder.

TenaciousDrones 06-09-2013 15:05

Re: Java Autonomous Help
 
Ok thanks guys I'll try these out. I'll let you guys know if I have any more problems.

Ipiano 08-09-2013 20:20

Re: Java Autonomous Help
 
If you use the Command base and/or RobotBuilder, and you decide that you really like it and get the hang of it, you could take a look at my thread here(http://www.chiefdelphi.com/forums/sh...d.php?t=118745) about autonomous. I made a couple of classes you can extend to set up your autonomous so that it's really easy to change.


All times are GMT -5. The time now is 12:52.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi