OCCRA
Go to Post Sadly this bot uses better punctuation and capitalization than many on this site. - Andrew Schreiber [more]
Home
Go Back   Chief Delphi > Technical > Programming > C/C++
CD-Media  
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 05-02-2016, 08:58 PM
shui054 shui054 is offline
Registered User
AKA: Sam Hui
FRC #1257 (Parallel Universe)
 
Join Date: Nov 2015
Rookie Year: 2014
Location: Scotch Plains, New Jersey
Posts: 18
shui054 will become famous soon enough
Beginners Programming in C++

My team (FRC 1257) uses C++ to program the robot and I'd like to learn it. I've never really written code in anything except basic Python. Are there any good resources you know of to learning C++? Or how did you guys learn?

Any assistance would be amazing!
Reply With Quote
  #2   Spotlight this post!  
Unread 05-02-2016, 09:22 PM
CalTran's Avatar
CalTran CalTran is offline
Will MC/GA for food
FRC #2410 (BV CAPS Metal Mustang Robotics)
 
Join Date: Apr 2010
Rookie Year: 2010
Location: Overland Park, Kansas
Posts: 2,797
CalTran has a reputation beyond reputeCalTran has a reputation beyond reputeCalTran has a reputation beyond reputeCalTran has a reputation beyond reputeCalTran has a reputation beyond reputeCalTran has a reputation beyond reputeCalTran has a reputation beyond reputeCalTran has a reputation beyond reputeCalTran has a reputation beyond reputeCalTran has a reputation beyond reputeCalTran has a reputation beyond repute
Re: Beginners Programming in C++

I've heard good things about Code Academy. Personally, I learned at a summer camp and subsequently took the C++ Intro class in college. You could look into a local community college and see if they offer a summer course or something.

As well, the WPI Library is a good place to start once you have a good handle on the basics of coding and want to know more about FRC specific applications.
__________________
Team 2410 thinks KISSing is amazing! Keep It Super Safe!
  • "You know you've been in robotics too long when you start talking to your tools." "Well, you've been in robotics CLEARLY too long when they start talking back"
  • Theory is when you know everything but nothing works. Practice is when everything works but you don't know why. On our team, theory and practice comes together - nothing works and nobody knows why.
MMR 2410 Student (2010 - 2013) | MMR 2410 Mentor (2013 - Present)
FTC Game Announcer / MC (2014 - Present) | FTC Referee (2017-Present)
FRC MC (2015 - Present) | FRC Referee (2016-17) | FRC A/V (2017) | FRC Robot Inspector (2018)
VEX MC (2017-Present)
Reply With Quote
  #3   Spotlight this post!  
Unread 05-02-2016, 10:26 PM
rich2202 rich2202 is offline
Registered User
FRC #2202 (BEAST Robotics)
Team Role: Mentor
 
Join Date: Jan 2012
Rookie Year: 2012
Location: Wisconsin
Posts: 1,498
rich2202 has a reputation beyond reputerich2202 has a reputation beyond reputerich2202 has a reputation beyond reputerich2202 has a reputation beyond reputerich2202 has a reputation beyond reputerich2202 has a reputation beyond reputerich2202 has a reputation beyond reputerich2202 has a reputation beyond reputerich2202 has a reputation beyond reputerich2202 has a reputation beyond reputerich2202 has a reputation beyond repute
Re: Beginners Programming in C++

https://www.edx.org/course/introduct...soft-dev210x-1
__________________

Reply With Quote
  #4   Spotlight this post!  
Unread 05-02-2016, 10:58 PM
connor.worley connor.worley is offline
Registered User
FRC #5499
 
Join Date: Mar 2011
Rookie Year: 2010
Location: Berkeley
Posts: 768
connor.worley has a reputation beyond reputeconnor.worley has a reputation beyond reputeconnor.worley has a reputation beyond reputeconnor.worley has a reputation beyond reputeconnor.worley has a reputation beyond reputeconnor.worley has a reputation beyond reputeconnor.worley has a reputation beyond reputeconnor.worley has a reputation beyond reputeconnor.worley has a reputation beyond reputeconnor.worley has a reputation beyond reputeconnor.worley has a reputation beyond repute
Re: Beginners Programming in C++

learncpp.com has super comprehensive tutorials. Heavy on the text, but if you bear with it you'll learn a lot.
__________________
Team 5499 (2015-present)
Past Teams: Team 973 (2016-2017) / Team 254 (2014-2015) / Team 1538 (2011-2014)
日本語副専攻です!話しましょう!
I work for Yelp on the Core Services team. Looking for a referral? Send me a message.
Reply With Quote
  #5   Spotlight this post!  
Unread 05-03-2016, 12:23 AM
jmullins16's Avatar
jmullins16 jmullins16 is offline
Registered User
AKA: Jeff Mullins
FRC #2135 (Presentation Invasion)
Team Role: Mentor
 
Join Date: Nov 2011
Rookie Year: 2011
Location: San Jose, CA
Posts: 35
jmullins16 is a glorious beacon of lightjmullins16 is a glorious beacon of lightjmullins16 is a glorious beacon of lightjmullins16 is a glorious beacon of lightjmullins16 is a glorious beacon of light
Re: Beginners Programming in C++

As a new C++ programmer, I encourage you to look at RobotBuilder and the Command-based robot template provided in the FRC tools. RobotBuilder is a graphical interface that will provide a set of C++ template files that are easy to work in. Even with only basic C++ skills, you can get a drivetrain defined and implemented very quickly. It will let you focus on how to make your robot work using C++ since it sets up all the files and syntax for an organized project.
Reply With Quote
  #6   Spotlight this post!  
Unread 08-03-2016, 05:40 PM
Mitchell C Mitchell C is offline
Registered User
FRC #0313
 
Join Date: Jan 2016
Location: Michigan
Posts: 15
Mitchell C is an unknown quantity at this point
Re: Beginners Programming in C++

I've been working on a C++ guide on my team website http://www.bioniczebras.net/c++_guide.shtml
its not completely done but the only thing im still working on is the fancier auton verson. It uses Iterative as opposed to command based like most.
Reply With Quote
  #7   Spotlight this post!  
Unread 08-03-2016, 06:27 PM
euhlmann's Avatar
euhlmann euhlmann is offline
Alum
AKA: Erik Uhlmann
FRC #2877 (LigerBots)
Team Role: Alumni
 
Join Date: Dec 2015
Rookie Year: 2015
Location: United States
Posts: 453
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 ofeuhlmann has much to be proud of
Re: Beginners Programming in C++

I've found the most important part of learning C++ to be understanding how memory management works (that might just be because I came from a Java background though )

Once you have a somewhat firm grasp on C++, I highly recommend writing a basic robot program from scratch. Run it on a test bot if your team has one, or use the WPILib simulator.

Or you could always switch to RobotPy
__________________
Creator of SmartDashboard.js, an extensible nodejs/webkit replacement for SmartDashboard


https://ligerbots.org
Reply With Quote
  #8   Spotlight this post!  
Unread 07-27-2018, 06:46 PM
calcmogul's Avatar
calcmogul calcmogul is offline
WPILib Developer
AKA: Tyler Veness
FRC #3512 (Spartatroniks)
Team Role: Mentor
 
Join Date: Nov 2011
Rookie Year: 2012
Location: Hawthorne, CA
Posts: 109
calcmogul has much to be proud ofcalcmogul has much to be proud ofcalcmogul has much to be proud ofcalcmogul has much to be proud ofcalcmogul has much to be proud ofcalcmogul has much to be proud ofcalcmogul has much to be proud ofcalcmogul has much to be proud ofcalcmogul has much to be proud ofcalcmogul has much to be proud of
Re: Beginners Programming in C++

My team uses C++. The way I teach it is pretty tightly integrated with the software engineering principles I try to impart and the actual applications in FRC. I do that because it's a lot easier to get students through the syntactic gotchas of C++ if they have interesting applications to work on. I think how you use the language at hand to solve FRC problems is more important than just learning a new language, so having context for how the learning resources fit into the overall pedagogy is important.

Note that a lot of the feedback portions require a dedicated software mentor, so this regimen may not work for everyone.

C++

To teach my students C++, I use the book Programming: Principles and Practice Using C++ (2nd edition) by Bjarne Stroustrup. I like it because it's designed for independent learning, works well for teaching students programming from scratch, and covers modern C++ idioms. A lot of the C++ resources I see online don't follow best practices. By the way, those best practices are here: https://isocpp.github.io/CppCoreGuid...CoreGuidelines.

With regard to memory management, try to think about ownership in terms of "who cleans this up when I'm done with it?". The short version is don't use the new and delete keywords for anything; prefer stack variables; if you need something on the heap, use std::unique_ptr for sole ownership; and use std::shared_ptr for shared ownership. I rarely use std::shared_ptr in my experience because a lot of ownership scenarios don't represent true shared ownership. They are either a stack variable with only one object looking at it or a std::unique_ptr with a non-owning pointer to it somewhere else.

The online resources I put together for my students are here: https://csweb.frc3512.com/ci/cs01/. I usually walk them through a chapter per week, then they do the exercises and I provide implementation and style feedback on their solutions. They make any corrections, and then we move on. This introduces them to the concept of code review.

Git

At the same time, I give them a lecture on Git (the HTML slides I use on at https://csweb.frc3512.com/ci/git01/, and I have my students submit the solutions mentioned earlier via Git. I try to emphasize how Git is basically an application of graph theory, because having that deeper understanding has saved our butts a couple times at competition when my students start doing hairy things to the branches and history.

One of my students even dug into the reflog at one point to get back some old commits because he wasn't following good branching hygeine, but the fact he was able to recover himself is a testament to how flexible Git is when you really understand it. I try to teach my students enough to avoid https://xkcd.com/1597/ at all costs, because you should never need to abort and do a fresh clone.

We use Gerrit for code review because I like the rebase workflow better than the merge workflow of GitHub (and we enforce rebases through the admin interface). I cover more of how to do that stuff in the presentation at https://csweb.frc3512.com/ci/git02/. I still need to go through those and expand on the lecture notes.

As far as branch hygeine, you keep master as the working version and give branches descriptive names and commit messages (no "Fixes " branch and also "Fixes the issue for real, I promise" with no indication as to which is the real "working" branch). A big part of in code review contexts is maintaining a clean commit history. I despise merge commits for this reason; they are just noise (last I checked, Brad was tied for most commits in wpilibc/wpilibj if you include the huge number of merge commits). Just rebase against master since you're doing that merging work either way and you get cleaner history with a rebase. Rebasing a PR on GitHub or a changeset on Gerrit is technically modifying public history, but we treat those branches as private so the author can rebase it to produce a branch that is easier to review.

WPILib

After we cover most of the C++ material, we move into doing state machines, starting with a lecture on what that is (https://csweb.frc3512.com/ci/frc01/) and then designing an auto-stacking state machine for our 2015 robot together https://csweb.frc3512.com/ci/frc01/state-machine/. Once we finish the state machine diagram, the students fill in the template provided with their state machine logic. I review it and test it against my working copy. I'll probably integrate Google Test into this at some point, because unit testing is a skill I want to start teaching in FRC as well.

Basically, the idea is the students work on mini-projects to learn skills, then they put it all together during competition season. We spend probably a month during offseason teaching new members. Things go faster if the student does the assignments on their own time because the software team usually gets pulled away during the offseason build sessions for FLL things.

We usually don't get to https://csweb.frc3512.com/ci/frc02/ until build season, which teaches common design patterns using WPILib classes. I try to provide project templates with stuff like a .clang-format file so they can start off with good practices by default. We use the first part of build season to do more robot-specific training with C++ like drive code, subsystem abstraction design, incorporating feedback controllers, and tuning them.
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:33 PM.

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


Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi