larvaworld.lib.model.modules.brain ================================== .. py:module:: larvaworld.lib.model.modules.brain Classes ------- .. autoapisummary:: larvaworld.lib.model.modules.brain.Brain larvaworld.lib.model.modules.brain.DefaultBrain Module Contents --------------- .. py:class:: Brain(conf: Any, agent: Any | None = None, dt: float | None = None, **kwargs: Any) Bases: :py:obj:`larvaworld.lib.param.NestedConf` Base brain class for agent behavioral control. Orchestrates sensory processing and locomotor control for autonomous agents in simulation. Integrates multiple sensory modalities (olfaction, touch, thermosensation, wind) with memory and locomotor modules. Attributes: olfactor: Olfactory sensor module for odor detection toucher: Tactile sensor module for contact sensing windsensor: Wind sensor module for air flow detection thermosensor: Temperature sensor module for thermal gradients locomotor: Locomotor module for movement control agent: Parent agent instance (polymorphic: LarvaRobot, LarvaSim, etc.) dt: Simulation time step (seconds) modalities: Dict of sensory modalities with sensors and processing functions Example: >>> brain = Brain(conf=brain_conf, agent=my_agent, dt=0.1) >>> brain.sense(pos=agent.pos, reward=False) >>> print(f"Total sensory input: {brain.A_in}") .. py:attribute:: olfactor .. py:attribute:: toucher .. py:attribute:: windsensor .. py:attribute:: thermosensor .. py:attribute:: agent :value: None .. py:attribute:: dt :value: None .. py:attribute:: locomotor :type: larvaworld.lib.model.modules.locomotor.Locomotor .. py:attribute:: modalities .. py:method:: init_sensors() -> None .. py:method:: sense_odors(pos: Any | None = None) -> dict[str, Any] .. py:method:: sense_food_multi(**kwargs: Any) -> dict[Any, int] .. py:method:: sense_wind(**kwargs: Any) -> dict[str, float] .. py:method:: sense_thermo(pos: Any | None = None) -> dict[str, float] .. py:method:: sense(pos: Any | None = None, reward: bool = False) -> None .. py:property:: A_in :type: float .. py:property:: A_olf :type: float .. py:property:: A_touch :type: float .. py:property:: A_thermo :type: float .. py:property:: A_wind :type: float .. py:class:: DefaultBrain(conf: Any, agent: Any | None = None, dt: float | None = None, **kwargs: Any) Bases: :py:obj:`Brain` Default larva brain implementation with full sensory integration. Extends base Brain with automatic sensor module construction and integrated locomotor stepping. Provides complete sensorimotor loop for autonomous larva agents. Args: conf: Brain configuration dict with keys: - 'olfactor': Olfactory sensor config (or None) - 'toucher': Tactile sensor config (or None) - 'windsensor': Wind sensor config (or None) - 'thermosensor': Thermal sensor config (or None) - 'memory': Memory module config (or None) - 'locomotor': Locomotor module config agent: Parent agent instance (LarvaRobot, LarvaSim, or compatible). Must have attributes: model, radius, pos, touch_sensorIDs dt: Simulation time step (seconds). Defaults to agent.model.dt **kwargs: Additional keyword arguments passed to parent Brain Returns: Tuple of (linear_velocity, angular_velocity, crawl_flag) Example: >>> brain = DefaultBrain(conf=brain_config, agent=my_larva, dt=0.1) >>> lin_vel, ang_vel, crawling = brain.step(pos=larva.pos, on_food=False) .. py:method:: step(pos: Any, on_food: bool = False, **kwargs: Any) -> tuple[float, float, bool]