![]() |
Need help understanding command-based Robots
Before the new season starts, I'd like to learn command-based programming. Last year, I used the sample robot. Any sites besides screensteps that I could use? I am confused about the subsystems, commands, and how the drivetrain is made.
Thanks |
Re: Need help understanding command-based Robots
Command: Basically some action that you can define. This might be an autonomous mode action, or a teleop action, or something you use in both modes. initialize() sets up the action to happen, then execute() is repeatedly called until isFinished() is true, then end() is called to clean up.
Example: Code:
public class MoveToPositionCommand extends Command {Example: Code:
public class DriveSubsystem { |
Re: Need help understanding command-based Robots
Have you checked out the robotbuilder? If not it provide a very concrete way to understand how subsystems, commands and OI all fit together. It generates readable code based on your description.
Think of it this way, your robot is composed of one or more subsystems. Each subsystem will have one or more commands associated with it. You will almost always have a subsystem for your drivetrain, which at least initially will probably use either the 2 or 4 motor controller. You will then create a teleop_drive command for your drivetrain controller. Generate the code, and fill in a few blanks and you should be able to get your robot moving pretty quickly. Give that a try and if you get stuck let us know. |
Re: Need help understanding command-based Robots
Quote:
|
Re: Need help understanding command-based Robots
Quote:
|
Re: Need help understanding command-based Robots
Quote:
The code ends up looking something like (but again, let robot builder do the lifting until you get the hang of it): Code:
// where the coPilot and cmdMove2Pos variables are generally |
Re: Need help understanding command-based Robots
Quote:
Quote:
Quote:
|
Re: Need help understanding command-based Robots
After being confused at first about command-based programming, I am now a big fan of it. It allows for some pretty complex movements with organized and reusable code. The one definite downside is that it can actually make the code seem more complex than it actually is to someone who hasn't been working on it because of all the extra file structure and such. There's some other downsides to it if you want to really squeeze every bit of performance out of the roboRIO possible - but 5414 isn't at that point yet. euhlmann covered it and screensteps does a pretty good job in my opinion, but I'll just kind of repeat and add a little bit:
I like to start with the RobotMap - adding in static variable names for whatever motors or buttons you plan on having. For instance you might have: Code:
public class RobotMap {Code:
public class OI {Code:
public class Collector extends Subsystem {Code:
public class CollectorIn extends Command {Hope this helped some. |
Re: Need help understanding command-based Robots
I have my programmers watch these 6 videos. https://www.youtube.com/watch?v=k7PaYcjDEDc&list=PLYA9eZLlgz7t9Oleid2wtlgn vhGObeKzp We are a Java team but these videos do apply to C++ as well. Last year was my first year as a coach, I watched these, Played along and simulated the programs in FRCSim. The one student program we had last year called it "cheating".
|
| All times are GMT -5. The time now is 09:53. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi