Go to Post Let's sheathe the pitchforks and douse the torches for another two months, shall we? - Taylor [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 19-12-2016, 10:31
MuskieProgramme MuskieProgramme is offline
Registered User
FRC #6420
Team Role: Programmer
 
Join Date: Dec 2016
Rookie Year: 2014
Location: Muscatine, IA
Posts: 3
MuskieProgramme is an unknown quantity at this point
Seeking advice for rookie programming

Hello! I'm a member of the newly created FRC Team 6420, and am looking for advice on programming. I've been the main programmer for FTC for the past two years, using Android Studio. You can view my work for this year here.

I'm familiar with Java & IntelliJ, but our main mentor is recommending we use C++ because teams in the area use it and we will be able to get help. I have some limited experience with C++, and no experience with eclipse. I'm aware the Labview exists, but I really don't like any sort of visual programming. It seems exceedingly clunky to me.

So. What would you recommend? Are there online tutorials for FRC programming? How is it similar / different to FTC programming? Anything else you'd like to add?

Thanks!
Reply With Quote
  #2   Spotlight this post!  
Unread 19-12-2016, 11:02
nickbrickmaster's Avatar
nickbrickmaster nickbrickmaster is online now
Not Allowed Near Power Tools
AKA: Nick Schatz
FRC #3184 (Blaze Robotics)
Team Role: Leadership
 
Join Date: Jan 2015
Rookie Year: 2014
Location: Eagan MN
Posts: 152
nickbrickmaster is an unknown quantity at this point
Re: Seeking advice for rookie programming

Welcome to FRC!

WPILIB ScreenStepsLive is the definitive FRC programming tutorial.

If you have experience with Java, I would personally recommend using that. Changing IDEs is a lot easier than changing languages. I've also seen some people using IntelliJ and Gradle to do robot code.

If you know Python (or don't, it's easy to learn!), that's also an option, using robotpy.
__________________
I have approximate knowledge of many things.

FRC 3184: 2014-, FTC 10648: 2015-
Reply With Quote
  #3   Spotlight this post!  
Unread 19-12-2016, 11:03
msonnier msonnier is offline
Engineering Mentor
FRC #2992 (SS Prometheus)
Team Role: Mentor
 
Join Date: Jan 2014
Rookie Year: 2013
Location: United States
Posts: 7
msonnier is an unknown quantity at this point
Re: Seeking advice for rookie programming

There may be other opinions, but I would recommend staying with what you know -- in this case Java. The "pain" of learning C++ just isn't worth it. (And this coming from a mentor who knew C++ and had much more C++ experience prior to starting this mentor gig and having to learn Java). Also, if there continue to be FTC teams that you are drawing students from, you have the advantage of having incoming programming team candidates with Java expertise.

I mentor both FRC (2992) and FTC (8991 and 10337) teams for programming using Java, and we have found the advantage of having incoming FRC students with FTC Java experience to be a great jump starter.

I recommend you check out https://wpilib.screenstepslive.com/s/4485 which is the documentation for the controls and programming from last year. AFAIK the 2017 version is not yet posted (though there is some 2017 beta info at that same site).

Whether you use C++ or Java, you will likely be using Eclipse. It's not that different from Android Studio. Installation instructions at the above website are reasonably easy to follow. Its actually a bit easier to setup for Java than C++.

The API tutorial for Java is pretty decent. You will see a ton of similarity w/ FTC API for accessing hardware and driver station. The IterativeRobot base class is very similar to the OpMode base class for FTC.

While it may seem a bit more complex at first, I strongly recommend you look into the "Command Based" programming model. The "Robot Builder" tool that comes w/ the API is a good way to jump start into Command Based programming. My first year as a mentor, the team had lost all of its programming resources so we were essentially programming rookies. We switched that year from C++ to Java and started off doing IterativeRobot but switched partway through build season to Command Based as it makes Autonomous programming much easier (it enables a base class called CommandGroup similar to LinearOpMode from FTC). Command Based also allows easy multitasking for your robot, with each "subsystem" able to operate fairly independently, making your code easier to implement and troubleshoot.

Finally, make sure you take a look at the SmartDashboard tool and API. This is similar to (but much more powerful than) the Telemetry functions in FTC.

I took a quick look at your FTC code, and it looks good. I don't expect you to have any issues making the FRC transition.

Good luck and have fun
Mike
Reply With Quote
  #4   Spotlight this post!  
Unread 19-12-2016, 11:35
euhlmann's Avatar
euhlmann euhlmann is offline
CTO, Programmer
AKA: Erik Uhlmann
FRC #2877 (LigerBots)
Team Role: Leadership
 
Join Date: Dec 2015
Rookie Year: 2015
Location: United States
Posts: 317
euhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud of
Re: Seeking advice for rookie programming

Disclaimer: my team is switching from C++ to Java this year

C++
ProsCons
  • It allows you to do almost anything. Which is bad sometimes (use smart pointers!)
  • For FRC specifically, the compiler is unusually slow. Large projects can take several minutes to build
  • To display errors, Eclipse basically parses compiler output. It sometimes doesn't work too well
  • Exceptions aren't as sophisticated as in Java. Also I often think the creators of the standard library put making it beautiful C++ before making it actually usable to new programmers. It's beautiful C++ that I don't entirely understand. Luckily in FRC, you don't need to use the standard library a lot
  • Debugging in eclipse is basically a GUI wrapper over GDB (a console program). It can be problematic sometimes

Java
Pros:
  • Safer. It's more restrictive, but it has the advantage that the compiler will catch most problems for you (as opposed to C++ where you'll just get a random segfault)
  • Simple standard library. And you can actually understand the source of most of it, unlike STL which is basically line noise that happens to be valid C++
  • Less file spam. No need for header files, or dealing with cyclic dependencies since the compiler handles it all for you
  • Compiling is fully integrated into Eclipse. It compiles as you write, and gives you instant feedback on errors. In C++, you have to explicitly use the build button before it displays most errors.
  • Debugging is fully integrated into Eclipse, and it's awesome (SE even supports limited code hotswapping. I'm going to test if hotswapping works on ME at some point)
Cons:
  • May be slower (it's interpreted / JIT compiled)
  • It's more restrictive than C++, so some C++ may be necessary for performance hacks (eg, link in C++ pros above)
__________________
Creator of SmartDashboard.js, an extensible nodejs/webkit replacement for SmartDashboard


https://ligerbots.org

Last edited by euhlmann : 19-12-2016 at 11:39.
Reply With Quote
  #5   Spotlight this post!  
Unread 19-12-2016, 16:40
MamaSpoldi's Avatar
MamaSpoldi MamaSpoldi is offline
Programming Mentor
AKA: Laura Spoldi
FRC #0230 (Gaelhawks)
Team Role: Engineer
 
Join Date: Jan 2009
Rookie Year: 2007
Location: Shelton, CT
Posts: 305
MamaSpoldi has a brilliant futureMamaSpoldi has a brilliant futureMamaSpoldi has a brilliant futureMamaSpoldi has a brilliant futureMamaSpoldi has a brilliant futureMamaSpoldi has a brilliant futureMamaSpoldi has a brilliant futureMamaSpoldi has a brilliant futureMamaSpoldi has a brilliant futureMamaSpoldi has a brilliant futureMamaSpoldi has a brilliant future
Re: Seeking advice for rookie programming

Disclaimer/Background: I'm a software engineer with 30+ years experience programming in C and C++, but I know a fair amount of Java as well. I have been working with our FRC team doing C++ code for 11 years. I have no experience with FTC code.

I'm not going to tell you what you should choose, but here are are few points to consider:
  • The syntax of C++ and Java is VERY similar. So if you are familiar with Java, then C++ is not a huge leap.
  • All the points mentioned above by Erik comparing C++ and Java are pretty valid. I would especially emphasize his points that:
  1. Java is interpreted and therefore does not run as fast as C++. This can be a significant issue depending on what you hope to do.
  2. Some of the error messages are pretty poor but if you have local support (or CD support) it is not usually a big issue.
  3. The C++ STL is clunky, but we don't use that in our robot code so this is kind of irrelevant (at least for us).
  • If you already know Java, C++ is the next step in your learning process. I think the biggest mindset change is that C++ is pass by value and Java is pass by reference. This is related to pointers (indirectly) and it basically means that you cannot modify a parameter to a C++ routine unless you pass a pointer to the value.
  • Whatever language you choose, you will have lots of resources available including the ScreenStepsLive mentioned before and mentors of local teams and here on CD.
  • I personally am not a fan of the CommandBasedRobot base class, it requires a lot of infrastructure and relies a lot on tools like the robotBuilder instead of using more common coding principles. Our team uses SampleRobot (formerly SimpleRobot). The architecture that we use makes it very simple to use the same mechanism classes and functionality for teleop and autonomous. If you are interested, here is a link to our code from last year (https://sourceforge.net/projects/frc-team230-2016/). We would be happy to answer any questions you have. In addition I would be happy to send you a copy of the slides I use for the C++ programming "class" that I teach for our students who are interested in programming. I provides a fair overview of into our code architecture.
  • Regardless of your choice there will be times you think it might have been easier if you had made a different choice. Resist the urge to second guess yourself... BOTH ARE GOOD CHOICES.
Good luck! Remember to reach out if you need help. We are all in this together.

Save
Save
Save
Save
__________________

Last edited by MamaSpoldi : 20-12-2016 at 09:53. Reason: typos
Reply With Quote
  #6   Spotlight this post!  
Unread 19-12-2016, 17:47
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,045
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: Seeking advice for rookie programming

I agree with much of what has been said in this thread, but...

Quote:
Originally Posted by MamaSpoldi View Post
Java is interpreted and therefore does not run as fast as C++. This can be a significant issue depending on what you hope to do.
For 99.9% of FRC teams, this doesn't matter. Python is even slower than Java and you can build a high performance robot using it. If you find that you are running into speed issues solely because you're using Java, you're almost certainly doing something wrong and should reevaluate your approach.
__________________
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
  #7   Spotlight this post!  
Unread 19-12-2016, 18:13
euhlmann's Avatar
euhlmann euhlmann is offline
CTO, Programmer
AKA: Erik Uhlmann
FRC #2877 (LigerBots)
Team Role: Leadership
 
Join Date: Dec 2015
Rookie Year: 2015
Location: United States
Posts: 317
euhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud of
Re: Seeking advice for rookie programming

Quote:
Originally Posted by MamaSpoldi View Post
the C++ STL is clunky, but we don't use that in our robot code so this is kind of irrelevant.
I did use it last season. It's not irrelevant if you plan on making a complex program, unless you want to roll your own lists/maps/etc

Quote:
Originally Posted by MamaSpoldi View Post
If you already know Java, C++ is the next step in your learning process. I think the biggest mindset change is that C++ is pass by value and Java is pass by reference. This is related to pointers (indirectly) and it basically means that you cannot modify a parameter to a C++ routine unless you pass a pointer to the value.
Keep in mind that to someone who doesn't already know C++, this statement may be confusing.
Basically, the general idea is that C++ provides several ways to store, transfer, and access data while in Java there's only one way. You don't really need to know this unless you plan on learning C++
__________________
Creator of SmartDashboard.js, an extensible nodejs/webkit replacement for SmartDashboard


https://ligerbots.org
Reply With Quote
  #8   Spotlight this post!  
Unread 19-12-2016, 18:51
FlamingSpork FlamingSpork is offline
Eating Utensil
FRC #3003 (Tan[X])
Team Role: Programmer
 
Join Date: Nov 2014
Rookie Year: 2015
Location: Canandaigua, NY
Posts: 63
FlamingSpork is just really niceFlamingSpork is just really niceFlamingSpork is just really niceFlamingSpork is just really niceFlamingSpork is just really nice
Re: Seeking advice for rookie programming

My team has used C++ for the past several years, but we are switching to Java this year because it's the language our school teaches in a programming course and we're sick of pointers.

I've used both C++ and Java, and I'd say that Java is much easier to work with. Switching from Java to C++ might seem reasonably easy, but there's a bunch of quirks you will need to learn. Nothing is different with syntax, but, as has been mentioned on this thread, the ways data is stored is rather different.
Reply With Quote
  #9   Spotlight this post!  
Unread 19-12-2016, 21:09
GeeTwo's Avatar
GeeTwo GeeTwo is offline
Technical Director
AKA: Gus Michel II
FRC #3946 (Tiger Robotics)
Team Role: Mentor
 
Join Date: Jan 2014
Rookie Year: 2013
Location: Slidell, LA
Posts: 3,572
GeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond repute
Re: Seeking advice for rookie programming

In your situation, I'll unhesitatingly recommend java. Unless you already know c++ quite well, or are working from a considerable existing code base, or are doing something requiring really tight optimization, the "advantages" of C++ over java are really just more rope to hang yourself. It sounds like none of these apply in your situation. Outside of assembler, about the only thing which can cause as much confusion as a pointer arithmetic error with so little effort on the part of the programmer is an abused FORTRAN common block, and for pretty much the same reason.
__________________

If you can't find time to do it right, how are you going to find time to do it over?
If you don't pass it on, it never happened.
Robots are great, but inspiration is the reason we're here.
Friends don't let friends use master links.
Reply With Quote
  #10   Spotlight this post!  
Unread 19-12-2016, 21:30
BrianAtlanta's Avatar
BrianAtlanta BrianAtlanta is offline
Registered User
FRC #1261
Team Role: Mentor
 
Join Date: Apr 2014
Rookie Year: 2012
Location: Atlanta, GA
Posts: 70
BrianAtlanta has a spectacular aura aboutBrianAtlanta has a spectacular aura about
Re: Seeking advice for rookie programming

Another thing to consider when selecting a language, sustainability. We have some good programmers, and they were thinking about switching from Java to C++. There were some robotics stuff that they wanted to try, that might require a faster processing loop than WPI-Lib. So we talked about it. Our high school teaches Java, so if they wanted to switch to another language, they had to be able to develop a program to teach future programmers C++. They then decide that they would stay in Java, since it fits with what the school teaches.

So TLDR, pick a language that's best for the club and can live one
__________________
Reply With Quote
  #11   Spotlight this post!  
Unread 19-12-2016, 22:02
BenBernard BenBernard is offline
Registered User
FRC #5687 (The Outliers)
Team Role: Mentor
 
Join Date: Jan 2016
Rookie Year: 2015
Location: Portland, ME
Posts: 44
BenBernard is on a distinguished road
Re: Seeking advice for rookie programming

There are lots of good arguments on both sides in this thread, but I think that sticking with what your team as a whole knows best will serve you better. When push comes to shove, your team needs to be able to sort out its own code issues--your neighboring teams won't be there in your pit when the inevitable competition-day bugs arise!

I'd also argue that you're more likely to get urgent programming help here on these forums than from neighboring teams--there's simply a MUCH larger pool to draw on here! Think about the number of responses you've received to this question here in less than 12 hours!

Either way you go--good luck! It's a blast!
Reply With Quote
  #12   Spotlight this post!  
Unread 19-12-2016, 22:15
SoftwareBug2.0's Avatar
SoftwareBug2.0 SoftwareBug2.0 is offline
Registered User
AKA: Eric
FRC #1425 (Error Code Xero)
Team Role: Mentor
 
Join Date: Aug 2004
Rookie Year: 2004
Location: Tigard, Oregon
Posts: 486
SoftwareBug2.0 has a brilliant futureSoftwareBug2.0 has a brilliant futureSoftwareBug2.0 has a brilliant futureSoftwareBug2.0 has a brilliant futureSoftwareBug2.0 has a brilliant futureSoftwareBug2.0 has a brilliant futureSoftwareBug2.0 has a brilliant futureSoftwareBug2.0 has a brilliant futureSoftwareBug2.0 has a brilliant futureSoftwareBug2.0 has a brilliant futureSoftwareBug2.0 has a brilliant future
Re: Seeking advice for rookie programming

Quote:
Originally Posted by BenBernard View Post
There are lots of good arguments on both sides in this thread, but I think that sticking with what your team as a whole knows best will serve you better. When push comes to shove, your team needs to be able to sort out its own code issues--your neighboring teams won't be there in your pit when the inevitable competition-day bugs arise!

I'd also argue that you're more likely to get urgent programming help here on these forums than from neighboring teams--there's simply a MUCH larger pool to draw on here! Think about the number of responses you've received to this question here in less than 12 hours!

Either way you go--good luck! It's a blast!
Actually, I do end up in other teams pits from time to time when they have code issues. I suppose that how willing other teams are to help may depend on your region. PNW (where I am) tends to be pretty friendly and I would expect that the midwest (where the OP is) would be as well.

One thing that I will note is that the teams that need help are disproportionately using languages other than C++. This suggests to me that teams are more conservative about moving to it than they need to be.
Reply With Quote
  #13   Spotlight this post!  
Unread 19-12-2016, 22:19
Oblarg Oblarg is offline
Registered User
AKA: Eli Barnett
FRC #0449 (The Blair Robot Project)
Team Role: Mentor
 
Join Date: Mar 2009
Rookie Year: 2008
Location: Philadelphia, PA
Posts: 1,050
Oblarg has a reputation beyond reputeOblarg has a reputation beyond reputeOblarg has a reputation beyond reputeOblarg has a reputation beyond reputeOblarg has a reputation beyond reputeOblarg has a reputation beyond reputeOblarg has a reputation beyond reputeOblarg has a reputation beyond reputeOblarg has a reputation beyond reputeOblarg has a reputation beyond reputeOblarg has a reputation beyond repute
Re: Seeking advice for rookie programming

Quote:
Originally Posted by MamaSpoldi View Post
[*]If you already know Java, C++ is the next step in your learning process. I think the biggest mindset change is that C++ is pass by value and Java is pass by reference. This is related to pointers (indirectly) and it basically means that you cannot modify a parameter to a C++ routine unless you pass a pointer to the value.
This is not quite right - java is actually pass-by-value; when passing objects it passes the value of the reference (not the reference itself!). If you reassign a passed parameter in a java subroutine, it will not change anything outside of the subroutine.

(I've heard some object to this by arguing that it is indeed pass-by-reference, but variable assignment in java is best interpreted as name-binding. But this is not how the language specification describes it.)
__________________
"Mmmmm, chain grease and aluminum shavings..."
"The breakfast of champions!"

Member, FRC Team 449: 2007-2010
Drive Mechanics Lead, FRC Team 449: 2009-2010
Alumnus/Technical Mentor, FRC Team 449: 2010-Present
Lead Technical Mentor, FRC Team 4464: 2012-2015
Technical Mentor, FRC Team 5830: 2015-2016

Last edited by Oblarg : 19-12-2016 at 22:25.
Reply With Quote
  #14   Spotlight this post!  
Unread 19-12-2016, 22:30
SoftwareBug2.0's Avatar
SoftwareBug2.0 SoftwareBug2.0 is offline
Registered User
AKA: Eric
FRC #1425 (Error Code Xero)
Team Role: Mentor
 
Join Date: Aug 2004
Rookie Year: 2004
Location: Tigard, Oregon
Posts: 486
SoftwareBug2.0 has a brilliant futureSoftwareBug2.0 has a brilliant futureSoftwareBug2.0 has a brilliant futureSoftwareBug2.0 has a brilliant futureSoftwareBug2.0 has a brilliant futureSoftwareBug2.0 has a brilliant futureSoftwareBug2.0 has a brilliant futureSoftwareBug2.0 has a brilliant futureSoftwareBug2.0 has a brilliant futureSoftwareBug2.0 has a brilliant futureSoftwareBug2.0 has a brilliant future
Re: Seeking advice for rookie programming

Quote:
Originally Posted by Oblarg View Post
This is not quite right - java is actually pass-by-value; when passing objects it passes the value of the reference (not the reference itself!). If you reassign a passed parameter in a java subroutine, it will not change anything outside of the subroutine.

(I've heard some object to this by arguing that it is indeed pass-by-reference, but variable assignment in java is best interpreted as name-binding. But this is not how the language specification describes it.)
Yeah, I think every Java fan I've ever talked to has insisted that the language is pass by value but the fact that for objects you can only ever have mutable references to them means that all the benefits you'd expect to get with pass by value semantics are effectively destroyed.
Reply With Quote
  #15   Spotlight this post!  
Unread 19-12-2016, 23:31
phurley67 phurley67 is offline
Programming Mentor
FRC #0862 (Lightning Robotics)
Team Role: Mentor
 
Join Date: Apr 2014
Rookie Year: 2013
Location: Michigan
Posts: 65
phurley67 is an unknown quantity at this point
Re: Seeking advice for rookie programming

Hint: Programmers like to argue about their favorite languages :-)

On our team our mentors (myself included) prefer C++ as a language; however, our FTC feeder system (in Michigan FTC is generally a middle school program) is now in Java and our high school AP Programming class is taught in Java. Based primarily on these two factors we (the mentors) supported the idea of using Java even though it is not our personal favorite programming language. Prior to that we had been using LabVIEW which, while I will admit I never grew to love, I least felt I had a pretty good understanding -- but we never found it easy to create work flow that supported 10+ programmers without more discipline than we were able to maintain with high school students during build.

I would suggest writing up a pro and con for each language. Keep in mind your primary goals -- different teams can easily have different goals. For us it was choosing a language which will allow us to engage the most students (we have a large programming sub-group) and field a competitive robot. Other teams may want to prioritize the learning of only one or two programmers and they are personally going to get more out of using C++ or Python -- there is no one perfect answer.
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 21:54.

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