Skills Overview


1. What is a Skill?

In pyraya, a skill is a modular block of code that encapsulates a specific behavior or capability that a robot can perform. Skills are designed to be easy to use, reusable, and composable—allowing you to build complex robotic behaviors with minimal effort.

Each skill contains the logic needed to carry out its task and exposes a simple interface for configuration and execution.

2. Skill Lifecycle

Each Skill follows a structured lifecycle consisting of three asynchronous methods:

setup()

Called once when the Skill instance is initialized, it is typically used for tasks that prepare the Skill for execution.

Common tasks performed in the setup() method include:

  • Acquiring necessary controllers or dependencies.

  • Initializing internal state or configuration.

  • Logging readiness information.

main()

It is the entry point for the Skill’s behavior and triggered when the Skill is invoked and receives optional keyword arguments passed during execution.

The main() method encapsulates the core logic of the Skill and typically performs the primary task associated with the Skill.

finish()

It is called when the Skill is no longer needed, and is responsible for cleaning up resources, halting background tasks, and completing any final steps in the Skill’s lifecycle.

Common tasks performed in the finish() method include:

  • Releasing controllers.

  • Stopping timers, subscriptions, or other background processes.

  • Logging the shutdown process.

3. Skill Types

Pyraya supports two types of Skills, each tailored for different development needs and behavioral models:

Standard Skill (RayaSkill)

This type of Skill is ideal for linear or procedural logic. It inherits from the RayaSkill base class and follows a typical structure with the setup, main, and finish lifecycle methods.

Use a standard Skill when:

  • The logic can be expressed as a sequence of steps.

  • There’s no need for internal state transitions or complex behavioral flows.

  • You want a simple, readable, and direct execution model.

These Skills are simple to implement and are typically suitable for isolated actions or utilities.

FSM Skill (RayaFSMSkill)

FSM Skills (Finite State Machine Skills) inherit from RayaFSMSkill and are used to model more complex behaviors using discrete, named states and transitions.

Use an FSM Skill when:

  • The Skill needs to handle multiple stages or modes of behavior.

  • You want to manage transitions explicitly using state handlers.

  • The Skill must respond to events or conditions dynamically during execution.

FSM Skills allow you to separate behavior into multiple well-defined states, improving maintainability and readability for more complex scenarios.