Introduction: How to Add Conscience to a Machine
Suppose a robot must pass between 2 chairs. The trajectory is easy to calculate, but need to know the coordinates of the obstacles. You can get it in 2 ways: either immediately before the movement using sensors or in advance and keep the data in some representation. The second variant is conscience - a knowledge base which maintains the internal picture of the world. Programmatically, it is a standard part of system software and is structured itself. Contains at least 2 parts: knowledge about the external world and self-knowledge. In this demo, we will implement the latter.
As in the previous Instructable "How to make clever machines",
we will use the development environment of WinNB.
Parameters of various objects are prescribed and loaded during the program initialization. Instead, the manipulator moves, and its state should be timely updated. The idea is that only important values should be traced. If some distinct events are not used anywhere in the program, they should be ignored. The program will do the same that in the previous demo, only on a higher level of abstraction.
Derived from: Caudate_nucleus.gif https://commons.wikimedia.org/w/index.php?curid=7894172 Description : English: Caudate nucleus. Images are from Anatomography maintained by Life Science Databases(LSDB). Date: 25 September 2009 Source: from Anatomography, website maintained by Life Science Databases(LSDB). Author: Images are generated by Life Science Databases(LSDB). Permission: CC-BY-SA-2.1-jp
Step 1: List the Important Parameters.
Choose what should be traced in conscience. Just a reminder: we program a robotic arm which must throw a ball, then catch it back. Obviously, what happens to the ball is of primary interest. The following situations are possible.
% ball lies on floor.
% ball is in hand.
% ball flies.
% ball flies left (right).
% ball flies down (up).
The next is the state of the manipulator itself.
% hand is in horizontal position.
% hand is in vertical position.
At the beginning of the program, the initial state is defined.
ball lies on floor.
hand is in vertical position.
Step 2: Look Where Critical Events Are Generated.
Find places in the program where a state is changing. For example:
@InfLevel := @InfLevel + 1;
turn into vertical position;
remember: _operator(@InfLevel,"adjust hand vert");
so as to take ball.
After the last operator the ball will be in the hand.
Step 3: Update Knowledge.
Add commands which update the knowledge base in these places.
take green ball; forget: ball is on floor; remember: ball is in hand so as to take it.
Note that this step has some flexibility. We have detected the change at the upper level of function calls but may update somewhere down the hierarchy. It depends on the convenience of programming. The trade is that convenience may contradict precision. You may update the picture of the world earlier or later than the world itself has changed. Also keep in mind various erroneous situations. Under normal circumstances, everything works correctly, but if the program fails at some point, knowledge may be updated without real change or vice versa.
Step 4: Use Knowledge.
In the rules of the previous program, low-level calculations were used.
@DX < 0; @DY > 0;
Now we can replace them with more convenient facts.
ball flies left;
ball flies up;
Step 5: Test the New Program.
After the major reshuttle, some combinations may change and the program will stop operating under certain circumstances. Erroneous movements may be rather weird. With a real manipulator, they may break the expensive hardware.
Run thoroughly from various initial conditions and make sure that everything works as previously. When the goal is finally achieved, keep in mind that now there is another source of misunderstanding. Suppose the robot has caught the ball and you drop it using low-level instructions.
move 30 steps up.
rotate -90 steps.
move 5 steps up.
rotate 90 steps.
Then tell 'play ball.' again.
Obviously, the machine thinks that the ball is still in its hand. That's because low-level instructions don't update conscience.