![]() |
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.
|
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)?
|
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. |
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. |
Re: Java Autonomous Help
Quote:
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(...);) |
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); } |
Re: Java Autonomous Help
Quote:
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. |
Re: Java Autonomous Help
Quote:
|
Re: Java Autonomous Help
Quote:
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". |
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.
|
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?
|
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. |
Re: Java Autonomous Help
Quote:
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. |
Re: Java Autonomous Help
Ok thanks guys I'll try these out. I'll let you guys know if I have any more problems.
|
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 09:59. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi