Pinned Project Overview Post

Project Overview

Introduction There have been numerous researches conducted for the development of algorithms that can be used for environment exploration an...

Tuesday, September 12, 2023

[Post :09] NetLogo Simulation Progress Part - 2

In addition to the links I shared in the previous post, I found this super useful document to learn about NetLogo programming. 

In the simulation, I managed to implement the following behaviors in the agents. In my simulation, I refer to agents as bots. The bots are capable of doing the following tasks,

  • Can detect if the target enters into the vision range
  • Can calculate freedom (what freedom is that?)
  • Can detect the agent with maximum freedom in the local region
  • Can follow a specific bot
  • Can avoid colliding with obstacles in the environment
  • Can detect the edges of the world and turn around 
Let me tell you what each of the mentioned features does and how I managed to implement them.

Detecting targets in the vision range
Before detecting the target, we need to specify the vision range of the bot. The vision range is going to be a circular region around the bot. This is implemented by using the 'in-radius' primitive. The primitive requires the radius as a parameter. in the code, it looks something like this.


Visual representation of the code


The good thing with NetLogo is it is easy to understand written code. The bad thing is it is not easy to write the code to do something I want as it is required to format it to comply with NetLogo rules.

A GUI slide is added to the main interface named 'vision-distance' so that it can be used to adjust and fine-tune the radius value for best performance



Calculating freedom
The algorithm uses a value called 'freedom score' to identify the amount of free space a bot has in its local environment to move around. Whenever there are other agents in the local area, they use this value to decide whether they need to follow someone or move on their own. While it is best to use proximity sensor reading for this purpose which gives a distance value, in NetLogo, a primitive called 'neighbors' is used. This primitive reports the 8 patches around the agent. (The floor area in NetLogo is divided into patches). Accordingly, if there is an obstacle in the neighborhood with the color yellow, it causes the freedom value to be reduced by 1 unit 

Visual representation of freedom score and an example where freedom = 5

Once the freedom score is calculated, in order to convey this score to others, agents use their color. While the base color of a bot is green, depending on the freedom, this color takes different shades. Accordingly, if an agent has maximum freedom of 8, its color is a brighter green. Any agent with a freedom score of 5 or lower will take a darker shade of green. The color representations are as follows,




Obstacle avoidance and world edge detection
The obstacles in the environment are represented in yellow color. Hence agents check for any yellow color patches in front of it in a cone-shaped vision range. To detect the edges of the world, agents use a primitive called 'patch-ahead'. While this primitive reports the patch matches the filtering criteria, it reports the 'nobody' value if the patch being checked lies outside the world edge. In both cases, the agent takes a random maneuver to avoid moving forward and hitting an obstacle or edge.


Following an agent

3 rules are enforced to be followed by agents when following another. 
  • The distance between 2 agents should not exceed a maximum value
  • The distance between 2 agents should not be below a minimum value
  • A cone-shaped region in front of the agent should be empty
These 3 rules combined with freedom score logic, make the whole swarm split into several groups and explore different regions. This helps to explore the area much quicker.

In order to interact with the simulation area, additional procedures are to be developed. These procedures will give the user to ability to place or remove bots on the floor using a mouse, add/remove obstacles, save or load an obstacle map, etc. I will post another article with that information.



No comments:

Post a Comment