tjbot-ce - v3.0.0
    Preparing search index...

    Class TJBot

    Class representing a TJBot

    Index

    Properties

    config: TJBotConfig

    TJBot configuration

    Raspberry Pi hardware driver

    rpiModel: string

    Raspberry Pi model on which TJBot is running

    "Raspberry Pi 5"
    
    Hardware: typeof Hardware = Hardware

    Hardware list

    VERSION: string = ...

    TJBot library version

    Methods

    • Moves TJBot's arm all the way back. If this method doesn't move the arm all the way back, the servo motor stop point defined in TJBot.Servo.ARM_BACK may need to be overridden. Valid servo values are in the range [500, 2300].

      Returns Promise<void>

      Resolves when the arm is fully back.

      if the servo hardware is not initialized

      tj.armBack()
      @public
    • Describe an image using the configured vision engine (Azure only).

      Parameters

      • image: string | Buffer<ArrayBufferLike>

        Image buffer or file path

      Returns Promise<ImageDescriptionResult>

    • Detect faces in an image using the configured vision engine.

      Parameters

      • image: string | Buffer<ArrayBufferLike>

        Image buffer or file path

      Returns Promise<{ isFaceDetected: boolean; metadata: FaceDetectionMetadata[] }>

    • Detect objects in an image using the configured vision engine.

      Parameters

      • image: string | Buffer<ArrayBufferLike>

        Image buffer or file path

      Returns Promise<ObjectDetectionResult[]>

    • List the AI/ML models on this device.

      Parameters

      • OptionalmodelType: ModelType
      • installedOnly: boolean = true

      Returns string[]

      Array of installed model keys

    • Initialize TJBot with configuration. Can be called multiple times to reconfigure. Performs cleanup of previous initialization, loads configuration, detects hardware, initializes all configured hardware and AI models eagerly.

      Parameters

      • OptionaloverrideConfig: Partial<TJBotConfigSchema>

        (optional) Configuration object to overlay on top of loaded config.

      • OptionalrecipeConfigPath: string

        (optional) Path to recipe configuration file (default: recipe.toml in current working directory)

      Returns Promise<TJBot>

      if configuration file cannot be loaded, is invalid, or cleanup fails

    • Listen for a spoken utterance (offline mode - returns transcript).

      Returns Promise<string>

      The transcribed text

      if the microphone hardware is not initialized

    • Listen for a spoken utterance (streaming mode - uses callbacks).

      Parameters

      • onPartialResult: (text: string) => void

        Callback for partial transcription results

      • onFinalResult: (text: string) => void

        Callback for final transcription result

      Returns Promise<void>

      Promise that resolves when transcription completes

      if the microphone hardware is not initialized

    • Capture an image and save it in the given path.

      Parameters

      • OptionalfilePath: string

        (optional) Path at which to save the photo file. If not specified, photo will be saved in a temp location.

      Returns Promise<string>

      Path at which the photo was saved.

      if the camera hardware is not initialized

    • Lowers TJBot's arm. If this method doesn't move the arm all the way back, the servo motor stop point defined in TJBot.Servo.ARM_DOWN may need to be overridden. Valid servo values are in the range [500, 2300].

      Returns Promise<void>

      Resolves when the arm is fully lowered.

      if the servo hardware is not initialized

      tj.lowerArm()
      @public
    • Play a sound at the specified path.

      Parameters

      • soundFile: string

        The path to the sound file to be played.

      Returns Promise<void>

    • Pulse the LED a single time.

      Parameters

      • color: string

        The color to shine the LED. May be specified in a number of formats, including: hexadecimal, (e.g. "0xF12AC4", "11FF22", "#AABB24"), "on", "off", or may be a named color in the colornames package. Hexadecimal colors follow an #RRGGBB format.

      • duration: number = 1.0

        The duration the pulse should last. The duration should be in the range [0.5, 2.0] seconds.

      Returns Promise<void>

      A promise that resolves when the LED pulse animation completes.

      if the LED hardware is not initialized, color is invalid, or duration exceeds 2.0 seconds

    • Raises TJBot's arm. If this method doesn't move the arm all the way back, the servo motor stop point defined in TJBot.Servo.ARM_UP may need to be overridden. Valid servo values are in the range [500, 2300].

      Returns Promise<void>

      Resolves when the arm is fully raised.

      if the servo hardware is not initialized

      tj.raiseArm()
      @public
    • Get a random color.

      Returns string

      Random named color.

    • Capture an image and return it as a buffer.

      Returns Promise<Buffer<ArrayBufferLike>>

      The captured image as a buffer.

      if the camera hardware is not initialized

    • Change the level of TJBot's logging.

      Parameters

      Returns void

    • Change the color of the LED.

      Parameters

      • color: string

        The color to shine the LED. May be specified in a number of formats, including: hexadecimal, (e.g. "0xF12AC4", "11FF22", "#AABB24"), "on", "off", or may be a named color in the colornames package. Hexadecimal colors follow an #RRGGBB format.

      Returns Promise<void>

      A promise that resolves when the LED color has been set.

      if the LED hardware is not initialized or if color is invalid

    • Get the list of all colors recognized by TJBot.

      Returns string[]

      List of all named colors recognized by shine() and pulse().

    • Sleep for the specified number of seconds.

      Parameters

      • sec: number

        Number of seconds to sleep

      Returns Promise<void>

    • Speak a message.

      Parameters

      • message: string

        The message to speak.

      Returns Promise<void>

      if the speaker hardware is not initialized

    • Waves TJBots's arm once.

      Returns Promise<void>

      Resolves when the wave is complete.

      if the servo hardware is not initialized

      tj.wave()
      @public
    • Get the singleton instance of TJBot.

      Returns TJBot

      The singleton TJBot instance

    • Get recipe-specific configuration. This method can be used before calling TJBot.getInstance().initialize() in case a recipe needs to dynamically determine which hardware components should be configured.

      Parameters

      • recipeConfigPath: string = 'recipe.toml'

        (optional) Path to recipe configuration file (default: recipe.toml in current working directory)

      Returns Record<string, unknown>

      The recipe configuration as a key-value object. If no recipe configuration file is found, returns an empty object.