![]() |
Help for a beginner
Hey guys! I'm relatively new to coding and I decided to learn some more before next year.
I've learned mostly simple stuff for "regular" java coding, like if-then-else, while, how to print lines, variables, etc. How do I apply this to coding a robot? |
Re: Help for a beginner
The biggest thing to realize is that programming for a robot has a different mindset most of the time than a desktop application.
Unlike a desktop application you are usually not doing one set of instructions in a set order then exiting the program. You usually have a "control loop". The code should maintain the state of the robot every so often, taking in inputs such as sensors, joysticks, etc, and send outputs such as giving motors power, activating pneumatics, etc. I would definitely try to build a testing board to play with if you have the materials available to you. There are a lot of templated things available for you in the WPILib (such as the SimpleRobot, IterativeRobot, and CommandBasedRobot templates). The FRC plugins also come packaged with a multitude of example projects that I suggest poking through and trying to understand. |
Re: Help for a beginner
|
Re: Help for a beginner
Here is a list of things i went through to learn java for FRC.
http://www.youtube.com/watch?v=4vYij44HWfo http://www.youtube.com/watch?v=_LU5UhxsrCA http://www.youtube.com/watch?v=PYsmIhvKmdo http://www.youtube.com/watch?v=5Uz1yldz2FE http://www.youtube.com/watch?v=AkEdmYjPEOU http://wpilib.screenstepslive.com/s/3120/m/7885 http://robotics.francisparker.org/javadoc/ http://first.wpi.edu/FRC/frcjava.html http://first.wpi.edu/Images/CMS/Firs...va_for_FRC.pdf http://first.wpi.edu/Images/CMS/Firs...sers_Guide.pdf |
Re: Help for a beginner
Thanks so much for your help! Unfortunately I haven't been able to gain access to a test board, but I've been given permission to use an older robot.
I can get it to move forward autonomously for as long as I want...that's about it. How can I code simple autonomous, like going in a box? |
Re: Help for a beginner
Are you using the RobotDrive feature or no?
|
Re: Help for a beginner
Here is a very stripped down version of our autonomous. This shoots the frisbees.
Code:
// Int |
Re: Help for a beginner
Yes, I'm using RobotDrive.
Thank you for the sample code! Another quick question- how do I read the API exactly? (This one http://robotics.francisparker.org/javadoc/ ) Yes, I'm very new to this, but I'm determined to become an able coder by the beginning of the upcoming year. |
Re: Help for a beginner
Don't worry this is my first year doing java for my team and it worked out great. I can try to explain the API to you the best i can. It basically has everything that the wpi library has to help or tell you what features are there and how to use them. Like for jaguar. If you find the jaguar on there it says:
Constructor Summary Jaguar(int channel) Constructor that assumes the default digital module. Jaguar(int slot, int channel) Constructor that specifies the digital module. So i dont need to specify a slot when im constructing this. So in my code it is Jaguar jaguar1 = new "Jaguar(1)"; The quotations dont go in the code they are to show you what the API says to do to construct it. void set(double speed) Set the PWM value. for this i can do if(joystick1.getRawButton(1)) { jaguar1.set(0.64); //the jaguar values are -1 to 1 and 0 is no output } else { jagaur1.set(0.0); } I dont know if this helped you at all or not. Hopefully it did. |
| All times are GMT -5. The time now is 10:01. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi