larvaworld.lib.model.modules.oscillator
Classes
Base timer module for time tracking and activation control. |
|
Oscillator module for phase-based periodic behaviors. |
Module Contents
- class larvaworld.lib.model.modules.oscillator.Timer(**kwargs: Any)
Bases:
param.ParameterizedBase timer module for time tracking and activation control.
Provides time-step counting, activation state management, and iteration tracking. Base class for all time-dependent modules.
- Attributes:
dt: Simulation time step in seconds ticks: Current elapsed ticks since last reset total_ticks: Total ticks since initialization active: Whether timer/module is currently active complete_iteration: Flag for iteration completion
- Example:
>>> timer = Timer(dt=0.1) >>> timer.count_time() >>> print(f"Elapsed: {timer.t} seconds")
- dt
- ticks = 0
- total_ticks = 0
- active = True
- complete_iteration = False
- count_time() None
- property t: float
- property total_t: float
- reset() None
- start_effector() None
- stop_effector() None
- class larvaworld.lib.model.modules.oscillator.Oscillator(random_phi: bool = True, **kwargs: Any)
Bases:
TimerOscillator module for phase-based periodic behaviors.
Extends Timer with phase tracking and oscillation mechanics. Manages phase progression, iteration detection, and frequency control for all oscillatory behavioral modules.
- Attributes:
freq: Oscillation frequency in Hz phi: Current oscillation phase in radians (0-2π) initial_freq: Frequency at initialization (stored for reset) iteration_counter: Number of completed oscillation cycles complete_iteration: True when phase completes full 2π cycle
- Args:
random_phi: If True, randomize initial phase (default: True) **kwargs: Additional keyword arguments passed to parent Timer
- Example:
>>> oscillator = Oscillator(freq=1.5, random_phi=False) >>> oscillator.oscillate() >>> print(f"Phase: {oscillator.phi}, Completed: {oscillator.complete_iteration}")
- freq
- phi
- initial_freq
- iteration_counter = 0
- set_freq(v: float) None
- get_freq(t: float) float
- oscillate() None
- act_on_complete_iteration() None
- reset() None
- update() None
- phi_in_range(phi_range: tuple[float, float]) bool
- property Act_Phi: float