Toio_CoreCube management class Toio_CoreCubeを管理するクラス

Hierarchy

  • default

Implements

Constructors

Properties

functionButtonPress: null | ((value) => void) = null

Type declaration

    • (value): void
    • Parameters

      • value: number

      Returns void

functionMotionChange: null | ((value) => void) = null

Type declaration

    • (value): void
    • Parameters

      • value: number

      Returns void

ioKeys?: string[]
keys: string[] = []
ondisconnect?: ((reason) => void)

Type declaration

    • (reason): void
    • Parameters

      • reason: any

      Returns void

params: any
peripheral: null | BleRemotePeripheral = null
requiredKeys: string[] = []

Methods

  • Connect to the device

    デバイスに接続

    Parameters

    • timeout: number

      (not used)

    Returns Promise<number>

  • Get the remaining battery power of the Toio_CoreCube

    Toio_CoreCubeのバッテリー残量を取得

    Returns Promise<number>

    remaining battery power バッテリー残量

    Range 範囲 0~100 (Unit 単位: 10 %)

  • Get button state from the Toio_CoreCube

    Toio_CoreCubeのボタンの状態を取得

    Returns Promise<boolean>

    Whether the button is pressed

    ボタンが押されたかどうか

  • Get motion detection data from the Toio_CoreCube

    Toio_CoreCubeからのモーション検出データを取得

    Returns Promise<{
        attitude: number;
        isCollision: boolean;
        isDoubletap: boolean;
        isHorizon: boolean;
    }>

    motion detection data モーション検出データ

    {

    isHorizon: horizontal or not 水平かどうか,

    isCollision: detect collision or not 衝突検知したかどうか,

    isDoubletap: detect double tap or not ダブルタップ検出したかどうか,

    attitude: posture 姿勢

    (1: top faces upward 天面が上, 2: bottom faces upward 底面が上, 3: rear side faces upward 背面が上, 4: front side faces upward 正面が上. 5: right side faces upward 右側面が上, 6: left side faces upward 左側面が上)

    }
  • Get the absolute position and angle of Toio_CoreCube

    (For more detail, please see https://toio.github.io/toio-spec/docs/ble_id )

    Toio_CoreCubeが存在している絶対位置や角度を取得

    (詳細は https://toio.github.io/toio-spec/docs/ble_id を参照してください。)

    Returns Promise<{
        angle: number;
        posSensorAngle: number;
        posSensorX: number;
        posSensorY: number;
        posX: number;
        posY: number;
    }>

    absolute position data 絶対位置データ

    {

    posX: X coordinate value of the center of the cube キューブ中心のx座標 (Position ID),

    posY: Y coordinate value of the center of the cube キューブ中心のY座標 (Position ID),

    angle: angle value of the center of the cube キューブの角度 (Range 範囲: 0~360 deg),

    posSensorX: X coordinate value of the identification sensor 読み取りセンサーのX座標 (Position ID),

    posSensorY: Y coordinate value of the identification sensor 読み取りセンサーのY座標 (Position ID),

    posSensorAngle: angle value of the identification sensor 読み取りセンサーの角度 (Range 範囲: 0~360 deg)

    }
  • Turn the wheel to move the Toio_CoreCube

    タイヤを回してToio_CoreCubeを動かす

    Parameters

    • _leftWheelPower: number = 0

      left wheel power 左側のタイヤ出力 (Range 範囲: -255~255)

      a positive value rotates forward, a negative value rotates backward

      正の値は前方、負の値は後方へ回転

    • _rightWheelPower: number = 0

      right wheel power 左側のタイヤ出力 (Range 範囲: -255~255)

      a positive value rotates forward, a negative value rotates backward

      正の値は前方、負の値は後方へ回転

    Returns Promise<void>

  • Directs the Toio_CoreCube to the specified Position ID

    (For more detail, please see https://toio.github.io/toio-spec/en/docs/ble_motor/#motor-control-with-target-specified )

    Toio_CoreCubeを指定したPosition IDへ移動

    (詳細は https://toio.github.io/toio-spec/docs/ble_motor#%E7%9B%AE%E6%A8%99%E6%8C%87%E5%AE%9A%E4%BB%98%E3%81%8D%E3%83%A2%E3%83%BC%E3%82%BF%E3%83%BC%E5%88%B6%E5%BE%A1 を参照してください)

    Parameters

    • timeoutSec: number = 5

      timeout タイムアウト (Unit 単位: 1 sec)

    • moveType: number = 0

      method of movement 移動タイプ

      (0: move while rotating 回転しながら移動, 1: move while rotating without moving backwards 後退せず回転しながら移動, 2: move after rotating 回転してから移動)

    • maxWheelPower: number = 30

      maximum motor speed モーターの最大速度 (Range 範囲 10~255)

    • wheelPowerType: number = 0

      speed change type 速度変化タイプ

      (0: constant 速度一定, 1: gradual acceleration 徐々に加速, 2: gradual deceleration 徐々に減速, 3: accelerate to the midpoint and decelerate to the target point 中間地点まで加速し目標地点まで減速)

    • targetPosX: number = 0

      target point X coordinates 目標地点のX座標 (Position ID)

      Range 範囲: 0~65535 (65535: same as for write operation 書き込み操作時と同じ)

    • targetPosY: number = 0

      target point Y coordinates 目標地点のY座標 (Position ID)

      Range 範囲: 0~65535 (65535: same as for write operation 書き込み操作時と同じ)

    • targetAngle: number = 0

      angle of the cube at the target point 目標地点でのキューブの角度

    Returns Promise<void>

  • Verify that the received peripheral is from the Toio_CoreCube

    受け取ったPeripheralがToio_CoreCubeのものかどうかを確認する

    Parameters

    • peripheral: BleRemotePeripheral

      instance of BleRemotePeripheral BleRemotePeripheralのインスタンス

    Returns boolean

    Whether it is the Toio_CoreCube

    Toio_CoreCubeかどうか

Generated using TypeDoc