Field Node - TomHulme/306-Swarm-Robotics-Project GitHub Wiki
Overview
The field node determines a fields soil quality based on rain. The field class generates numbers for rain and sunlight and a soil quality every second. It then publishes the soil quality along a topic that can be accessed by the other robots (grass). The sunlight value is also passed along this topic. Both of these will be used to determine how much the grass needs to grow.
Rain
Rain is implemented by a simple random number generator that generates a random number based on the system time and the field number. The field number is used so that the fields generate different soil qualities, otherwise they would all have the same value. The field node then uses this value to set the soil quality based on the current soil quality and the current rain value.
Sunlight
Sunlight is implemented in a slightly different way. Depending on how long the ros simulation has been running changes what the sunlight value is. Starting at 0 and ending up at 100, the sunlight value mimics a very primitive day/night cycle. For this primitive day/night cycle, I've considered one second to be one hour. The sunlight value has 24 possible values in its cycle. At midnight it is 0 and at midday it is 100. Going from midnight to midday increases the sunlight value, and the opposite decreases it.