Options
All
  • Public
  • Public/Protected
  • All
Menu

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

Hierarchy

  • Toio_CoreCube

Implements

Index

Constructors

constructor

Properties

functionButtonPress

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

functionMotionChange

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

Optional ioKeys

ioKeys: string[]

keys

keys: string[] = []

Optional ondisconnect

ondisconnect: undefined | ((reason: any) => void)

params

params: any

peripheral

peripheral: BleRemotePeripheral | null = null

requiredKeys

requiredKeys: string[] = []

Methods

connectWait

  • connectWait(timeout: number): Promise<number>
  • Connect to the device

    デバイスに接続

    Parameters

    • timeout: number

      (not used)

    Returns Promise<number>

disconnectWait

  • disconnectWait(): Promise<void>
  • Disconnect from the sensor

    センサから切断

    Returns Promise<void>

getBatteryStateWait

  • getBatteryStateWait(): Promise<number>
  • Get the remaining battery power of the Toio_CoreCube

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

    Returns Promise<number>

    remaining battery power バッテリー残量

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

getButtonStateWait

  • getButtonStateWait(): Promise<boolean>
  • Get button state from the Toio_CoreCube

    Toio_CoreCubeのボタンの状態を取得

    Returns Promise<boolean>

    Whether the button is pressed

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

getMotionWait

  • getMotionWait(): Promise<{ attitude: number; isCollision: boolean; isDoubletap: boolean; isHorizon: boolean }>
  • 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 左側面が上)
    
    }

getPositionWait

  • getPositionWait(): Promise<{ angle: number; posSensorAngle: number; posSensorX: number; posSensorY: number; posX: number; posY: number }>
  • 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)
    
    }

moveAroundWait

  • moveAroundWait(_leftWheelPower?: number, _rightWheelPower?: number): Promise<void>
  • Turn the wheel to move the Toio_CoreCube

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

    Parameters

    • Default value _leftWheelPower: number = 0

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

      a positive value rotates forward, a negative value rotates backward

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

    • Default value _rightWheelPower: number = 0

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

      a positive value rotates forward, a negative value rotates backward

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

    Returns Promise<void>

movePositionWait

  • movePositionWait(timeoutSec?: number, moveType?: number, maxWheelPower?: number, wheelPowerType?: number, targetPosX?: number, targetPosY?: number, targetAngle?: number): 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

    • Default value timeoutSec: number = 5

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

    • Default value moveType: number = 0

      method of movement 移動タイプ

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

    • Default value maxWheelPower: number = 30

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

    • Default value 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 中間地点まで加速し目標地点まで減速)

    • Default value targetPosX: number = 0

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

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

    • Default value targetPosY: number = 0

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

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

    • Default value targetAngle: number = 0

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

    Returns Promise<void>

wired

  • wired(obniz: Obniz): void
  • Parameters

    Returns void

Static info

  • Returns ObnizPartsInfo

Static isDevice

  • 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