⚙️ MotorSingle動作テスト


🧪 テスト内容

個別のモーターを指定し、回転方向と回転速度を制御します。

ここでは、モーターの出力を段階的に増減させてから停止する一連の動作を行います。


🔧 使用関数・構文

drone.sendMotorSingle(index, Rotation.Direction, speed)
パラメータ 説明
index モーターのインデックス番号(0〜3)
Rotation 回転方向(Rotation.ClockwiseRotation.CounterClockwise
speed 回転速度(数値例:1000〜2000)

🧭 モーター番号対応表

モーター位置 インデックス (index) 推奨回転方向
右前 0 Clockwise(時計回り)
左前 1 CounterClockwise(反時計)
左後 2 Clockwise
右後 3 CounterClockwise
from time import sleep

from CodingDrone.drone import *
from CodingDrone.protocol import *

def eventAck(ack):
    print("eventAck()")
    print("-   DataType: {0}".format(ack.dataType.name))
    print("-      CRC16: 0x{0:04X}".format(ack.crc16))
    print("- SystemTime: {0}".format(ack.systemTime))

if __name__ == '__main__':

    drone = Drone()
    drone.open()

    # イベントハンドリング関数登録
    drone.setEventHandler(DataType.Ack, eventAck)
    sleep(0.01)

    drone.sendMotorSingle(1, Rotation.Clockwise, 1000)
    sleep(2)

    drone.sendMotorSingle(1, Rotation.Clockwise, 2000)
    sleep(2)

    drone.sendMotorSingle(1, Rotation.Clockwise, 3000)
    sleep(2)

    drone.sendMotorSingle(1, Rotation.Clockwise, 2000)
    sleep(2)

    drone.sendMotorSingle(1, Rotation.Clockwise, 1000)
    sleep(2)

    drone.sendStop()
    sleep(0.1)

    drone.close()

⚠️ 注意事項