クラス Robot

# Import Robot class
from robot import Robot

# Create a robot(PiSloth)
robot = Robot(pin_list=[0, 1, 2, 3], name="pisloth")

robot.move_list["forward"] = [
    [0, 40, 0, 15],
    [-30, 40, -30, 15],
    [-30, 0, -30, 0],

    [0, -15, 0, -40],
    [30, -15, 30, -40],
    [30, 0, 30, 0],
    ]

robot.do_action("forward", step=3, speed=90)

API

class robot_hat.Robot(pin_list, db='/root/.config/robot-hat/robot-hat.conf', name=None, init_angles=None, init_order=None, **kwargs)

ベースクラス: _Basic_class

ロボットクラス

このクラスはRobot HATを使ってサーボロボットを作るためのものです

サーボの初期化、全サーボが特定の速度で動くこと、サーボのオフセットなどがあり、ロボットを作りやすくなっています。SunFounderのPiシリーズロボットはすべてこのクラスを使用しています。詳細はそれらをチェックしてください。

PiSloth: https://github.com/sunfounder/pisloth

PiArm: https://github.com/sunfounder/piarm

PiCrawler: https://github.com/sunfounder/picrawler

move_list = {}

プリセットアクション

max_dps = 428

サーボの最大度/秒

__init__(pin_list, db='/root/.config/robot-hat/robot-hat.conf', name=None, init_angles=None, init_order=None, **kwargs)

ロボットクラスを初期化する

パラメータ
  • pin_list (list) -- ピン番号のリスト[0-11]

  • db (str) -- 設定ファイルのパス

  • name (str) -- ロボットの名前

  • init_angles (list) -- 初期角度のリスト

  • init_order (list) -- 初期化の順序のリスト(突然の大電流の場合、サーボは1つずつ初期化され、電源電圧が下がることがあります。デフォルトの順序はピンリストです。場合によっては異なる順序が必要です。このパラメータを使用して設定してください。)

new_list(default_value)

デフォルト値でサーボ角度のリストを作成する

パラメータ

default_value (int or float) -- サーボ角度のデフォルト値

戻り値

サーボ角度のリスト

戻り値の型

list

servo_write_raw(angle_list)

サーボ角度を特定の生の角度に設定する

パラメータ

angle_list (list) -- サーボ角度のリスト

servo_write_all(angles)

元の角度とオフセットを使ってサーボ角度を特定の角度に設定する

パラメータ

angles (list) -- サーボ角度のリスト

servo_move(targets, speed=50, bpm=None)

速度またはBPMでサーボを特定の角度に動かす

パラメータ
  • targets (list) -- サーボ角度のリスト

  • speed (int or float) -- サーボ移動の速度

  • bpm (int or float) -- 分あたりの拍数

do_action(motion_name, step=1, speed=50)

動作名とステップと速度を使ってプレフィックスアクションを実行する

パラメータ
  • motion_name (str) -- 動作

  • step (int) -- 動作のステップ

  • speed (int or float) -- 動作の速度

set_offset(offset_list)

サーボ角度のオフセットを設定する

パラメータ

offset_list (list) -- サーボ角度のリスト

calibration()

全てのサーボをホームポジションに動かす

reset()

サーボを元の位置にリセットする