Go to Post Point is, there is no definite answer. This is FIRST, Whatever works well with your team is the best. - NelsonMichael [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 21-04-2016, 22:43
E, Palmer E, Palmer is offline
Registered User
FRC #6239 (The Irrational Engineers)
Team Role: Programmer
 
Join Date: Jan 2014
Rookie Year: 2009
Location: Maryland
Posts: 15
E, Palmer will become famous soon enoughE, Palmer will become famous soon enough
Command Based V iterative V Custom?

So as this year begins to end I'm looking to next year. I am Programming lead for my team. This year we used the WPI Command Based Form given by FIRST. My question is, for next year, is this form the best option? I was not particularly pleased with the constant overhead that it forces. I do however realize the merit in the system, it allows for beginners to learn structure and the basics of programming in java. Next year however we wont have as many beginners and i was wondering what other teams are doing? is there an established, better way? or is command based the best?
Reply With Quote
  #2   Spotlight this post!  
Unread 21-04-2016, 23:18
mikets's Avatar
mikets mikets is offline
Software Engineer
FRC #0492 (Titan Robotics)
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2008
Location: Bellevue, WA
Posts: 667
mikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of light
Re: Command Based V iterative V Custom?

It's not necessarily better but our team has developed a library for the past eight years. It was in C++ first but we converted it to Java last year when we switched to Java. This year, we even merged with our FTC library so the library is compatible with both FTC and FRC. If you want to take a look, you can access it at GitHub (https://github.com/trc492/Frc2016Fir...Stronghold/src)
The main file is in frc492/Robot.java
Our framework was based on the same concept as Iterative Robot but it supports Cooperative Multi-tasking (multi-task with one thread) so it is easier to learn. You started with putting code in a method called initRobot where it creates the entire robot configuration (drive base and subsystems). Then at the end of initRobot, you create the RobotModes: Autonomous, TeleOp and Test. Each of them implements the RobotMode interface which includes the methods: startMode, stopMode, runPeriodic and runContinuous. startMode and stopMode are methods that will be called one time before the competition mode starts or stops. For example, before autonomous starts, teleop starts, autonomous stops or teleop stops. Then the methods runPeriodic and runContinuous will be called periodically. The difference between runPeriodic and runContinuous is the frequency it is called. runPeriodic is called when there is new driver station data and runContinuous is called in a loop as fast as it can. So typically, TeleOp code goes into runPeriodic and autonomous goes into runContinuous for better resolution.
Not only does this framework makes it a lot easier to write multi-tasking code without the gotcha's of multitasking (i.e. resource contention and tasks synchronization), it also cumulates all the knowledge we learned about different mechanisms. For example, how to use PID control to drive a robot base accurately in all different drive modes: arcade drive, tank drive and mecanum drive. Our PID control for the drive base is overall PID control, not individual motor PID control. It means it will combine encoders, gyro, ultrasonic or any sensors to determine what power should be distributed to each of the motors of the drive base so it will drive straight if you wish so. Also, it supports using PID control to control an elevator/arm so it will hold its position fighting gravity? It also provides supports for event driven actions such as calling you back if a joystick button is pressed or if a limit switch is activated and much more.
__________________

Last edited by mikets : 21-04-2016 at 23:55.
Reply With Quote
  #3   Spotlight this post!  
Unread 28-04-2016, 18:39
Ozuru's Avatar
Ozuru Ozuru is offline
It's always the programmer's fault.
no team
 
Join Date: May 2013
Rookie Year: 2010
Location: Earth
Posts: 268
Ozuru is a splendid one to beholdOzuru is a splendid one to beholdOzuru is a splendid one to beholdOzuru is a splendid one to beholdOzuru is a splendid one to beholdOzuru is a splendid one to beholdOzuru is a splendid one to behold
Re: Command Based V iterative V Custom?

Quote:
Originally Posted by mikets View Post
It's not necessarily better but our team has developed a library for the past eight years. It was in C++ first but we converted it to Java last year when we switched to Java. This year, we even merged with our FTC library so the library is compatible with both FTC and FRC. If you want to take a look, you can access it at GitHub (https://github.com/trc492/Frc2016Fir...Stronghold/src)
The main file is in frc492/Robot.java
Our framework was based on the same concept as Iterative Robot but it supports Cooperative Multi-tasking (multi-task with one thread) so it is easier to learn. You started with putting code in a method called initRobot where it creates the entire robot configuration (drive base and subsystems). Then at the end of initRobot, you create the RobotModes: Autonomous, TeleOp and Test. Each of them implements the RobotMode interface which includes the methods: startMode, stopMode, runPeriodic and runContinuous. startMode and stopMode are methods that will be called one time before the competition mode starts or stops. For example, before autonomous starts, teleop starts, autonomous stops or teleop stops. Then the methods runPeriodic and runContinuous will be called periodically. The difference between runPeriodic and runContinuous is the frequency it is called. runPeriodic is called when there is new driver station data and runContinuous is called in a loop as fast as it can. So typically, TeleOp code goes into runPeriodic and autonomous goes into runContinuous for better resolution.
Not only does this framework makes it a lot easier to write multi-tasking code without the gotcha's of multitasking (i.e. resource contention and tasks synchronization), it also cumulates all the knowledge we learned about different mechanisms. For example, how to use PID control to drive a robot base accurately in all different drive modes: arcade drive, tank drive and mecanum drive. Our PID control for the drive base is overall PID control, not individual motor PID control. It means it will combine encoders, gyro, ultrasonic or any sensors to determine what power should be distributed to each of the motors of the drive base so it will drive straight if you wish so. Also, it supports using PID control to control an elevator/arm so it will hold its position fighting gravity? It also provides supports for event driven actions such as calling you back if a joystick button is pressed or if a limit switch is activated and much more.
@OP - my personal advice is not to bother with this for two reasons:

1) You're new and aren't an expert with FRC's ins and outs. Debugging will be very hard and CD won't be able to help you. The only person that will understand why something is breaking is the maintainer of that software.
2) The project could be discontinued at any time and next year you'll be forced back to the position you are in now.

As someone who has used iterative and command based for multiple (independent) seasons, I feel that command based is more intuitive and powerful than iterative. I view iterative as one giant while(true) loop, while command based has the #basedscheduler and allows subsystems to run in parallel (and be delayed without locking other robot functionality). Also, command based builds off of object-oriented concepts, something new programmers should be very familiar with if they've taken AP Computer Science.

That being said, command based has some flaws, but I personally believe that it has less flaws than iterative. I can go more in-depth into command based's weaknesses if you'd like.
Reply With Quote
  #4   Spotlight this post!  
Unread 04-05-2016, 14:06
Cr1spyBacon8r Cr1spyBacon8r is offline
Registered User
FRC #5203
 
Join Date: Mar 2016
Location: Michigan
Posts: 4
Cr1spyBacon8r is an unknown quantity at this point
Talking Re: Command Based V iterative V Custom?

I'm taking a page out of #254's book to reprogram our robot in the offseason. They use a mix between iterative and command based, which looks really organized (at least compared to ours).
Reply With Quote
  #5   Spotlight this post!  
Unread 04-05-2016, 14:43
notmattlythgoe's Avatar
notmattlythgoe notmattlythgoe is online now
Flywheel Police
AKA: Matthew Lythgoe
FRC #2363 (Triple Helix)
Team Role: Mentor
 
Join Date: Feb 2010
Rookie Year: 2009
Location: Newport News, VA
Posts: 1,717
notmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond repute
Re: Command Based V iterative V Custom?

We have used the Command Based structure since it's inception and have always been very happy with it.
Reply With Quote
  #6   Spotlight this post!  
Unread 04-05-2016, 14:48
Pratik Kunapuli's Avatar
Pratik Kunapuli Pratik Kunapuli is offline
Probably browning-out on Astro-Turf
FRC #1648 (G3 Robotics)(EWCP)
Team Role: Mentor
 
Join Date: Jan 2013
Rookie Year: 2012
Location: Atlanta, GA
Posts: 143
Pratik Kunapuli is a name known to allPratik Kunapuli is a name known to allPratik Kunapuli is a name known to allPratik Kunapuli is a name known to allPratik Kunapuli is a name known to allPratik Kunapuli is a name known to all
Re: Command Based V iterative V Custom?

I've always used iterative, and have no issues with it. Some people say command based is more intuitive, but I've always thought the opposite. I think command based lends itself to automation very well, so I'll definitely be taking a look into it during the summer/offseason. Ultimately, it's easy to try both and figure out what works best for you, just pick the one that you like the best and run with it.
__________________
Official Driving Record: 101-59-0
2012-2015 Student 341 Miss Daisy
2015-Current Mentor 1648 G3 Robotics
Reply With Quote
  #7   Spotlight this post!  
Unread 04-05-2016, 14:50
notmattlythgoe's Avatar
notmattlythgoe notmattlythgoe is online now
Flywheel Police
AKA: Matthew Lythgoe
FRC #2363 (Triple Helix)
Team Role: Mentor
 
Join Date: Feb 2010
Rookie Year: 2009
Location: Newport News, VA
Posts: 1,717
notmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond repute
Re: Command Based V iterative V Custom?

Quote:
Originally Posted by Pratik Kunapuli View Post
I've always used iterative, and have no issues with it. Some people say command based is more intuitive, but I've always thought the opposite. I think command based lends itself to automation very well, so I'll definitely be taking a look into it during the summer/offseason. Ultimately, it's easy to try both and figure out what works best for you, just pick the one that you like the best and run with it.
I wouldn't say intuitive. I've always told people it makes it harder to do very simple things but easier to do more complex things.
Reply With Quote
  #8   Spotlight this post!  
Unread 04-05-2016, 16:43
mikets's Avatar
mikets mikets is offline
Software Engineer
FRC #0492 (Titan Robotics)
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2008
Location: Bellevue, WA
Posts: 667
mikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of light
Re: Command Based V iterative V Custom?

The design of our library is supposed to be as easy to use as Iterative robot but also supports complex scenarios you can find in command-based code but simpler to understand.
__________________
Reply With Quote
  #9   Spotlight this post!  
Unread 07-05-2016, 12:14
Bell-Inequaliy's Avatar
Bell-Inequaliy Bell-Inequaliy is offline
Registered User
AKA: Josh
FRC #5332 (Toaster Tech)
Team Role: Programmer
 
Join Date: Mar 2015
Rookie Year: 2013
Location: Georgia
Posts: 4
Bell-Inequaliy is an unknown quantity at this point
Re: Command Based V iterative V Custom?

Sorry to hop on a bit late, it took me a little while to prepare what I was going to show you. If you want to look at an example of a custom coded but non-library structure, take a look here:

https://github.com/ToasterTechFRC/Toaster-Base-Bot

It is built off of the iterative model but it has a structure similar to command-based. It does require a bit more knowledge of Java than entry-level but it does show how a custom structure can be created manually to fit your needs. I've also documented it as best I can. Our 2016 code (we haven't pushed our CMP code) is also on GitHub, but it is much messier and has significantly less comments although it does show how our structure can function with autonomous modes.
Reply With Quote
  #10   Spotlight this post!  
Unread 10-05-2016, 19:53
mikets's Avatar
mikets mikets is offline
Software Engineer
FRC #0492 (Titan Robotics)
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2008
Location: Bellevue, WA
Posts: 667
mikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of light
Re: Command Based V iterative V Custom?

Quote:
Originally Posted by Bell-Inequaliy View Post
Sorry to hop on a bit late, it took me a little while to prepare what I was going to show you. If you want to look at an example of a custom coded but non-library structure, take a look here:

https://github.com/ToasterTechFRC/Toaster-Base-Bot

It is built off of the iterative model but it has a structure similar to command-based. It does require a bit more knowledge of Java than entry-level but it does show how a custom structure can be created manually to fit your needs. I've also documented it as best I can. Our 2016 code (we haven't pushed our CMP code) is also on GitHub, but it is much messier and has significantly less comments although it does show how our structure can function with autonomous modes.
Your code implemented a framework. It is a light weight framework but it is still essentially a library although it is structured not very library friendly (i.e. all reusable code scattered in various folders instead of concentrating in one library folder).
__________________
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 14:42.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


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