Older blog entries for raquib (starting at number 2)

18 Aug 2003 (updated 18 Aug 2003 at 22:40 UTC) »

OK, here's some really basic code for one of my subroutine programs. This one will be the one that "blindly" builds a map of where the robot is and where other things may be. The map itself is only used as a secondary source (more for seeing "am i headed in the right direction" then for planning out complex moves).

sensors used: 3 IR sensors that measure proximity to robot. They are placed facing foward, foward left, and foward right.Distance tracking: x,y, and degree values of the robot are measured by the robot. There may be a lot of imprecision here, which is why the map is a secondary source! (NOTE: the x and y values may be negative! the robot starts off in the state 0,0 )

The pseudocode:

/* NOTES: if you use this, email me...! raquib0@lycos.com i'd like to hear about your robot! (credit would be nice too..)

a map is made up of areas

an area is a matrix of doubles (real numbers) where the location of each element (x,y) represents a set distance and the value of each element represents the probability that is is "filled".

when I say "mark" an area, i mean that you will do this:


your position is x,y
add .1 (or some other constant) to the elements 1 element away from x,y
add .05 (or some other contant) to the elements 2 elements away from x,y
add .0025 (or some other contant) to the elements 3 elements away from x,y...
.... etc
.... etc
keep doing this for N elements away from xy

the elements in the matrix with a value above a certain threshold are likely to be filled... you can use this to plan a overall route to a point.

*/


constant Tx; // max x size on the map
constant Ty; // max y size on the map
constant Td = 360; // max degrees
constant Tir; // threshold for IR values to signal a mark event


var doff = 0;
var xoff = 10;
var yoff = 10;


var ir1, ir2, ir3, x,y,d


begin critical loop{
read in ir1, ir2, ir3, x,y,d values from robot
// bring the x,y values to our system
x += (Tx/2);
y += (Ty/2);


// now put x,y to our degree position
var distance = sqrt(x*x + y*y);
x = distance*sin(doff+d);
y = distance*cos(doff+d);
// check bounds, create or move to new area if need be
if(! inbounds(x,y) ){
make xoff and yoff starting positions in new area
doff = (doff+d)%Td;
go back to start of loop
} // inbounds check


// check if i should update this area of the map
if(ir1 + ir2 + ir3 > Tir){
update values around me in the area
}
} // end of crtical loop

So here's another project i'm working on cocurrently. A music analyser using neural nets. I'm using the Maate MPEG library to decode mp3s and running them through the neural net to look for classifications. Okay, that made no sense. Here we go. Let's call the program MA. You pass in 2 lists to MA, a list of songs you want to hear and a list of songs that you don't want to hear. You then train the network (a standard FFN) with the lists that you passed in, expecting a result of 1 for a good song and 0 for a bad. I'm currently using the RMS value of each subband as the inputs to the network. Layers: variable node input layer, 20 and 10 node hidden layers, and a 1 node output layer. I want to extend the program so I have multiple nets (RMS, Centroid, Energy Movement, etc) and allow the songs that have a majority of the nets firing to enter the "good" list. I've only programmed in the RMS network so far, and that seems to be working well. I'm looking at a 98% success rate so far... i'll get back to the robot soon...

And the journey into the realm of AI is a harsh one. The basic plan right now is loop... loop... and loop. Every subsystem runs on its own with no communication with the others. I'm thinking that's a good idea and a bad one at the same time. I'm using what's generally known as subsumption architecture, (build one layer, then another, then another... have the real world be the model.. ), but the results although interesting, aren't what i want. It's ok to have a robot avoid everything, until you want it to get close to something. I've been wondering about how to have everything communicate with each other but in a general enough way so that i don't have to specialize any given item. Here's the plan: connect everything with "chemical-like" messages. imagine the modules of the robot in a chemical pool, much like cells in our body. Each module is affected by a particular signal, say inhibit other motor modules, excite other motor modules, inhibit sensory information, etc... Right now, i'm planning on 2 signals for the motors (as the motor is the only thing that does stuff right now) inhibit motors to everything else, excite to everything else. All inhibit and excite do is change the module's rate of fire. Alright, enough typing... back to work.

X
Share this page