![]() |
Teaching C++
Hi CD,
This year I was my team's Only Student Programmer, and it looks like things are going to be that way next year too. I want to teach some other team members C++. WPILib is nice and makes development very easy, but I think it will pose a challenge for zero experience programmers who aren't ready to jump into OOP, indirection, memory management, etc. We will be using VEX in the preseason, and the EasyC API is even easier than WPILib, so I plan on starting with C. Before I think any further, do you have any advice on teaching programming? Teaching in general? The timeframe required to really know C? Thanks. |
Re: Teaching C++
Honestly for anyone with even a little programming experience around a month-1.5months to REALLY know it. For anyone with next to nothing but a very logical mind 2-2.5 months. and Anyone else 3-6months. To know it enough to program a robot. (basiclly to just know the Libraries, how to use them, and basic syntax).
(This is based more on Java and C++ than C.) |
Re: Teaching C++
Quote:
In terms of really knowing C/C++, I'd consider that to be an optimistic timeframe, though this definitely depends on how much time you, the teacher, and your students are willing to commit towards the end goal of teaching whatever, what projects you'll have them go through, as well as their prior experiences. |
Re: Teaching C++
Quote:
I can attest to this. I started learning C++ at the beginning of this year in order to program the robot, due to the lack of any other programmers. I have had experience with various languages throughout my life, but never really stuck with one. I quickly learned enough to program our drive train and all, and I feel confident that I have the ability to program most anything my team could need. But I still find myself frustrated by the fact that I don't really KNOW C++. I use C++ to control the robot, but I don't fully understand how C++ works, and would likely find myself unable to write any kind of non-robot program without the assistance of google. |
Re: Teaching C++
From year to year, our team always have this problem. If we are lucky, we will have one or two students who already have some backgrounds on programming. Depending on when they join the team, we are luck if we have 2 to 3 years of their service. Then they graduate. Ideally, while they are in service, we would train less experience programming students to take over after they graduate. In reality, this doesn't always work out. Our school is a very small school with only a few hundred students. We are lucky if the FRC team has over 20 members. This year we have 18 and only a handful are interested in programming. A lot of them have very little or no background on programming. Even if we train some of them, some students may decide to quit robotics after a year or so. In order to make this work, we need a way to rapidly train students. A few years ago, their robot code was monolithic. Everything was written from scratch year after year. The code was hard to understand so it is hard to learn from reading it. One of the ways we use in recent years is to preserve knowledge continuity by developing a robotics library. This library is written as generic as possible so that it can re-used year after year. For less experience programmers, they would learn how to use this library. Reading past code that used this library is a simple way to start. It is a lot faster on-boarding than teaching them how to write the entire code from scratch. For more advanced programmers, they will learn the internals of the library and may even contribute to debugging, maintaining and extending the library year after year. This past summer, we even built a smaller form factor practice bot. It is basically a 24" x 24" running base. Small enough for students to take it home if they need to gain some experience in coding and debugging for it. All of these are more focused on teaching robotics programming, not necessarily just teaching C++. For teaching C++, we supplement it by recommending students to learn the basic language from some internet sites. It is generally difficult to teach a bunch of students who have different levels of programming skill. When you teach something too basic, intermediate or advanced programmers will lose focus. When you teach something more advanced, you will lose the beginners. So each individual student must bring themselves to a more uniform level. We usually start with doing an introduction to the C/C++ language session for really beginners. Then point them to some internet sites for more detail information. Then we start to teach how to program the robot using the library, showing code from past years and explaining the design and structure of the code. Then for whoever are interested and can handle it, we will talk about more advanced topics and how each library module works. In between all these, the small form factor robot is available for demoing concepts and hands-on experiments.
|
Re: Teaching C++
It depends how in-depth you really want to get. We don't go too much into detail with our students because it's not really necessary to just get the robot running. This is more or less what we cover with our students:
This year, we ran two Saturday workshops for 25 and 103 to go over programming stuff. The first session was for programming basics, so just how to write simple code in general. The second session focused on WPILib and how we use it to write code for the robot. To help drive it all home, we work with the students have them rewrite the code for the previous robot. In our case, we had each student assigned to a different system on the robot, so one student was responsible for getting drives and brakes to work while another did the pneumatic things. They'll ask us questions and we lead them in the right direction (like "Remember when we talked about the Joystick class and the different functions it has? Try looking for something to help you in there.") but we won't do any of the work for them. |
Re: Teaching C++
I find that a constant roadblock in my learning C++ on my own is the IDE...
I have numerous books on C++, and have looked over several comprehensive online tutorials. The problem is that I always have trouble with the IDE, either it wont stay installed, I can't figure it out, it doesn't work well; and in the end I always forget anything I had learned. This year I will be trying to teach younger members about programming at the same time as teaching them some basics about electronics. We will be using arduinos, and doing activities with them that involve controlling motors and reading / interpreting sensor data. I feel that attaching the programming knowledge to a small scale physical demonstration might help them remember it better. Now, the arduino's programming language isn't exactly C++, but it is similar enough that they can go on from the arduino activity and start reading over our 2012 robot code, while me and the other existing programmer help them relate things in it to the concepts they learned on the arduinos. We will then re-write the robot code (almost) from scratch, having them offer suggestions for improvement. This should give them a decent understanding of the structure/organization of code for FRC robots, as well as a basic understanding of how various physical electronic components that will be controlled by the code will work, such as jaguars, victors, servos, gyroscopes, ultrasonic rangefinders, etc. |
Re: Teaching C++
Quote:
I agree with you about the IDE -- I don't like IDEs at all. I prefer to use vim and make. Learning a different IDE every few months just isn't appealing to me. |
Re: Teaching C++
Quote:
I didn't mean to say that it uses a different library (well, at least I think I didn't) but I suppose it does. But I think it should still be useful in teaching some of the basics of programming the robot, at least in terms of how sensors and other hardware can be interacted with through programming. |
Re: Teaching C++
We teach C++ by giving members websites and software like Visual studio. We encourage being able to learn things on your own and offer help and explanations whenever needed. So far, our programming team is the captain, the apprentice, and a past member of the team who helps us substantially. I'm hoping to get a couple more people in the programming department. The school also has a C++ class and any member of the team is welcome to take it. We don't discourage anyone from learning programming.
|
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:
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. |
Re: Teaching C++
I learned the programming for the robot by starting on labview (3 yrs ago, 8th grade) and then took the school's programming class (2 yrs ago and has basically only seniors) and then explored plenty more on my own.
The school's class (taught by the AP Calc teacher who know a tad of programming) starts using Microsoft Studios like 2006 or something (C++). Then the second half of the semester class, he gets students doing some projects with Just BASIC which uses BASIC instead of C++. Now this past year I have become quite profficient with programming and I needed to teach someone else. One of the things I've started was Video tutorials cause our mentor (AP Physics teacher) had started doing that and really likes it. But the person I was teaching had never done programming before and I didn't have time to go through the whole Microsoft Studios 2006 thing. So instead I took him straight into Just BASIC to teach him the ideas of integers and mathematical operation and for loops and while loops. Then took him to the WindRiver compiler to relate it to the robotics code. Now that I have done more projects with the Arduino, I might start with that instead but I'm not sure. Also I helped teach a few sessions of the C++ programming class and got them to work on a project to try and make the robot autonomously go around the room without sensors.. Almost made it, but we did make enough dents in the walls. BTW that robot was ~1 ft wide by 2 ft and the frame consisted of a sheet plastic cutting board. It was a double decker and had banebot motors for the drive. |
Re: Teaching C++
I take a slightly different approach. I run a class on C programming before build season starts. I start out by just teaching the language semantics and syntax. Then I work on logic, flow control, how to break down a problem into smaller steps, etc. I feel that it is more important for students to learn how to program than the specific language. C has a fairly simple syntax.
As people have mentioned you're filling in a framework, which is basically C syntax within a C++ function. As we get closer to the start of build season, I walk students through the framework - we use the IterativeRobot class, and show how to use the various sensors, and other objects required to get the robot up and running. As they become more familiar with the various constructs, we talk about processes, memory management, timing, PID control loops, etc. but only with the students that show real interest. Some times it's only one or two students. This year we had two freshmen that really did a great job, and a hand full of others students who mostly watched them work. |
Re: Teaching C++
Quote:
While I'm typing, I might as well ask. Can you recommend any online tutorials that do a good job of explaining the parts of the language that go beyond syntax? (which, at this point, is the only thing that I really know well). |
Re: Teaching C++
Quote:
http://mindview.net/Books/TICPP/ThinkingInCPP2e.html They're free online but you can buy hard copies also. They're pretty old but understanding the first book will give you a deep understanding of C++. The second one talks mostly about the STL so isn't really relevant to FRC. |
| All times are GMT -5. The time now is 13:38. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi