# Background Missions The `auto_start` feature allows you to define background behaviors that run automatically when the robot or your custom skill manager starts. This enables you to: * Control the **default autonomous behaviors** on the robot. * Define your **own custom background routines** tailored to your needs. --- ## `start_background_missions` Skill By default, the robot runs an auto-start skill called `start_background_missions`. This skill: * Defines custom **priority levels** in the mission system. * Enqueues built-in background behaviors grouped by priority. * Ensures the robot starts up with essential functionality and expressiveness. ### Example Here's a simplified version of the skill: ```python import asyncio from pymirokai.decorators.skill import skill from pymirokai.enums import PreemptionStrategy from pymirokai.robot import Robot @skill(auto_start=True) async def start_background_missions(robot: Robot): await robot.make_priority_level("SYSTEM", below="MEDIUM", mission_conflict_strategy=PreemptionStrategy.RUN_OLDEST) await robot.make_priority_level("VERY_LOW", below="LOW", mission_conflict_strategy=PreemptionStrategy.RUN_OLDEST) await robot.enqueue_mission("battery_monitor", priority="SYSTEM") await robot.enqueue_mission( "set_default_neck_mode_and_wait_infinitely", priority="VERY_LOW", restart_after_cancellation=True, log_level=logging.ERROR, ) await asyncio.Future() ``` --- ### How It Works * **Mission Priorities**: Skills are assigned a priority level (e.g. `SYSTEM`, `LOW`, `VERY_LOW`). A skill can only take a resource if it is free or used by a lower-priority skill. * **Persistence**: The skill ends with `await asyncio.Future()` to run indefinitely. If this line is removed, any enqueued missions would be cancelled when the skill finishes. * **Priority Listing**: You can call `robot.get_available_priorities()` to inspect available priority levels. --- ## Default Background Skills The following background skills are automatically launched by the `start_background_missions.py` script: ### Interaction and Reactivity * **`obey`** – Enables voice-triggered skill execution. * **`react_to_words`** – Responds expressively to spoken phrases. * **`react_if_ear_touched`** – Reacts when the robot's ears are touched. ### System Monitoring * **`battery_monitor`** – Monitors the battery and gives voice alerts when low. * **`react_when_collisions`** – Responds to detected collisions. * **`enable_asr_only_when_voice_resource_is_free`** – Enables speech recognition only when audio resources are free. ### Autonomy and Intelligence * **`autonomous_planning`** – Manages high-level decision-making and mission planning. * **`react_when_grasping`** – Provides contextual feedback during grasping attempts. * **`react_when_navigating`** – Expresses reactions during navigation. ### Expressive and Social Behaviors * **`human_bond`** – Enables bonding behaviors like idle animations and head tracking. * **`look_towards_destination`** – Directs the head toward the navigation goal. * **`wander_off`** – Triggers random expressive behaviors to simulate lifelike presence. ### Passive Fallback * **`set_default_neck_mode_and_wait_infinitely`** – Sets the neck to a neutral position and waits indefinitely. Acts as a fallback behavior when no other task is running. --- ## Customization You can personalize the robot's background behavior in several ways: * **Disable a behavior**: Simply comment out the corresponding `enqueue_mission()` line in the `start_background_missions.py` file, or disable the whole custom skill file if you don't want the robot to run any background behavior. * **Add your own logic**: Define and enqueue new background skills—either on the robot or via a remote skill manager. This setup gives you full control over the robot's background activity, enabling intelligent, responsive, and expressive default behavior.