
05-02-2015, 10:11
|
|
Programming Mentor
AKA: Craig Stelter
 FRC #3018 (Nordic Storm)
Team Role: Mentor
|
|
Join Date: Apr 2012
Rookie Year: 2012
Location: Mankato, MN
Posts: 77
|
|
|
Re: Really underhanded
Quote:
Originally Posted by Kyorox
I will look into this though out the day, we havent dabbled much with Robot builder, as we have been waiting for our programming mentor (who we only see on saturdays) to assist us with this matter. With these instructions and what i have found elsewhere its worth the shot.
Please ignore my ignorence, on our team we really stress the "The Kids Run The Team" Motto, so I have had a lot on my plate and offered not to be the head programmer for this exact reason.
|
There are advantages and disadvantages to the RobotBuilder /CommandBase approach. I only outlined the above because it is possible to use the framework to get a mecanum drive up and running in 10-15 minutes. Also, I'd like to see as many teams as possible adopt this approach as I believe it is the best long-term approach for any team.
Disadvantages - Takes more time to wrap your head around. You have to start thinking 'object oriented'
- To truly master CommandBase paradigm, you must learn computer science concepts such as polymorphism, inheritance, data abstraction and encapsulation, but you can be successful with only a rudimentary understanding
- It is possible to try to use the CommandBase framework and do it so badly that you get almost no benefit from it. Misusing commands or not properly abstracting what your subsystem can do or hiding the subsystem's internals can lead you into the weeds
- The robot code generated by RobotBuilder with no functionality is more code than many teams code for a fully functioning robot. You don't *need* to know exactly how all that code works, although the more you understand, the more successful you can be. If you don't have a clue what the scheduler is and how it work, it hampers your ability. If you don't understand what is happening in TeleopPeriodic() and how that gets you to your command's execute() method, it will hamper your ability. In other words-- using RobotBuilder starts you with a lot of code that you probably want to read about.
- learning RobotBuilder is an investment in time early on that is not always conducive to the FRC hectic pace.
Advantages:- Once you have gotten over the learning curve, or if you have a mentor who fully understands the framework-- it is the most powerful way to get to sophisticated control.
- For large teams, the framework allows for groups to break up and take responsibility for separate subsystems in your robot-- each team responsible for coding the functionality of one part and the commands to control them.
- Learning this will give you a head start on college and toward a career in computer science. My son was lead programmer for our team the past 3 years and is now a freshman in college studying computer science. His first semester he was required to take an intro to C++ class (which was fine as he'd not learned C++ yet), but because he had been working with objects and object oriented concepts that CommandBase promotes, he quickly found himself helping other students after class. He was also asking his teacher far more advanced questions than a typical freshman and the teacher noticed all this and hired him as TA for one of her classes his second semester.
- Proper application of the CommandBase framework will make your code far easier to understand and write. You will avoid common issues that arise when one does *not* use CommandBase. You will never find yourself writing code to loop until something happens, or trying to maintain a mess of global variables. Instead of one big nasty function to handle everything, you find yourself writing many very short functions and it is always easy to read 6 lines of code and be sure it will do what you intend it to do rather than reading 150 lines of code an be sure it will do what it is supposed to do.
Truth in advertising disclosure: The electrical team delivered our practice chassis with the shiny new roboRIO to the programmers at 6pm a couple weeks ago. The previous session we had done the first RobotBuilder portion of the sequence but hit a wall because wpilib was not being introduced into the project and none of the functions from wpilib were resolving. We spent 1hr realizing that we had installed Eclipse/Java instead of Eclipse/C++ (didn't read the install directions carefully enough). It took us a full hour to write the 7 lines of code noted above and we kept having to revisit RobotBuilder because my style of teaching is 'OK-- what do we do next? What do we need now that we have this DriveTrain???' What can we currently do with it?? What methods are avaliable to us? They look and realize the class as written from RobotBuilder does nothing but set the default command and that is nothing but comments. So I taught them the concept of adding functionality to a class by providing useful methods and we wrote mecanumDrive and taught them the whole 'just type robotDrive41 and press period' to see what functionality exists on a RobotDrive object, etc. etc.
Finally after 30-40 minutes and teaching what a double is and what parameters are, etc... we wound up with the mecanumDrive() function. Then I ask 'OK-- so now we have a subsystem called DriveTrain that has the functionality of something called mecanumDrive on it. How can we make use of this? How can we command it to do something??
Eventually we arrive at the discussion that we need commands to control subsystems, go back to robot builder and add in DriveWithJoystick, we talk about Scheduler and the role it plays and why we need requires'. Then we get to the question 'OK-- so what else do we need now that we have a command that can control our DriveTrain???' Eventually after much prodding I get them to realize that we need Joystick input and we add the Joytick. By the time we review how a command works and fill out the execute() function there is only one hour left and we spent that flashing the roboRio, etc.
We spent the first hour of the next session setting up routers figuring out how to deploy the code. It took us a full 4 hours of FRC practice following the general cookbook I outlined in my previous post until we even downloaded our first set of code. Thankfully things were working pretty good out of the gate-- one wheel was not spinning at all-- we replaced PWM and it started working. We realized that when we tried to drive forward the right wheels went backwards and I had them invert the right side. So even though you *can* get up and running in 10-15 minutes with the above cookbook-- to properly learn what is going on along the way and be successful when you don't know all the answers going in, you may find yourself needing 3-4 hours.
|