I have now finished work on a much more advanced version of the insect simulator named
AnimatLab.
AnimatLab is a software tool that combines
biomechanical simulation and
biologically realistic neural networks.
You can build the body of an animal, robot, or other machine and place it in a virtual
3-D world where the
physics of its interaction with the environment are accurate and realistic. You can then design a
nervous system that controls the behavior of the body in the environment. The software currently has
support for simple
firing rate neuron models
and
leaky integrate and fire spiking neural models. In addition,
there a number of different
synapse model types that can be used to connect the various neural models to produce
your nervous system. On the biomechanics side there is support for a variety of different rigid body types,
including
custom meshes that can be made to match skeletal structures exactly. The biomechanics system also
has
hill-based muscle and
muscle spindle models. These muscle models allow the nervous system to produce
movements around joints. In addition, there are also motorized joints for those interested in controlling
robots or other biomimetic machines. This allows the user to generate incredibly complicated artificial lifeforms
that are based on real biological systems. Best of all
AnimatLab is completely free and it includes
free C++ source code!

4.2.1 The Insect

1. Introduction

The insect simulator currently uses a very simple two dimensional
environment with only a limited simulation of physics. The first phase
of this project was focused mainly on the neural control systems and
trying to get at least a simple system that could produce the desired
behaviors solely from neural networks. All configuration information
that defines every aspect of the insect and its environment is contained
in an XML file. The general outlines of the body, the number and
positioning of legs, antennas, and sensors can all be defined in this
file. There are several parts that make up the virtual insect. These
are: body, legs, mouth, energy storage, antennas, contact sensors,
chemical sensors, and the brain. The following sections will go over
each of these various parts and explain some of the details about each
of them.

2. Body and Contact Sensors

Contact Sensors

Figure 1. The body portion of the insect
is colored. The contact sensors are in different colors.

The body portion of the insect is colored in figure 1 above. Each
colored portion of the insect represents a contact sensor section.
Whenever a physical obstacle comes into contact with any of these
segments it sets a data variable. This data variable can then be used
by the sensory neurons to control the firing of neurons. These sensor
systems are used mainly when insect runs into a wall. One common
problem that was encountered was when the insect was trying to follow a
wall like the outside of a building it would come to a corner. The
insect would turn a little too aggressively and one of the corners of
the body would catch on the wall and the insect would get stuck. With
the contact sensors this is no longer a problem because it can detect
that condition and take steps to get out of trouble.

3. Insect Legs

Insect Legs

Figure 2. Image showing the insect legs in red, and
an image of an actual labeled roach leg.
4.2.1.1

Leg Rotation Guide

Figure 3. Guide showing the direction of rotation for legs
on different sides of the body.

An insect in this system can have any number of legs. However, all insects
that have been used to date only have six legs. Figure 2 shows the numbered
legs for an insect in red. A leg is made up a two main parts the Femur, and the
Tibia. The Femur is the portion that is clearly visible in the virtual insect,
and can rotate back and forth. The Tibia is responsible for picking up the
foot and for causing extension for insect rotation. In the virtual insect some
of the legs have blocks at the ends of the legs. These symbolically represent
that the foot is in contact with the ground for that leg. The reason for
doing this is since the simulation is only two dimensional it is not possible to easily
display this information. Each leg has several parameters that define it.

Rotation: This is the initial rotation of the leg.

Max Rotation: This is the maximum rotation that the leg can attain
relative to the starting rotation.

Min Rotation: This is the minimum rotation that the leg can attain
relative to the starting rotation.

Start Rotation: This gives the initial orientation for the leg and serves as
the base rotation against which all other rotations are measured. Legs that
are on opposite sides of the body have opposite start rotations.

Length: This is the length of the leg.

Position: This is (x, y) position for the base of the leg that
connects to the body.

Mass: This is the mass of the leg. This is used in the physical simulation
to try and determine how fast the leg can rotate.

Torque: This is the torque that is currently being applied to the leg.

Extension: This is the amount of extension of this leg. This is used to
help turn the insect.

Figure 3 gives a guide to how rotations are measured. This system uses the convention that all
rotations that are clockwise are negative, and all rotations that are
counter-clockwise are positive. This means that the rotations on different sides
of the bodies are swapped. This can be confusing so be sure to keep it in mind
when looking at rotation values. Also, all of the rotations are relative to the
start rotation value. So when there is a graph that shows leg 1 rotated 0.5
radians then it is necessary to remember that this is in relation to the start
rotation, and depends on whether the rotation is positive or negative. The feet
also have all of these variables, but they operate in the same way as for the
leg. The big difference is that the affects of the feet variable are not
very visible. Another important point about the insect legs is that the Tibia is normally
used by the insect to pick its foot up off the ground. However, it also uses it
to physically rotate the direction of travel for the entire insect. It does this
by extending the Tibia of one of the front legs while it keeps its foot on the
ground. It then pulls in its leg on the other side. This essentially pushes the
front of the insect to one side or another. When it takes its next step it is
traveling at an angle compared to where it was going before. The insect is able
to use the extension variables of the legs to rotate itself.

4. Insect Motion

Now that the insect can rotate its legs and raise and lower its foot, the next thing that needs
to be looked at is how does the movement of the legs propel the insect to move. The algorithm
used to do this is somewhat complicated, so only the basic principles will be discussed. When an
insect has a foot down on the ground and it swings its leg, then that causes a force to be
applied to the body of the insect. For example, In figure 2 if leg 0 was to rotate in the negative
direction while its foot was down, then this would apply a force to move the insect's body forward.
Currently there are no rotational torques applied due to differences in forces on different
sides of the body. This is a major deficiency of the current system that will be addressed
when it is converted to use the 3D physics package. The amount of force applied to the
body is proportional to the torque of the leg. Also, if legs on opposite sides of the body are
applying forces in different directions, then the insect does not move. I realize this is a
very simplistic algorithm for the insect motion, but I believe it is able to capture
enough of the general principles for what is currently being done. This is one of the main reasons why
I doubt that the neural network designed for this 2D system will work "as is" in a real robot.
Things like the differential forces on the legs will have a definite impact. Once the system
is converted to the true physics simulation then it will be possible to modify the network
to try and overcome these problems. It is definitely possible to overcome them with a similar
network because other researchers have already implemented working robotic systems using the
neural net designed by Dr. Beer.

The antennas have two main purposes. They are to detect contact with
obstacles before the main body comes into contact with them, and they can detect chemical
signals. The detection of chemical signals will be discussed below in section
7. A very important behavior that is seen in insects like the cockroach is the
ability to keep one of the antenna in contact with a surface so that it can
follow a wall. The cockroach spends the bulk of its time following walls and
other structures. The antennas first detect if they are in contact with a
surface. If they are, then they calculate the angle of incidence between the
antenna and the obstacle. The sensory
neurons then use this value to determine their firing rate. Figure
4 shows
two possible contact situations. In the first situation the insect is
walking parallel to the obstacle and the antenna is just touching it.
In the second situation the insect is running almost head on into the
obstacle. It can be clearly seen that the angle of incidence that the
antenna makes with the obstacle in these two situations are very
different. Angle A is much smaller than angle B. This fact will be used
later when the edge following subsystem is being built to control the
amount of turn that is needed. If an insect is walking directly into a
wall it will want to turn more than if it is simply brushing up against
the side of a wall. Also, one thing that is apparent is that the
antenna appear to actually be penetrating the obstacle. This was done
for simplicity sake. In a physical system the antenna would be
deflected when they come into contact with a surface. And it would be
the amount of this deflection that would then determine the rate of
fire. However, it would have consumed a large amount of time to make it
appear that the antenna were deflected and followed along the edge of
the obstruction. So in the simulator system the antenna are allowed to
go inside of obstacles, but this should be viewed as if they were
really being deflected.

6. Mouth

The mouth is not visible on the insect. The resolution of the insect is
so low that it did not seem worthwhile to try and make it appear on the insect.
It is physically located at the top, middle portion of the head. It is composed
of a jaw that can be opened and closed to chew food. Just like the legs, the jaw
has a torque variable. In order for the mouth to open and close there has to be
motor neurons in the brain that can control this. If the mouth opens and closes
while it is directly over food then it will have taken one bite of the food. The
energy for that food will then be put in the energy reservoir for the insect. If
the insect can not open and close its mouth while over food then it can not eat,
and it will ultimately die.

The insect has to have energy in order to be able to move and survive. There are several variables
that are related to energy.

Energy: This is the initial energy level for the insect.

Max Energy: This the maximum amount of energy that an insect
can contain.

Standing Energy Usage: This is the amount of energy that is
used up when the insect is just standing still.

Moving Energy Usage: This is the amount of energy that is
used up when the insect is moving.

A really elaborate system to calculate energy usage would have been possible.
However, simplicity was chosen instead. The two variables that
determine how fast a insect uses up its energy are the standing and
moving energy levels. An insect is always burning up energy. If it is
just standing there doing nothing then it will burn up the standing
energy usage amount on each time step. This means that if an insect
simply stands still and does nothing it will eventually die. It must
actively seek food to replenish its energy stores. When it does move it
burns the moving energy usage amount of energy each time step. This
value is higher than the one for standing still because it is expending
more energy. However, the current system does not attempt to base the
energy usage on things like the velocity of the insect or how many
appendages or moving. That would have complicated the system for little
gain. In order to replenish the energy store an insect must find food,
position the mouth directly over the food and then move the mouth open
and close to take bites of the food. All of these things must happen or
it can not get any new energy.

8. Chemical Sensors

In order for the insect to be able to eat it has to find some food. To
do this it uses chemotaxis to steer itself toward the scent of the food. There
are five main chemical sensors on the insect used for the simulations shown
here. Two sensors are located on the tips of each of the antenna, and a fifth
sensor is located right next to the mouth. There is one high gain and one low
gain chemical sensor on each of the antenna. The high gain sensor is for
smelling the chemicals from relatively long distances. However, once the insect
begins to get near the food source these sensors saturate and are no longer able
to provide any useful information. That is when the low gain sensors kick in.
They are only able to detect smells when they are pretty close to the food
source. So the high gain sensors are for long range detection of the food that
gets them going in the right direction. And once they are closer to the food the
low gain sensors home them into the point where they can actually get directly
to the food. Having the sensors on both antenna's that are separated by a good
distance is the key in their being able to steer towards the food. The insect
basically compares the strength of the smells arriving at both antenna and uses
that to determine which way to turn. So if the chemical is stronger on one
antenna it will turn in that way. If both antenna are getting the same signal
strength then the insect does not turn at all. The chemical signal next to the
mouth is not very sensitive at all. Food has to be in almost direct contact with
this sensor for it to register anything. It is used to help tell the
insect that it is directly over food and it should stop moving forward and start eating.
Also, the chemical sensors are specific for a particular food type.
They will only detect one type of food. If multiple types of food need
to be detected then multiple sensor systems are required. Currently the
simulator is only using one food type so this is not that important at
present. But at some point it would be nice to setup different food
types to try some aversion experiments. These
things will all be visited again in more detail during the discussion on
appetite control.

9. Insect Overview

The insect contains a number of different sensor and motor systems. All of these
are needed to allow it to perform the behaviors that will allow the
insect to survive. The contact sensors on the body help keep the insect from
getting stuck in a situation where it can no longer move. Without the legs and
feet the insect would not be able to move at all. It is only through the
synchronized action of all the legs and feet acting in concert that the insect
is actually able to walk. The antennas provide critical data that allows the
insect to follow along the edge of a wall instead of smashing into it and
getting stuck. The mouth allows the insect to eat so that it can replenish its
energy stores. And that is the key point in this simulator system. The insect
has to find food and eat it to survive. And without the chemical sensors it
would only be able to eat if it randomly walked over a pile of food. And no
insect is likely to survive long by displaying that type of behavior. The
chemical sensors allow the insect to actively orient its direction of travel
towards the food. This section has given a brief description of all of the
physical systems that are involved in the simulation of the virtual insect.