DJ Sures Homepage Contact Me Follow us on Twitter Follow me on Facebook
Share/Bookmark

 
project name: DJ's robotic 2d/3d environmental mapping code
birthdate: october 1, 2006
description: If you are here because you've been lured-in by one of my robots, then you are already aware of the development of my 2d/3d environmental codebase. Otherwise, let me introduce to you the magic behind my robot's autonomousness (is that a word?) and behavior based artificial intelligence.

Many toy robot manufacturers create robots that resemble animals. Some may think it's creepy... I think it's outright stupid. Here's why: Robots are robots, pets are pets.

The goal of any robotist should not be to replace complex biological organisms that took an unfathomable amount of time to evolve. Also, building robots to replace human mobility is limited to cost over demand.

What can we do? We aid the evolution of robots as robots. Sound crazy? Biological life is a complex circuit of switches that creates the illusion of spirit and emotion. I'm not downplaying my life or emotional experiences. I need to state that the evolution of technology and it's respective logical complexity has met the requirements of a life form.

My previous statement brings a lot of great arguments. Most people wittily ask the question "How can a robot be a life form? It needs us. We built and designed it!".

All life requires a supporting infrastructure of Food For energy and the Will To survive. We Feed Robots by providing smaller and more efficient circuits to support their logic and by designing software that performs specific tasks. We are built on a foundation of technology. In short, we have become dependent and addicted to the potential of technology. We are far from being in control; we are slaves to technological growth.

What does this rant have to do with my silly little 2d/3d robot code? This code and its implementations (i.E. Robots) is my contribution to providing a visible path to the inevitable... Technology will eventually integrate beyond our current potential imagination. And I hope to make the transition smoother.

You're reading this aren't you? Means I've done my job

the goal: I wanted this codebase to be transportable. So developing a respective hardware theme was important. No cameras, no facial recognition blah blah blah. We're not redesigning a dog... We are doing more with less!

I wanted my robots to seem alive. Most toys and robots have limited understanding of their surroundings and appear dumb.

I stand by the phrase "Do more with less". Simplifying your sensory input will limit the complexity of the data which allows more creativity of how your robot processes and reacts. This is done by Remembering Sensor data. The action code requests feedback on specific trends of the memory.

So now my robots can wonder around and do their thing on their own agenda... They know the location of people, chair legs, couches, walls, doorways, etc ... As my robots drive around and interact, they learn about their surroundings. This information is used when choosing actions.

development enviroment: +1,000 lines of microcontroller c & assembly code



software
last updated: 11-01-2008
description: for many years, my previous robots were simple and performed single tasks. however, my software infrastructure began evolving and becoming far more effecient and reusable. the best feature of this code structure allows for flexability and expandability. the software is split up into modules. each module is named to encapsulate the function of the commands within it.

software... that's the key.
features: my advanced programming structure provides an interface to continously map surroundings. a 2-d or 3-d array of information is constantly updated during scans.c functions. this feature provides the movements.c functions ability to determine escape paths and understand environmental surroundings.

this is usually done with only 1 ir distance sensor.
when any of my code asks to scan, the data is put into an array respective to the sensor's angle. the array in 2-d looks like this...

the first column is the array index. the other 14 points from left to right are his vision values, the center values being his head position center. each column of the array history. I only keep 10 rows of history, and 14 points across becuase his head has 14 positions.

10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 
9,  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 
8,  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 
7,  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 
6,  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 
5,  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 
4,  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 
3,  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 
2,  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 
1,  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 

- everytime it moves forward, the array index is increased and the data is moved back one row.
- if it moves backwards, the array index is decreased and the data is moved forward one row.
- if it turns either direction, some magic occures and the table transforms.

if it is beside a wall with something in front, it'd look like ths...
10, 38, 36, 33, 0,  0,  0,  0, 0, 0, 0, 0, 0,  0, 0 
9,   0,  0,  0, 0, 23, 22, 22, 0, 0, 0, 0, 0, 0, 11 
8,   0,  0,  0, 0,  0,  0,  0, 0, 0, 0, 0, 0, 0, 12 
7,   0,  0,  0, 0,  0,  0,  0, 0, 0, 0, 0, 0, 0, 12 
6,   0,  0,  0, 0,  0,  0,  0, 0, 0, 0, 0, 0, 0, 14 
5,   0,  0,  0, 0,  0,  0,  0, 0, 0, 0, 0, 0, 0, 17 
4,   0,  0,  0, 0,  0,  0,  0, 0, 0, 0, 0, 0, 0, 14 
3,   0,  0,  0, 0,  0,  0,  0, 0, 0, 0, 0, 0, 0, 15 
2,   0,  0,  0, 0,  0,  0,  0, 0, 0, 0, 0, 0, 0, 16 
1,   0,  0,  0, 0,  0,  0,  0, 0, 0, 0, 0, 0, 0, 14 

the next decision is randomly generated by the personality module (that's a whole new topic). but when the decision is made, it may or may not actually do anything. becuase that decision might not have enough physical room to complete the action. so now we move onto the movements.c file. which references the scans.c 2-d/3-d array. whenever a movement is requested by the personality, the movement examines the array and determines if it can be done. maybe it will only partially or entirely complete... that's up to the data in the array and how the action uses that information. the robot now knows how far it can turn in either direction. how to navigate through table legs and chair legs. it also now knows how far to backup to reposition itself. you can see that demonstrated in my latest Wall-E video. now on top of all that. becuase I have this array, I can also reference it to determine if something has changed. if that is the case, then guess what? it must be a human! simple logic here: if it moves, interact with it! so it will turn towards the change, and it's personality will decide to do some animations. and now it's life like.





neko.c this is the program file that contains the main() entry point. initialization occures here (init head, init arms, init movement servo timers)
neko.h contains microcontroller fuse parameters, program #defines, and communication stream definition. the #defines are declared in this file so they may be easily modified in one location.
moveservos.c timer1 is used in conjunction with ccp1 and ccp2 to control the pulses to the movement servos. servos are controlled individually with speed and direction as parameters
DJservos.c this module contains the functions to move the head and arm servos. they use my own pwm control function. the reason for this is that it lets the user specify how many degrees from center to move the servo. then the number of pulses to move the servo from it's current location to the new location are sent. the current location is always stored for future reference.
DJtones.c a simple function that contains a tone generator with a optional oscillation parameter. a #define list notes are specified for musical score. the oscillation parameter gives the futuristic effect to the sound you hear.
sounds.c a collection of functions that play different melodies and sound effects.
Audiocontrol.c provides an interface to trigger samples from the toy's original sample board.
actions.c this file holds all the functions to control the emotion actions (eyes, tilting head, arms, etc)
scans.c a list of functions that provide scanning capabilities. they include getmaxright, getmaxleft, isleftclear, isrightclear, getdirectionofdifference, etc..
movements.c movements are small re-usable macros that are used by modes. the movements assist in getting out of jams, or avoiding objects by using scans.c functions.
modes.c this file contains the list of modes. a mode is a macro of movements, scans, actions and sounds. examples of a movement are nodatnearestobject, gotoclosestobject or goautonomous. modes are infinitely choosen by the personality generator function in the main() entry point.
adc.c contains my adc library which performs redunancy and false positive checking.
util.c common utilities that are used often. mostly which are functions to calculate differences with medians and servo degree position differences.



Copyright © 1995-2012 DJ Sures

hacker emblem