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:
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.
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.
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.
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.