Go to Post Welcome to ChiefDelphi a month before Kick-Off. This is an annual traditional experience for quite a few regulars. - synth3tk [more]
Home
Go Back   Chief Delphi > Technical > Programming
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 27-11-2016, 15:38
PopeRyanI PopeRyanI is offline
Registered User
FRC #2410 (Metal Mustangs Robotics)
Team Role: Programmer
 
Join Date: Dec 2014
Rookie Year: 2012
Location: Kansas
Posts: 22
PopeRyanI is an unknown quantity at this point
Re: IterativeRobot, CommandRobot, or SampleRobot for brand new programmers?

Quote:
Originally Posted by trycatch View Post
Hello all

I'm a programming mentor for a team with a lot of students with very, very little programming experience at all. To me, it looks clear that SampleRobot is by far the most straight forward way to go - honestly, if I'm understanding right, SampleRobot is much more "write out what you want it to do in what order," as opposed to having to keep track of a state machine in Iterative.
I have mixed feelings about CommandBased - as a programmer (who's made a few robots), it seems VERY overly complex, especially for brand new programmers, to require entirely separate classes for every single thing you want the robot to do, especially when every command class is a single function. SampleRobot really seems like the most straightforward and traditional way.
Hello, my team uses SampleRobot and I definitely agree that I think it is a lot more intuitive than Iterative. Being able to control how frequently it looped rather than waiting for a packet was more logical for our programmers. We never really got involved with CommandBased because we did not like all of the boilerplate code and thought that it was rather confusing with so many different classes.

Quote:
But I do have a couple of quick questions - if using SampleRobot, do I have to check periodically if the robot has been disabled (IsAutonomous() && IsEnabled()), or will this be caught in Timer.Delay() pauses? I've mentored for FTC previously, and the autonomous thread would be killed if you disabled it when the main thread got control for a bit, i.e., when you delayed the Autonomous thread for a few milliseconds at least.
We have never had problems with our autonomous ever accidentally being disabled and, as a result, have not had to check during auto if the robot is enabled. This includes running Wait() to pause the robot (for C++, Timer.delay() for Java is comparable). In addition, we found that SampleRobot made more sense in this instance because running autonomous code every 20 ms or so did not seem to make sense.

Quote:
The WPILIB documentation makes it sound like the SampleRobot class is a lot harder to use, but I don't really understand why. What am I missing?
Honestly, the only part that might be a little confusing for new programmers is handling the looping within SampleRobot, but with some experience, I think it is more straight forward.

In case it helps out, here is my team's code for this past year's robot: https://github.com/CAPS-Robotics/201...ree/master/src

We did use C++ for this and it seems that you use Java, but the same basic idea is present (just ignore all of the pointer fun). We used SampleRobot for this code and you can see that the autonomous does not actually check if it is still enabled. We ran this code in competition and never had any problems with the autonomous disabling during a match.
Disclaimer: I wrote some of this code, so it is not necessarily very good, but I hope it at least helps with the basic ideas.
Reply With Quote
  #2   Spotlight this post!  
Unread 27-11-2016, 17:02
virtuald's Avatar
virtuald virtuald is offline
RobotPy Guy
AKA: Dustin Spicuzza
FRC #1418 (), FRC #1973, FRC #4796, FRC #6367 ()
Team Role: Mentor
 
Join Date: Dec 2008
Rookie Year: 2003
Location: Boston, MA
Posts: 1,058
virtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant future
Re: IterativeRobot, CommandRobot, or SampleRobot for brand new programmers?

Just because you can do something and it doesn't break does not mean one should do so.

A great example of why loops are dangerous are these two bits of code in your autonomous: https://github.com/CAPS-Robotics/201...anOWar.cpp#L89

Code:
while (!aligned) {
   ... do things
}
If your gyro breaks (maybe the wire gets messed up on accident), your robot will never enter teleoperated mode and that match is over for you.

Same thing here:

Code:
do {
... fire = someSensor > some_value
} while (!fire)
If your encoder breaks/gets disconnected, same business. You're done.

Maybe you have magic hardware that never breaks, but I wouldn't put my trust in that.
__________________
Maintainer of RobotPy - Python for FRC
Creator of pyfrc (Robot Simulator + utilities for Python) and pynetworktables/pynetworktables2js (NetworkTables for Python & Javascript)

2017 Season: Teams #1973, #4796, #6369
Team #1418 (remote mentor): Newton Quarterfinalists, 2016 Chesapeake District Champion, 2x Innovation in Control award, 2x district event winner
Team #1418: 2015 DC Regional Innovation In Control Award, #2 seed; 2014 VA Industrial Design Award; 2014 Finalists in DC & VA
Team #2423: 2012 & 2013 Boston Regional Innovation in Control Award


Resources: FIRSTWiki (relaunched!) | My Software Stuff
Reply With Quote
  #3   Spotlight this post!  
Unread 27-11-2016, 18:30
PopeRyanI PopeRyanI is offline
Registered User
FRC #2410 (Metal Mustangs Robotics)
Team Role: Programmer
 
Join Date: Dec 2014
Rookie Year: 2012
Location: Kansas
Posts: 22
PopeRyanI is an unknown quantity at this point
Re: IterativeRobot, CommandRobot, or SampleRobot for brand new programmers?

Quote:
Originally Posted by virtuald View Post
If your gyro breaks (maybe the wire gets messed up on accident), your robot will never enter teleoperated mode and that match is over
Maybe you have magic hardware that never breaks, but I wouldn't put my trust in that.
Wait that is a thing? This is my first year as the head robot programmer for the team and I never realized that it was possible that the robot could get stuck in autonomous and never enter teleop. I thought that the FCS changed modes automatically and that any residual problems from the autonomous would not affect the teleop.
Reply With Quote
  #4   Spotlight this post!  
Unread 27-11-2016, 18:34
virtuald's Avatar
virtuald virtuald is offline
RobotPy Guy
AKA: Dustin Spicuzza
FRC #1418 (), FRC #1973, FRC #4796, FRC #6367 ()
Team Role: Mentor
 
Join Date: Dec 2008
Rookie Year: 2003
Location: Boston, MA
Posts: 1,058
virtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant future
Re: IterativeRobot, CommandRobot, or SampleRobot for brand new programmers?

Quote:
Originally Posted by PopeRyanI View Post
I thought that the FCS changed modes automatically and that any residual problems from the autonomous would not affect the teleop.
That is incorrect.

Use the source, Luke.

As you can see from the source of SampleRobot, if you never return from the Autonomous function, OperatorControl will never be called. No magic here.
__________________
Maintainer of RobotPy - Python for FRC
Creator of pyfrc (Robot Simulator + utilities for Python) and pynetworktables/pynetworktables2js (NetworkTables for Python & Javascript)

2017 Season: Teams #1973, #4796, #6369
Team #1418 (remote mentor): Newton Quarterfinalists, 2016 Chesapeake District Champion, 2x Innovation in Control award, 2x district event winner
Team #1418: 2015 DC Regional Innovation In Control Award, #2 seed; 2014 VA Industrial Design Award; 2014 Finalists in DC & VA
Team #2423: 2012 & 2013 Boston Regional Innovation in Control Award


Resources: FIRSTWiki (relaunched!) | My Software Stuff
Reply With Quote
  #5   Spotlight this post!  
Unread 27-11-2016, 20:05
feverittm's Avatar
feverittm feverittm is offline
Registered User
FRC #0997 (Spartans)
Team Role: Mentor
 
Join Date: Apr 2010
Rookie Year: 2010
Location: Corvallis, OR
Posts: 122
feverittm will become famous soon enoughfeverittm will become famous soon enough
Re: IterativeRobot, CommandRobot, or SampleRobot for brand new programmers?

I have been working with our programmers for a while now and have been working with the WPILIBJ since the beginning in 2010.

Our team uses the command based framework. We like the way we can modularize the code: Break apart functionality into Subsystems, Define commands that operate on those subsystems and then connect the overall system together in the Robot.java code segment while abstracting the harward connections away in the RobotMap layer.

you can get a better look at this methodology by reviewing the Gearsbot code and if you look on Youtube there are videos on this system as well that explain it quite well.

I have looked at he RobotBuilder and in some places it can work reasonably. However, it does make it more difficult to understand your code and our programmers are not a fan of placing all the constructors in the RobotMap file. I use it VERY early in the development to help understand the connections and plan the structure of the code. I can also use it to help with quick testing of systems without having to focus on having everything in place; you can define the subsystems with all their sensors and actuators, then use the 'Testing' mode on the dashboard to verify system functionality.

I know that these capabilities can be developed using the other programming systems, like IterativeRobot, but we find this way easier.

Enjoy!

Floyd Moore
__________________
Floyd Moore
Mentor Electrical and Pneumatics
Team 997 - Spartan Robotics
Corvallis High School, Corvallis Oregon
Reply With Quote
  #6   Spotlight this post!  
Unread 27-11-2016, 21:05
trycatch's Avatar
trycatch trycatch is offline
Registered User
FRC #5858
 
Join Date: Nov 2015
Rookie Year: 2015
Location: AL
Posts: 29
trycatch is on a distinguished road
Re: IterativeRobot, CommandRobot, or SampleRobot for brand new programmers?

Quote:
Originally Posted by virtuald View Post
That is incorrect.

Use the source, Luke.

As you can see from the source of SampleRobot, if you never return from the Autonomous function, OperatorControl will never be called. No magic here.
Yeah, I found that earlier today... if there was a way to break back out of this simply without having to constantly poll, SampleRobot would honestly be perfect. I spent a bit stewing on creating a new extension to RobotBase that would spawn killable threads for autonomous and teleop, but that would require thread.stop(), which has it's own issues. If it got killed in the middle of an i2c command, it could pick up the device it was talking to.
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 03:58.

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