![]() |
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. |
Re: Teaching C++
Thanks. From what I've read so far those books seem like they'll help quite a bit. Older sources seem to have much more straightforward explanations than many newer ones...
|
Re: Teaching C++
This book does a very good job of teaching programming. It uses python because it's a simple language to pickup, but once they've finished it you can teach them C++ and they'll have a much higher success rate than just going straight into C++.
I've found that just teaching people the language isn't good enough. You have to teach them how to think like a programmer. |
Re: Teaching C++
Quote:
A number of the items I mentioned are functions of the operating system that is being used, and the hardware. There are books on VxWorks that explain how the OS works, and what features are available. There are books on control theory but most of the ones that I have are not really for novices. For more info than you'll ever want to know about C++, you can use Bjarne Stroustrup's book. I always believe in going straight to the source, but for a novice programmer it can be a daunting book. Also, I agree that Python is another viable language for teaching how to program. The hello world program is probably the easiest and clearest of any language :) |
Re: Teaching C++
Quote:
One year our team had a programmer who was practically a java god. They knew java inside out, it was crazy. But they had little to no understanding of any of the mechanical or electrical systems on the bot... Our robot didn't have working code until I took it home and learned enough java to fix it. This is one of the reasons that we are now making sure that anyone involved in programming is also heavily involved with other things as well. This is also the main reason that I am planning to use the arduino to teach programming, so that kids can learn how programming can be used to interact with physical things. |
Re: Teaching C++
Already knowing Java and VB.NET, It was very easy for me to pick up C++. I learned all of the basics in a month. I used learncpp.com. They have great explanations and structured lessons with quizzes at the end. Did I mention it's free?
|
Re: Teaching C++
If you guys are looking for a good IDE to get started developing in outside of robotics, I'd recommend Qt. It has libraries for nearly everything you could ever need to develop a desktop application, along with a great community to support it, also it simplifies coding GUIs and cross-platform applications greatly, as you can code once, and use it on any platform. When I program things for my team, it's what I use.
Just my two cents. |
Re: Teaching C++
Well from my experience, I learned 50% of my programming knowledge in the 6-week build. Prior to that, I had dabbled in C++ and NXC ( http://bricxcc.sourceforge.net/ ) a bit but never fully understood it. (I could do basic variable manipulation, loops and if/else statements but thats about it)
I was able to program our robot rather effectively using all the builtin libraries in WPILib without understanding what OOP was, or how to implement it. Just seeing what worked and what didn't was enough to make some rough Teleop and a brief autonomous code with smartdashboard logging and some drive mode switching. (The code can be found at https://bitbucket.org/teammetalcow/r...cpp?at=default ) I will note that I learned none of this from books, just experimenting with the language and looking up references from the WPILib documentation. I did go on to learn OOP in the off season, so thats what https://bitbucket.org/teammetalcow/2012offseason/src is. It really depends on the person though, Ive found. We all think differently, but C++ thinks in basically one way. Like one person here said, If you think extremely logically if can be 2.5 months, but if not it can be 6. |
Re: Teaching C++
Can anyone help me in programing the Jumper ??!! in order to see the battery voltage in the computer drivers??!!
|
Re: Teaching C++
Gadeer, you don't need to (at least not at the DS). There's a particular call to get the value in your code, but I don't know what that is.
As to the OP's question, 2473 starts their students off learning RobotC and programming basic NXT robots to do basic tasks. We've started pursuing the philosophy of teaching students extremely basic tasks, and as they become proficient at those, take the students through an experience curve tying together those basic tasks into more complex tasks. Remember that at the very bottom of things, the robot is just a big frame with motors attached that have got things on the end of those motors that need to go places. It's just a matter of when and how much to spin those motors. Now, our team has two years to train our students before they get to FRC. We are looking to create programmers, not just software guys for the team. Way back when we didn't have the FTC feeder team, we simply pulled the entire software team together every day for a month and learned RobotC to start off with, then taught them C++ lecture style (syntax only, since they learned the logic via RobotC). Everything else they learned was through experience, which, unfortunately, we weren't able to give them. While all of the resources you've been given are great, nothing beats experience as a teacher. You just have to go out, take a stab at a problem, fail (not miserably) at it, pick yourself up, figure out what went wrong, and succeed at it to learn a lot. It's that courage to keep going that will keep you learning. |
Re: Teaching C++
Quote:
|
| All times are GMT -5. The time now is 14:25. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi