Psuedo-Code, was Algorithms

Some of us are programmers, some of us are more inclined to the mechanical aspects (pun intended), some of us dabble in many areas, and some of us don’t have a clue but love robots. Perhaps the ‘dabblers’ have it the easiest, they just need to get up to speed on whatever area is troubling them at the moment.

I’d venture to say very few of us are properly trained in algorithms, i.e. the methodology of how to solve a problem.
An algorithm is basically a set of steps on how to do a particular something. I’ve had the most problems in trying to adapt ‘what I want to do’ to the nuts 'n bolts of, say, using a sensor or component. Not the simple “this is how to hook up an IR range sensor and read the output” but the slightly more complex “this is how to use this sensor to affect motors, to avoid an obstacle and continue with …”

A generic algorithm, for using a differential-drive bot and IR sensor, can be mostly laid out in a series of plain-language steps A thru G or whatever. Then, it becomes a much simpler task to adapt these steps to whatever programming language and controller is being used.

For me, the hardest part has been designing workable algorithms for behavior. What I would like to propose is a database of generic algorithms, ranging from the simple to the insanely complex. As a resource, this could help us as a template to be adapted to particular languages and controllers. A simple, logical, step-by-step plain language description of how to do what are, individually, simple tasks. Combining these tasks and translating them to code is the job of the individual roboticist.

So, is this a workable, do-able idea?

Ah… let me provide a short sample…

Simple Object Avoidance Algorithm

  1. With all motors stopped, check Forward, 45 degrees Right, and 45 degrees Left for obstacles within range.
    A. If no obstacles detected, proceed to step 2.
    B. If obstacle is Forward or Right, turn Left 90 degrees.
    C. If obstacle is Left, turn Right 90 degrees.
    D. If obstacle is Forward, Left, and Right, turn around 180 degrees.
    E. Go back to step 1.

  2. Ramp up Speed from Zero to 3/4 of Full Speed for 3 seconds, then ramp Speed back to Zero.

  3. Save movement data (6 seconds worth of free space in a given compass heading).
    A. Transmit movement data to host, for future use or map construction.
    B. Sample and transmit (or save) any other environmental data, i.e. slope angle, tilt angle, temperature, etc.

  4. Go back to step 1.

A very crude example, just trying to flesh out the general idea. This could be translated to any coding language by most non-programmers, by referring to a manual. The ‘work’ has been done, all that is left is to hammer out the specifics for each language.

OK, too simplistic, but you get the idea. (All you REAL programmers, stop laughing!) For beginners, this sort of thing might help.

Hi,
Sounds like fun!

My guess is that you may be interested in behavior based programming. You might find it fun to look at the book: Robot Programming A practical guide to Behavior-based robotics by Joseph L. Jones. I read through it awhile ago and have always meant to go back and try some of the stuff in it.

Kurt

yes nice idea for a thread. instantly i remembered i did something like this. in fact it was when i started robotics about 7years ago.

i wrote this before i knew anything about robotics and i haven’t read through it since so it may be a bit silly.
just thought i might add this here:

It’s called Pseudo-code. A loose collection of steps that represent a program that is implementation independent.

It could be useful.

Alan KM6VV

Ah, psuedo-code. I knew there would be a term for it! (You must be a programmer!)

Exactly what I was thinking about. Really more for the beginners (in coding) but I think it can be useful for most of us, especially if the library of psuedo-code grows beyond basics.

I like this idea. I did something kind of like this when I was starting out my rover project.

lynxmotion.net/viewtopic.php?f=9&t=6048

Just a little more flow chart like…

Just another (evil) thought…

You might get pseudo-code submissions by awarding, say, free shipping? I think a well thought-out algorithm is worth it, doncha think? As a side issue, it might pay for itself by encouraging more business. They can only ‘cash in’ by spending more. I know I ALWAYS have more in my cart than I planned…

C’mon, basically we’re all greedy and lazy, as well as being simultaneously impoverished and overworked. A ‘carrot’ works as well or better than a stick, and carrots are few and far between.