Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
buzz_examples [2016/09/02 13:28] – [Square Pattern Formation] ilpincy | buzz_examples [2018/03/18 22:58] (current) – root | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Buzz Example Gallery ====== | ====== Buzz Example Gallery ====== | ||
- | ===== Generic examples ====== | + | ===== Calculation of a Distance Gradient |
- | + | ||
- | ==== Calculation of a Distance Gradient ==== | + | |
The aim of this code is to have a group of robots form a distance gradient from a source. | The aim of this code is to have a group of robots form a distance gradient from a source. | ||
Line 42: | Line 40: | ||
</ | </ | ||
- | ==== Hexagonal Pattern Formation ==== | + | ===== Hexagonal Pattern Formation |
Hexagonal patterns can be formed in a simple way by mimicking particle interaction. A simple model of particle interaction is the [[https:// | Hexagonal patterns can be formed in a simple way by mimicking particle interaction. A simple model of particle interaction is the [[https:// | ||
Line 77: | Line 75: | ||
var accum = neighbors.map(lj_vector).reduce(lj_sum, | var accum = neighbors.map(lj_vector).reduce(lj_sum, | ||
if(neighbors.count() > 0) | if(neighbors.count() > 0) | ||
- | math.vec2.scale(accum, | + | math.vec2.scale(accum, |
# Move according to vector | # Move according to vector | ||
goto(accum.x, | goto(accum.x, | ||
Line 96: | Line 94: | ||
</ | </ | ||
- | ==== Square Pattern Formation ==== | + | ===== Square Pattern Formation |
- | <code buzz hexagon.bzz> | + | To form square lattice, we can build upon the previous example. The insight is to notice that, in a square lattice, we can color the nodes forming the lattice with two shades, e.g., red and blue, and then mimic the [[http:// |
+ | |||
+ | With this idea in mind, the following script divides the robots in two swarms: those with an even id and those with an odd id. Then, using '' | ||
+ | |||
+ | <code buzz square.bzz> | ||
# We need this for 2D vectors | # We need this for 2D vectors | ||
# Make sure you pass the correct include path to "bzzc -I < | # Make sure you pass the correct include path to "bzzc -I < | ||
Line 104: | Line 106: | ||
# Lennard-Jones parameters | # Lennard-Jones parameters | ||
- | TARGET_KIN | + | TARGET_KIN |
- | EPSILON_KIN | + | EPSILON_KIN |
- | TARGET_NONKIN | + | TARGET_NONKIN |
- | EPSILON_NONKIN = 100. | + | EPSILON_NONKIN = 100.0 |
# Lennard-Jones interaction magnitude | # Lennard-Jones interaction magnitude | ||
Line 135: | Line 137: | ||
accum = neighbors.nonkin().map(lj_vector_nonkin).reduce(lj_sum, | accum = neighbors.nonkin().map(lj_vector_nonkin).reduce(lj_sum, | ||
if(neighbors.count() > 0) | if(neighbors.count() > 0) | ||
- | math.vec2.scale(accum, | + | math.vec2.scale(accum, |
# Move according to vector | # Move according to vector | ||
goto(accum.x, | goto(accum.x, | ||
Line 158: | Line 160: | ||
} | } | ||
</ | </ | ||
- | |||
- | ===== Wheeled-robot Specific ===== | ||
- | |||
- | TODO | ||
- | |||
- | ===== Flying-robot Specific ===== | ||
- | |||
- | TODO |