Search the Mindcreators site: 

Update Alert!

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!

The page that corresponds to this one on the AnimatLab site is " Virtual environment properties in AnimatLab"

4.2.2 The Environment

1. Environment Physics

The insect simulator system uses a fairly simple two dimensional physics emulator. There exist some advanced 3D physics simulation packages that are capable of creating a virtual reality environment that handles all of the physics that make up the real world. They include things like gravity, friction, collision detection, and real motion from applied forces. The current insect simulator does not use any of these only because it was decided that the system needed to start as simple as possible to try and get something that would work. The important thing in this version was to get the neural systems to work on a simpler model. The next version will attempt to integrate one of the 3D physics simulators into the libraries that have already been developed and debugged. This version is based partially on some simplified Newtonian physics formulas, and some more general rules of thumb. The physics formulas that are used are for the torque and the force are:

  • F = m * a
  • t = I * w

Each leg uses the leg length and leg mass to calculate a moment of inertia (I) for that leg. It then takes the torque that is being applied to that leg and uses it to calculate the angular velocity (w). This is then multiplied by the duration of the time step and the number of time steps since the physical simulation was last updated. This final value is the actual amount of rotation that has occurred since the last time it was updated. All of the simulations that are in this document use a time step of 5 ms. This is a good value to use for the Euler numerical method to be able to accurately solve the differential equations. However, The physical simulation is only updated every 20 ms. The movement of the entire insect is done in a similar manner as that for the individual leg, except it uses the linear Newtonian equation. This system does not simulate momentum. When an insect runs into an obstacle it stops instantly and does not rebound. Simulation of momentum seemed like an unnecessary complication of what was meant to be a very simple physics simulation.

Not all of the properties of the simulator system are described with physics equations though. The system uses a very simple collision detection routine. Each time the physical simulation is updated it checks to see if the insect is physically intersecting an obstacle. If it is, then it resets the insect to its position from the last updated time step and retries different combinations of x, y and rotation motions that made up the full motion that intersected. For example, An insect may have moved to the left, up and rotated slightly to intersect an obstacle. But if the insect just rotates and moves left then it will not intersect the obstacle. If so, then this motion is used and the insect is moved. If no combination of these motions results in a new non-intersecting position then the old position is used and the insect does not move. This is basically trying to simulate the principle that their can be a constraint on one degree of freedom of the insect, but the others may be free.

2. Obstacles

Typical Environment
Figure 1. This is a typical environment for the insect.

Without some obstacles the environment would not be very challenging for the insect. It would simply be able to walk unhindered. The obstacles allow the insect to demonstrate some more complex behaviors like edge following, finding food even if it is behind obstacles, and corner navigation. The user can define as many obstacles as are needed. Each obstacle is series of (x, y) points that form a closed structure. Some different examples of what obstacles look like are shown in red in figure 1. Also, it can be seen that there is a red border around the edge of the environment. This is an obstacle as well. Without this boundary wall the insect could literally walk off the edge of the world and just keep going! It would still be working but it would no longer be visible. The environment does not form a torus where if the insect steps off one side of the screen it appears on the other side. That would have complicated things for no visible benefit. Having the bounding wall makes the simulation more like the insect is inside of a room with the same sharp corners that a real insect would encounter. The collision detection system insures that the insect can not actually intersect one of the obstacles.

3. Food

Without some food in the environment then the insect will eventually starve to death. Food can be seen scattered around the environment in figure 1 as little green patches. It will always be green in the examples used in this documentation. There are several important properties of food that control its affects on the insect.

  • Food Type: There can be multiple types of food. This makes it possible to have some food types that would be harmful to the insect and some that are needed for survival. The chemical sensors that detect orders are specific for a certain food type.
  • Position: This is the two dimensional location of the food.
  • Width / Height: These two values control the size of the food patch.
  • Core Width / Core Height: This defines the size of the food patch where the sensor on the mouth of the insect will tell it is directly over food. This is mainly to allow the insect to actually get on top of the food patch before it stops to eat.
  • Diffusion Graph Variables: This is the graph type, A, B, C, and D properties that define a simulation graph. For more details about how the graphs work see the Section 4.1.6.3. The purpose of these properties is to define how the odor of this food will diffuse. Typically it will diffuse using an inverse function so that the odor decreases the farther the insect is from the patch.
  • Quantity: This is the number of bite size morsels that are contained in this patch. Each time that an insect takes a bite it will reduce this number.
  • Energy Density: This is the amount of energy that the insect gains each time it eats one bite of food.
  • Each time that the insect takes a bite of food from a patch it reduces the quantity of food that is available in that patch. The quantity of food that is still available is denoted by the brightness of patch. The patches visible in Figure 1 are all at full strength and show up as bright green patches. But as the insect eats the food they slowly turn a lighter and lighter shade of green until they are gone and the location where it was is completely white. The food patches are not obstacles. The insect may walk directly over them. 

    4. Environment Overview

    The environment is a very important part of the whole system. It defines what types of behaviors that the insect can and can not display. Without obstacles the insect would only be able to display the most rudimentary behaviors such as walking around. But when obstacles are thrown into the environment, then suddenly some complex behaviors like edge following are possible. The different food types that are available can also have a very dramatic affect on the insect behavior as well. Things like the diffusion equation are important because they determine how well the insect will be able to detect food from afar. If it is particularly bad at detecting food then the insect runs a greater chance of dying.