Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I have a project that requires me to control movement of SCARA robot using VC. I am a beginner in programming so I thought of using existing program as my reference. The SCARA robot that I am using is regarded as a valuable property of the department and must be operated with extra care. I cannot simply make a program out of nowhere to ensure no damage on the robot.

I find it difficult to understand the existing program and am overwhelmed with the long lines of coding. Unfortunately, the last person involved with the program already left and no one in my department has any experience with the program. Currently I am not getting the help that i really need.Hopefully someone can give me guidance on this project.

share|improve this question
1  
Gotta love universities. "We don't need people who understand stuff, we have free students!" –  geekosaur Mar 21 '11 at 15:58
2  
Couldn't hurt to ask around to see the the previous guy is still in touch with people in the department or if your alumni association has an email address for him/her. If it's something that they are proud of they might be willing to help out a little. –  DKnight Mar 21 '11 at 16:48
1  
I thought all programmers nowadays write their code in such a way that documentation and comments have no purpose. You must have gotten onto one of those rare projects where the code could have used some documentation and comments. Man, it sucks to be you. –  Dunk Mar 21 '11 at 17:45

3 Answers 3

I would consider creation of some kind of software emulator. Ability to run program with some tweaks and without fear is a good thing for understanding.

Also this will open possibility for writing tests - also a good thing :)

share|improve this answer

In this situation, you have your work cut out for you, but it is not impossible. You will need to organize things a bit for your own sake. The actions you will need are:

  • Collect the specifications, manufacturer manuals, etc. you can. You'll need to familiarize yourself with how the SCARA robot is controlled and what acceptable parameters are. Don't assume someone else has done their due diligence for you.
  • Discover how the files are organized. It might look like a mess to start with, but eventually you'll learn which file(s) to look in. If the current organization of the application doesn't seem to make sense, spend some time adding some order. Some people still like to put everything in one file, esp. if it's a small app. You might consider breaking files up that have multiple classes so that there is one class per file. That makes it easier to find the file you need.
  • Attempt to recognize patterns that are being used. The GoF book "Design Patterns" provides some blueprints for common approaches to solving some problems. The code you see in the wild may not conform exactly to the way they are described in the book, but you can at least get an idea of what the code is supposed to be doing.
  • Comment the critical sections. The hard part is finding out what the critical sections of code are. That's what the previous steps were doing. Now that you've got an idea of what they are, it's time to really analyze what is happening. You'll have your manuals and specifications open for reference, but you will have to trace the application line by line to come up with the intent behind the code.

In this last step, you are going to want to take frequent breaks and keep asking yourself why is the application doing X or Y. Basically you are trying to figure out if you are in a forest or a jungle by looking at the leaves around you. But that's all you have at the moment. As you go through pass by pass, you will start to get a mental model for how the code is actually working. As you start to recognize the patterns and how things are working, change your comments because you need those to "get it". As you look at the new comments and code, you might be able to get to another level of abstraction away. You can add those comments, or change the comments you have as it makes sense.

Remember, you are trying to build some familiarity with the code. In the absence of the developer who wrote it, this is all you can do. This is also how I learned assembly programming way back in the day. The higher level concepts are there, but it takes time to zoom out as it were.

share|improve this answer

Can you run the program on the robot and step through it? That could be a good way to get an understanding of the overall program flow, assuming that pausing the program in the middle won't cause a crash. If the position/velocity control loop is implemented in VC, then you really shouldn't step through it, or you risk sending a constant output to some actuator, which will just cause it to accelerate into a hard stop. On the other hand, if the robot has a built-in separate motion controller, and the VC program is just telling the motion controller what step to take next, then you're safe to step through it.

Whether or not you can step through it, you're going to have to get familiar with the code. I suggest printing it out so you can make annotation in the margin, etc. Start with the high level program flow, and try to understand it. Then dive into each piece. You pretty much need to familiarize yourself with each line of code.

Yeah, it's a lot of work. Reading code is hard.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.