Robotics
Robotics: autonomous robots and robot swarms.
LightEmittingRobotElement(label, *, phi=0.0, light=0.0, speed=1.0, values=None, size=None, space=None)
Bases: Element
Light-emitting robot that moves in the direction phi.
Its speed is set by the light of the others it senses.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the agent or group. |
required |
phi
|
Annotated[object, Period(2 * pi)]
|
The initial direction of motion. |
0.0
|
light
|
Annotated[float, closed_open(0, oo)]
|
The light of the other robots the robot measures now. |
0.0
|
speed
|
Annotated[float, closed_open(0, oo)]
|
The speed the robot moves at. |
1.0
|
values
|
Mapping[str, object] | None
|
Further values by name, such as the position |
None
|
size
|
int | None
|
The number of robots, or |
None
|
space
|
BaseSpace | None
|
The arena, a continuous space whose axes |
None
|
Examples:
>>> from skcomplex.systems.engineering.robotics import LightEmittingRobotElement
>>> LightEmittingRobotElement('robot', phi=1.0).phi
1.0
Source code in src/skcomplex/systems/engineering/robotics/_light_emitting_robots.py
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 | |
LightEmittingRobotsSystem(n_robots=50, *, delay=10.0, side=10.0, I0=5.0, r0=1.0, V0=1.0, V_inf=0.1, tau=2.0, step=0.5, random_state=0, label='system', solver='auto', backend='auto')
Bases: BaseSystem
Light-emitting robots that cluster or spread by their sensing of light.
They cluster when they sense the light of the others late and spread when early. Every robot emits a Gaussian light
and measures the total light of the others, I_i = sum_j I0 exp(-d_ij^2 / r0^2) over the shortest distances on a
periodic square arena. It moves at the speed V_inf + (V0 - V_inf) exp(-I_i(t - delay)) in a direction that
diffuses with the time scale tau. A robot with a positive delay crosses a dark region at the fast speed it sensed
earlier in the dark and slows down only once it is in the light, so the robots linger near each other and form
clusters. A negative delay, a prediction of the light by its trend, makes a robot slow down before it reaches the
light and speed up before it leaves it, so the robots avoid each other and spread over the arena. Every step lasts
step, so the default run of 400 steps covers 200 s.
The system has the group robots of directions phi, measured lights light, and speeds speed, at positions in
the arena.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n_robots
|
int
|
The number of robots. |
50
|
delay
|
float
|
The sensory delay, negative for a prediction. |
10.0
|
side
|
float
|
The side of the periodic square arena. |
10.0
|
I0
|
float
|
The intensity of the light of every robot. |
5.0
|
r0
|
float
|
The width of the light of every robot. |
1.0
|
V0
|
float
|
The speed in the dark. |
1.0
|
V_inf
|
float
|
The speed in strong light. |
0.1
|
tau
|
float
|
The time scale of rotational diffusion. |
2.0
|
step
|
float
|
The time of one step. |
0.5
|
random_state
|
int | Generator | None
|
The seed or generator of the initial positions and directions. |
0
|
label
|
str
|
The label of the system, which names it when it is nested in another one. |
'system'
|
solver
|
BaseSolver | str
|
The solver of the problem, or |
'auto'
|
backend
|
BaseBackend | str
|
The backend that evaluates the compiled functions, or |
'auto'
|
Examples:
>>> from skcomplex.systems.engineering.robotics import LightEmittingRobotsSystem
>>> LightEmittingRobotsSystem(5).prepare().system_.elements[0].size
5
Source code in src/skcomplex/systems/engineering/robotics/_light_emitting_robots.py
288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 | |
LightSeekingRobotsSystem(n_robots=20, *, delay=5.0, V0=1.0, V_inf=0.1, I0=1.0, r0=1.0, tau=1.0, R=2.0, label='system', solver='auto', backend='auto')
Bases: BaseSystem
Light-sensitive robots in a circular well.
Their sensory delay decides whether they gather in the light. Each robot moves at
V_inf + (V0 - V_inf) exp(-I(t - delay)) in a direction that diffuses with time scale tau, in the Gaussian light
I = I0 exp(-(x^2 + y^2) / r0^2) at the centre of a well of radius R. The robots start at the centre, in
directions spread around the circle, and do not interact. A positive delay drives them out of the light: a robot
crosses the light at the fast speed it measured in the dark and lingers outside at the slow speed it measured in the
light, so robots with a delay spend less time in the light than robots without one.
The system has the group robots of positions x, y and directions phi.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n_robots
|
int
|
The number of robots. |
20
|
delay
|
float
|
The sensory delay. |
5.0
|
V0
|
float
|
The speed in the dark. |
1.0
|
V_inf
|
float
|
The speed in strong light. |
0.1
|
I0
|
float
|
The intensity at the centre of the light. |
1.0
|
r0
|
float
|
The width of the light. |
1.0
|
tau
|
float
|
The time scale of rotational diffusion. |
1.0
|
R
|
float
|
The radius of the well. |
2.0
|
label
|
str
|
The label of the system, which names it when it is nested in another one. |
'system'
|
solver
|
BaseSolver | str
|
The solver of the problem, or |
'auto'
|
backend
|
BaseBackend | str
|
The backend that evaluates the compiled functions, or |
'auto'
|
Examples:
>>> from skcomplex.systems.engineering.robotics import LightSeekingRobotsSystem
>>> LightSeekingRobotsSystem(4).prepare().system_.elements[0].size
4
Source code in src/skcomplex/systems/engineering/robotics/_robots.py
484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 | |
LightSensitiveRobotElement(label, *, x=0.0, y=0.0, phi=0.0, size=None, space=None)
Bases: Element
Robot at the position x, y that moves in the direction phi.
LightSensitivityInteraction sets its speed from the light it measures.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the robot or the group. |
required |
x
|
object
|
The initial horizontal position. |
0.0
|
y
|
object
|
The initial vertical position. |
0.0
|
phi
|
Annotated[object, Period(2 * pi)]
|
The initial direction of motion. |
0.0
|
size
|
int | None
|
The number of robots, or |
None
|
space
|
BaseSpace | None
|
The plane, a continuous space whose axes |
None
|
Examples:
>>> from skcomplex.systems.engineering.robotics import LightSensitiveRobotElement
>>> LightSensitiveRobotElement('robot', phi=1.0).phi
1.0
Source code in src/skcomplex/systems/engineering/robotics/_robots.py
65 66 67 68 69 70 71 72 73 74 75 76 77 78 | |
LightSensitivityInteraction(label, *, target, V0=1.0, V_inf=0.1, I0=1.0, r0=1.0, tau=1.0, R=2.0, delay=0.0)
Bases: Interaction
Motion of a robot in a Gaussian light field that slows down in light.
It reacts to the light it measured a delay ago. The robot moves at the speed
v = V_inf + (V0 - V_inf) exp(-I(t - delay)) in the direction phi, which diffuses with time scale tau,
dphi = sqrt(2 / tau) dW. The light is I(x, y) = I0 exp(-(x^2 + y^2) / r0^2), and a wall at radius R reflects
the robot back into a circular well.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the interaction. |
required |
target
|
Role
|
The path of the robot or the group of robots. |
required |
V0
|
Annotated[float, closed_open(0, oo)]
|
The speed in the dark. |
1.0
|
V_inf
|
Annotated[float, closed_open(0, oo)]
|
The speed in strong light. |
0.1
|
I0
|
Annotated[float, closed_open(0, oo)]
|
The intensity at the centre of the light. |
1.0
|
r0
|
Annotated[float, open(0, oo)]
|
The width of the light. |
1.0
|
tau
|
Annotated[float, open(0, oo)]
|
The time scale of rotational diffusion. |
1.0
|
R
|
Annotated[float, open(0, oo)]
|
The radius of the well. |
2.0
|
delay
|
float
|
The sensory delay, 0 for a robot that reacts to the light it measures now. |
0.0
|
Examples:
>>> from skcomplex.systems.engineering.robotics import LightSensitivityInteraction
>>> LightSensitivityInteraction('light', target='robots', delay=5.0).delay
5.0
Source code in src/skcomplex/systems/engineering/robotics/_robots.py
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 | |
SensoryDelayInteraction(label, *, target, I0=5.0, r0=1.0, V0=1.0, V_inf=0.1, tau=2.0, delay=0.0, step=0.5, side=10.0)
Bases: Interaction
Motion of light-emitting robots whose speed follows the light of the others.
The light is sensed with a delay. Every robot emits the Gaussian light I0 exp(-d^2 / r0^2) at the distance d,
and measures the total light I_i of the other robots, at the shortest distances on the torus. It moves at the
speed V_inf + (V0 - V_inf) exp(-I_i(t - delay)) in its direction, which diffuses with the time scale tau,
phi <- phi + sqrt(2 step / tau) w with a standard normal w. A positive delay reads the light measured that long
ago, and a negative delay predicts it by the linear extrapolation I(t) - delay I'(t), never below 0. Before the
delay has passed, a robot uses the earliest light it measured. Every step of the rule lasts step.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the interaction. |
required |
target
|
Role
|
The path of the group of robots. |
required |
I0
|
float
|
The intensity of the light of every robot. |
5.0
|
r0
|
float
|
The width of the light of every robot. |
1.0
|
V0
|
float
|
The speed in the dark. |
1.0
|
V_inf
|
float
|
The speed in strong light. |
0.1
|
tau
|
float
|
The time scale of rotational diffusion. |
2.0
|
delay
|
float
|
The sensory delay, negative for a prediction. |
0.0
|
step
|
float
|
The time of one step. |
0.5
|
side
|
float
|
The side of the periodic square arena. |
10.0
|
Examples:
>>> from skcomplex.systems.engineering.robotics import SensoryDelayInteraction
>>> SensoryDelayInteraction('motion', target='robots', delay=-10.0).delay
-10.0
Source code in src/skcomplex/systems/engineering/robotics/_light_emitting_robots.py
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 | |
SwarmRobotElement(label, *, heading=0.0, connections=0.0, illuminated=1.0, speed=0.2, radio_range=4.0, alpha=20.0, avoid_illuminated=1.5, avoid_shadowed=1.0, shadow_angle=0.5, beacon_x=95.0, beacon_y=50.0, arena=100.0, values=None, size=None, space=None)
Bases: Element
Robot of the swarmtaxis algorithm.
It keeps in radio contact with the swarm and avoids its neighbours, by the rule of SwarmtaxisInteraction.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the agent or group. |
required |
heading
|
Annotated[object, Period(2 * pi)]
|
The direction of motion. |
0.0
|
connections
|
Annotated[float, NN]
|
The number of robots within radio range at the last step. |
0.0
|
illuminated
|
Annotated[float, FiniteEnumeratedSet([0, 1])]
|
Whether the robot sees the beacon. |
1.0
|
speed
|
Annotated[float, closed_open(0, oo)]
|
The distance moved per step. |
0.2
|
radio_range
|
Annotated[float, open(0, oo)]
|
The range of the radio pings. |
4.0
|
alpha
|
Annotated[float, closed_open(0, oo)]
|
The number of connections below which a robot that loses one turns around. |
20.0
|
avoid_illuminated
|
Annotated[float, closed_open(0, oo)]
|
The avoidance radius of illuminated robots. |
1.5
|
avoid_shadowed
|
Annotated[float, closed_open(0, oo)]
|
The avoidance radius of shadowed robots. |
1.0
|
shadow_angle
|
Annotated[float, closed_open(0, oo)]
|
The half angle of the cone towards the beacon in which another robot casts a shadow. |
0.5
|
beacon_x
|
float
|
The horizontal position of the beacon. |
95.0
|
beacon_y
|
float
|
The vertical position of the beacon. |
50.0
|
arena
|
Annotated[float, open(0, oo)]
|
The side of the square arena, whose walls stop the robot. |
100.0
|
values
|
Mapping[str, object] | None
|
Further values by name, such as the position |
None
|
size
|
int | None
|
The number of robots, or |
None
|
space
|
BaseSpace | None
|
The arena, a continuous space whose axes |
None
|
Examples:
>>> from skcomplex.systems.engineering.robotics import SwarmRobotElement
>>> SwarmRobotElement('robots', values={'x': [1.0, 2.0], 'y': 1.0}, size=2).size
2
Source code in src/skcomplex/systems/engineering/robotics/_robots.py
261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 | |
SwarmtaxisInteraction(label, *, target)
Bases: Interaction
Rule of the swarmtaxis algorithm, which moves a swarm of robots towards a beacon.
Every step a robot counts the robots within its radio range. When it loses a connection and has fewer than alpha
connections, it turns around to stay with the swarm, and when it gains one it turns at random. A robot closer than
its avoidance radius to another turns away from it. A robot is shadowed when another robot lies between it and the
beacon, within the radio range and shadow_angle of the bearing to the beacon, and it is illuminated otherwise.
Illuminated robots avoid at a larger radius than shadowed ones, so they move away from the swarm towards the beacon,
and the swarm follows. The robot then moves forward at its speed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the interaction. |
required |
target
|
Role
|
The path of the group of robots. |
required |
Examples:
>>> from skcomplex.systems.engineering.robotics import SwarmtaxisInteraction
>>> SwarmtaxisInteraction('swarmtaxis', target='robots').target
'robots'
Source code in src/skcomplex/systems/engineering/robotics/_robots.py
323 324 325 | |
move(agent, system)
Update the connections, the shadow, and the heading, and move forward.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent
|
SwarmRobotView
|
The robot. |
required |
system
|
SystemView
|
The system. |
required |
Source code in src/skcomplex/systems/engineering/robotics/_robots.py
387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 | |
SwarmtaxisSystem(n_robots=20, *, size=100.0, spread=3.0, speed=0.2, radio_range=4.0, avoid_illuminated=1.5, avoid_shadowed=1.0, random_state=0, label='system', solver='auto', backend='auto')
Bases: BaseSystem
The swarmtaxis algorithm, which moves a swarm of robots towards a beacon.
Only some of the robots see the beacon. The robots start in a cluster near the left edge of a square arena, with the
beacon at the middle of the right edge. Each robot keeps radio contact with the swarm by turning around when it
loses a connection, and avoids its neighbours. Robots that see the beacon avoid at a larger radius than shadowed
robots, which moves the centre of the swarm towards the beacon. The system has the group robots of headings
heading and illumination illuminated.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n_robots
|
int
|
The number of robots. |
20
|
size
|
float
|
The side of the arena. |
100.0
|
spread
|
float
|
The standard deviation of the initial positions around the start. |
3.0
|
speed
|
float
|
The distance a robot moves per step. |
0.2
|
radio_range
|
float
|
The range of the radio pings. |
4.0
|
avoid_illuminated
|
float
|
The avoidance radius of illuminated robots. |
1.5
|
avoid_shadowed
|
float
|
The avoidance radius of shadowed robots. |
1.0
|
random_state
|
int | Generator | None
|
The seed or generator of the initial positions and headings. |
0
|
label
|
str
|
The label of the system, which names it when it is nested in another one. |
'system'
|
solver
|
BaseSolver | str
|
The solver of the problem, or |
'auto'
|
backend
|
BaseBackend | str
|
The backend that evaluates the compiled functions, or |
'auto'
|
Examples:
>>> from skcomplex.systems.engineering.robotics import SwarmtaxisSystem
>>> SwarmtaxisSystem(5).prepare().system_.elements[0].size
5
Source code in src/skcomplex/systems/engineering/robotics/_robots.py
589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 | |