Thread: Teaching C++
View Single Post
  #11   Spotlight this post!  
Unread 08-06-2012, 23:51
kwojcik kwojcik is offline
Registered User
no team
Team Role: Mentor
 
Join Date: Sep 2008
Rookie Year: 2009
Location: California
Posts: 24
kwojcik is a splendid one to beholdkwojcik is a splendid one to beholdkwojcik is a splendid one to beholdkwojcik is a splendid one to beholdkwojcik is a splendid one to beholdkwojcik is a splendid one to behold
Re: Teaching C++

C/C++ can be used to do some very very complex things, mastering them can take many years. There are a lot of things that you don't even realize you don't know until you understand compilers and language runtimes and processor/memory/bus/etc architecture. Every time I work on a project I learn something new about C (usually pointers and memory layout and optimization).

That being said, you really don't need to know all that much to program a FRC robot to do some basic stuff. You don't really even need to know much of C++, just the C-style syntax and pointers. This list is a great start. Once you have the syntax and variable basics down, I would say spend time understanding object oriented programming and how you can combine WPIlib classes with your own custom code to make very powerful classes. Also, you MUST understand the difference between when things are on the stack and when they are on the heap.
Quote:
Originally Posted by Alexa Stott View Post
It depends how in-depth you really
  • What an integer is
  • What an object is
  • How to declare, set/initialize, etc. both of the above
  • if/else statements
  • What functions/methods are
  • How to declare/write, call, use, etc. a function or method
  • An overview of what WPILib is and how to use it (i.e. how to figure out what functions you can/should call with the different objects)
  • Some of the most commonly used classes, like Victor, Joystick, Solenoid etc.
  • How to declare a pointer and how it changes how to call its functions (using the -> instead of .), though we don't really go into what the difference is unless someone really wants to know
  • How to read inputs from sensors (analog and digital from both the DS and the robot itself) and use those values
  • Where to put the different parts of the code (i.e. what should go in our Shooter class vs. our DriveBase class and where to put autonomous stuff vs. teleop stuff)
Most importantly, program a robot. Get a minimal set of code, say your robot.cpp that extends IterativeRobot. Write the few lines of code to get a tank drive going. Then get arcade drive. Make some buttons trigger solenoids (no fancy state machines yet). Hook up a potentiometer and code up an Analog channel and do a printf of the getVoltage and getValue() * 5/1024 (notice they are different! very important). Then hookup an encoder and print those values. Being able to use sensors and drive a tank drive in a few hours work (for a beginner) is so rewarding!

Start programming things ASAP. After mentoring for years, its amazing how much you think you taught someone via lecture-style learning and then you see them fail miserably in doing the most basic task. Most importantly, don't let someone struggle with something syntactic or basic forever, it is very demoralizing and you are wasting both of your time. Help them out and they will understand.
Reply With Quote