モーション#
導入#
VEX AIRドローンは4つのプロペラを搭載しており、あらゆる方向への移動と独立した回転が可能です。モーションコントロール機能により、移動、旋回、速度調整、位置追跡などの操作が可能です。

以下に、利用可能なメソッドの一覧を示します。
アクション
take_off– ドローンを指定された高さまで持ち上げます。land– ドローンを着陸させます。hover- ドローンをその位置に保持します。climb– ドローンを指定された垂直方向に移動させます。climb_for– ドローンを指定された垂直方向に指定された距離だけ移動させます。climb_to– ドローンを指定された高度まで移動させます。move_at– ドローンを指定された方向と速度で移動させます。move_for– ドローンを指定された方向で指定された距離だけ移動させます。move_to– ドローンを同じ方位を維持しながら指定された位置に移動します。turn– ドローンを左または右に旋回させます。turn_for– ドローンを指定された角度だけ回転させます。turn_to– ドローンを特定の方向に向けて旋回させます。move_with_vectors– ベクトルベースの x、y、z、および回転値を使用してドローンを移動します。
ミューテーター
set_steering_mode– ドローンの操縦のためのPOVを設定します。set_movement_mode– ドローンの移動スタイルを設定します。set_climb_velocity– デフォルトの上昇速度を設定します。set_move_velocity– デフォルトの移動速度を設定します。set_turn_velocity- デフォルトの旋回速度を設定します。set_max_z_height- ドローンが飛行できる高さの上限を設定します。set_xyz_position– ドローンの現在位置を設定します。
ゲッターズ
get_max_z_height– ドローンが到達できる最大高度を返します。get_flight_state– ドローンの現在の状態を返します。get_x_position– ドローンの x 座標を返します。get_y_position– ドローンの y 座標を返します。get_z_position– ドローンのz座標を返します。get_safe_mode– ドローンのプロペラロック状態を返します。is_climb_active– ドローンが現在上昇中かどうかを返します。is_move_active– ドローンが現在移動中かどうかを返します。is_turn_active– ドローンが現在旋回しているかどうかを返します。is_hovering- ドローンが現在ホバリングしているかどうかを返します。is_taking_off– ドローンが現在離陸中かどうかを返します。is_landing– ドローンが現在着陸中かどうかを返します。is_landed- ドローンが現在着陸しているかどうかを返します。
行動#
take_off#
take_off はプロペラを始動させ、ドローンを空中に持ち上げます。この操作は、他の動作を行う前に必ず実行する必要があります。
In VEX AIR Competition Matches, take_off must be the first method in your project. The Field Control System (FCS) does not make the drone take off automatically, so your project must handle takeoff. Your project starts running on its own when the FCS enables flight at the start of a Match.
使用法:
drone.take_off(climb_to, units, wait)
パラメータ |
説明 |
|---|---|
|
ドローンが飛行するZ座標(高度)。 |
|
使用する単位:
|
|
オプション |
# Fly for 1 second
drone.take_off(climb_to=500, units=MM)
wait(1, SECONDS)
drone.land()
land#
land はドローンを地上に降ろします。プロジェクトが停止されるまでプロペラは回転し続けます。
使用法:
drone.land(wait)
パラメータ |
説明 |
|---|---|
|
オプション |
# Land after 1 second
drone.take_off(climb_to=500, units=MM)
wait(1, SECONDS)
drone.land()
hover#
hover ドローンはあらゆる方向に移動を停止し、空中の現在の位置を維持します。
Usage:
drone.hover()
パラメータ |
説明 |
|---|---|
このメソッドにはパラメータがありません。 |
# Hold current position for 3 seconds after moving forward
drone.take_off(climb_to=500, units=MM)
drone.move_at(angle=0, velocity=50)
wait(1, SECONDS)
drone.hover()
wait(3, SECONDS)
drone.land()
climb#
climb ドローンを指定された垂直方向に移動します。
Usage:
drone.climb(direction, velocity)
パラメータ |
説明 |
|---|---|
|
ドローンが飛行する方向: |
|
ドローンが上昇する速度をパーセントで表したもの。 |
# Climb upwards for 2 seconds
drone.take_off(climb_to=500, units=MM)
wait(2, SECONDS)
drone.climb(UP, 50)
wait(2, SECONDS)
drone.land()
climb_for#
climb_for は、ドローンを指定された垂直方向に特定の距離だけ移動させます。
使用法:
drone.climb_for(direction, distance, units, velocity, wait)
パラメータ |
説明 |
|---|---|
|
ドローンが飛行する方向: |
|
ドローンが飛行できる距離。 |
|
オプション。距離を表す単位:
|
|
オプション。ドローンが上昇する速度をパーセントで指定します。速度を指定しない場合、デフォルトの速度は50%です。 |
|
オプション |
# Lower drone before landing
drone.take_off(climb_to=700, units=MM)
wait(2, SECONDS)
drone.climb_for(direction=DOWN, distance=300, units=MM, velocity=50)
wait(2, SECONDS)
drone.land()
climb_to#
climb_to はドローンを特定のz位置に移動します。
使用法:
drone.climb_to(z, units, velocity, wait)
パラメータ |
説明 |
|---|---|
|
ドローンが上昇するz座標(整数または小数)。 |
|
オプション。距離を表す単位:
|
|
オプション。ドローンが上昇する速度をパーセントで表したもの。 |
|
オプション |
# Reach 500 mm after takeoff
drone.take_off(climb_to=300, units=MM)
wait(1, SECONDS)
drone.climb_to(z=500, units=MM, velocity=50)
wait(1, SECONDS)
drone.land()
move_at#
move_at は、ドローンを指定された角度と速度で移動させます。
使用法:
drone.move_at(angle, velocity)
パラメータ |
説明 |
|---|---|
|
ドローンが移動する角度を、整数または小数で表したもので、0度から359度の範囲で指定します。 |
|
ドローンが移動する速度をパーセントで表したもの。 |
# Move left for 2 seconds
drone.take_off(climb_to=500, units=MM)
drone.move_at(angle=270, velocity=50)
wait(2, SECONDS)
drone.land()
move_for#
move_for は、現在の set_move_velocity を使用して、ドローンを特定方向に特定の距離だけ移動させます。
使用法:
drone.move_for(angle, distance, units, velocity, wait)
パラメータ |
説明 |
|---|---|
|
ドローンが移動する角度を整数または小数 (float) で表し、0 度から 359 度の範囲で指定します。 |
|
ドローンが移動する距離を、整数または小数で指定します。 |
|
オプション。距離を表す単位:
|
|
オプション。ドローンの移動速度をパーセントで表したもの。 |
|
オプション |
# Move forward for 200 mm
drone.take_off(climb_to=500, units=MM)
wait(1, SECONDS)
drone.move_for(angle=0, distance=200, units=MM, velocity=50)
wait(1, SECONDS)
drone.land()
move_to#
move_to は、ドローンを同じ方位を維持したまま、指定された空中位置まで移動させます。
使用法:
drone.move_to(x, y, z, units, move_velocity, climb_velocity, wait)
パラメータ |
説明 |
|---|---|
|
ドローンが移動する先のx座標。 |
|
ドローンが移動する座標。 |
|
ドローンが移動する先のz座標。 |
|
オプション。距離を表す単位:
|
|
オプション。ドローンの移動速度をパーセントで表したもの。 |
|
オプション。ドローンが上昇する速度をパーセントで表したもの。 |
|
オプション |
# Move diagonally to (300, 300, 800)
drone.take_off(climb_to=300, units=MM)
wait(2, SECONDS)
drone.move_to(x=300, y=300, z=800, units=MM, move_velocity=50, climb_velocity=50)
wait(2, SECONDS)
drone.land()
turn#
turn は、現在の set_turn_velocity を使用してドローンを特定の方向に旋回させます。
使用法:
drone.turn(direction, velocity)
パラメータ |
説明 |
|---|---|
|
ドローンが旋回する方向: |
|
オプション。ドローンが旋回する速度をパーセントで表したもの。 |
# Turn to the right for 2 seconds
drone.take_off(climb_to=500, units=MM)
wait(1, SECONDS)
drone.turn(RIGHT, 50)
wait(2, SECONDS)
drone.land()
turn_for#
turn_for は、現在の set_turn_velocity を使用して、ドローンを現在の向きに対して指定された方向に設定された距離だけ回転させます。
使用法:
drone.turn_for(direction, angle, velocity, wait)
パラメータ |
説明 |
|---|---|
|
ドローンが旋回する方向: |
|
ドローンが旋回する角度を整数または小数 (float) で表したもので、0 度から 359 度までの範囲です。 |
|
オプション。ドローンが旋回する速度をパーセントで表したもの。 |
|
オプション |
# Turn around, then land
drone.take_off(climb_to=500, units=MM)
wait(1, SECONDS)
drone.turn_for(RIGHT, 180)
wait(1, SECONDS)
drone.land()
turn_to#
turn_to は、現在の set_turn_velocity を使用してドローンを特定の方向に向けて旋回させます。
使用法:
drone.turn_to(heading, velocity, wait)
パラメータ |
説明 |
|---|---|
|
ドローンが向きを変える方向(0度から360度まで)。 |
|
オプション。ドローンが旋回する速度をパーセントで表したもの。 |
|
オプション |
# Turn to face each of the cardinal headings
drone.take_off(climb_to=500, units=MM)
drone.turn_to(heading=90, velocity=50)
wait(3, SECONDS)
drone.turn_to(heading=180, velocity=50)
wait(3, SECONDS)
drone.turn_to(heading=270, velocity=50)
wait(3, SECONDS)
drone.turn_to(heading=0, velocity=50)
wait(3, SECONDS)
drone.land()
move_with_vectors#
move_with_vectors は、ベクトルベースのモーションを使用してドローンを移動させ、x軸(水平方向)とy軸(垂直方向)に沿った動きを組み合わせながら、ドローンを回転させます。
注: このメソッドは移動速度と旋回速度の値を直接設定するため、set_move_velocity や set_turn_velocity は使用しません。
使用法:
drone.move_with_vectors(forward, rightward, upward, rotation)
パラメータ |
説明 |
|---|---|
|
ドローンのY軸方向の速度(前進および後退)。-100から100までの値をパーセントで指定します。負の値は後退、正の値は前進を表します。 |
|
ドローンのX軸方向(左右方向)の速度。-100から100までの値をパーセントで指定します。負の値は左方向、正の値は右方向への移動を表します。 |
|
ドローンのZ軸方向の速度(上下方向の動き)。値の範囲は-100~100(パーセント)で、負の値は下降、正の値は上昇を表します。 |
|
ドローンの回転速度。値の範囲は-100から100までで、パーセントで指定します。負の値は反時計回り、正の値は時計回りに回転します。 |
# Move with controller
drone.take_off(climb_to=500, units=MM)
while True:
drone.move_with_vectors(
forward=controller.axis4.position(),
rightward=controller.axis3.position(),
upward=controller.axis1.position(),
rotation=controller.axis2.position()
)
wait(5, MSEC)
変異誘発者#
set_steering_mode#
set_steering_mode は、ドローンを操縦する際に使用する視点を設定します。
使用法:
drone.set_steering_mode(style)
パラメータ |
説明 |
|---|---|
|
ドローンの操縦に使用する視点を設定します。0 |
# Steer based on the drone's starting orientation
# until button 7 is pressed
drone.take_off(climb_to=500, units=MM)
drone.set_steering_mode(HEADLESS)
while not controller.button7.pressing():
drone.move_with_vectors(
forward=controller.axis4.position(),
rightward=controller.axis3.position(),
upward=controller.axis1.position(),
rotation=controller.axis2.position()
)
wait(5, MSEC)
drone.land()
set_movement_mode#
set_movement_mode はドローンの移動スタイルを設定します。
この操作方法は、コントローラーを使ってドローンを操縦する際に使用されます。
使用法:
drone.set_movement_mode(style)
パラメータ |
説明 |
|---|---|
|
ドローンの操縦に使用する速度を設定します。
|
# Control the drone with the balanced movement style
drone.take_off(climb_to=500, units=MM)
drone.set_movement_mode(BALANCED)
while not controller.button5.pressing():
drone.move_with_vectors(
forward=controller.axis4.position(),
rightward=controller.axis3.position(),
upward=controller.axis1.position(),
rotation=controller.axis2.position()
)
wait(5, MSEC)
drone.land()
set_climb_velocity#
set_climb_velocity は、デフォルトの登攀速度をパーセンテージで設定します。これは、登攀に関連する後続のすべてのメソッドに影響します。デフォルトの登攀速度は 50% です。
使用法:
drone.set_climb_velocity(velocity)
パラメータ |
説明 |
|---|---|
|
ドローンが上昇する速度をパーセントで表したもの。 |
# Raise the drone quickly before landing
drone.take_off(climb_to=300, units=MM)
wait(1, SECONDS)
drone.set_climb_velocity(100)
drone.climb_for(direction=UP, distance=500, units=MM, velocity=100)
wait(1, SECONDS)
drone.land()
set_move_velocity#
set_move_velocity は、デフォルトの移動速度をパーセンテージで設定します。これは、移動に関連する後続のすべてのメソッドに影響します。デフォルトの移動速度は 50% です。
使用法:
drone.set_move_velocity(velocity)
パラメータ |
説明 |
|---|---|
|
ドローンが移動する速度をパーセントで表したもの。 |
# Move forward quickly, then reverse slowly
drone.take_off(climb_to=500, units=MM)
drone.set_move_velocity(100)
drone.move_for(angle=0, distance=500, units=MM, velocity=100)
wait(3, SECONDS)
drone.set_move_velocity(20)
drone.move_for(angle=180, distance=500, units=MM, velocity=20)
wait(5, SECONDS)
drone.land()
set_turn_velocity#
set_turn_velocity は、デフォルトの旋回速度をパーセンテージで設定します。これは、旋回に関連する後続のすべてのメソッドに影響します。デフォルトの旋回速度は 50% です。
使用法:
drone.set_turn_velocity(velocity)
パラメータ |
説明 |
|---|---|
|
ドローンが旋回する速度をパーセントで表したもの。 |
# Turn clockwise quickly, then counterclockwise slowly
drone.take_off(climb_to=500, units=MM)
drone.set_turn_velocity(100)
drone.turn_for(RIGHT, 360)
wait(3, SECONDS)
drone.set_turn_velocity(20)
drone.turn_for(LEFT, 360)
wait(5, SECONDS)
drone.land()
set_max_z_height#
set_max_z_height は、ドローンが飛行できる高度の上限を設定します。
使用法:
drone.set_max_z_height(z_height, units)
パラメータ |
説明 |
|---|---|
|
ドローンが上空を飛行しない最大z軸値(整数または小数)。範囲は1000~5000mm、または40~196インチ。 |
|
オプション。距離の単位は次のとおりです
|
# Fly with controller under 1000 mm
drone.set_max_z_height(1000, MM)
drone.take_off(climb_to=500, units=MM)
while not controller.button7.pressing():
drone.move_with_vectors(
forward=controller.axis4.position(),
rightward=controller.axis3.position(),
upward=controller.axis1.position(),
rotation=controller.axis2.position()
)
drone.land()
set_xyz_position#
set_xyz_position ドローンの現在の x、y、または z 座標を指定された値に設定します。
使用法:
drone.set_xyz_position(x, y, z, units)
注: すべてのパラメータはオプションですが、少なくとも1つ (x y、または z) を指定する必要があります。
パラメータ |
説明 |
|---|---|
|
オプション。ドローンに設定する x 座標を |
|
オプション。ドローンに設定するy座標を、 |
|
オプション。ドローンに設定するz座標を、 |
|
オプション。距離を表す単位:
|
# Reset the position to (0, 0, 0), then fly to z position -300
drone.take_off(climb_to=800, units=MM)
drone.set_xyz_position(x=0, y=0, z=0, units=MM)
wait(1, SECONDS)
drone.climb(DOWN, 50)
while not drone.get_z_position() < -300:
wait(5, MSEC)
drone.hover()
wait(1, SECONDS)
drone.land()
ゲッター#
get_max_z_height#
get_max_z_height 、ドローンが到達できる最大高度を整数として返します。
使用法:
drone.get_max_z_height(units)
パラメータ |
説明 |
|---|---|
|
オプション。測定単位:
|
# Display the new z height limit
controller.screen.print(drone.get_max_z_height(MM))
controller.screen.next_row()
drone.take_off(climb_to=500, units=MM)
drone.set_max_z_height(1000, MM)
controller.screen.print(drone.get_max_z_height(MM))
wait(1, SECONDS)
drone.land()
get_flight_state#
get_flight_state ドローンの現在の飛行状態を DroneFlightStateType として返します。
MOTOR_OFF- 他の飛行状態はどれも真ではありません。CALIBRATION- ドローンがセンサーのキャリブレーションを行っています。MOTOR_START- ドローンがモーターを始動しています。FLIGHT_READY- ドローンは飛行準備完了です。FLIGHT- ドローンが飛行中です。
Usage:
drone.get_flight_state()
パラメータ |
説明 |
|---|---|
このメソッドにはパラメータがありません。 |
# Report the flight status as the drone takes off
controller.screen.print("Preparing for flight!")
controller.screen.next_row()
drone.take_off(climb_to=800, units=MM, wait=False)
while not drone.get_flight_state() == MOTOR_START:
wait(5, MSEC)
controller.screen.print("Motors starting...")
controller.screen.next_row()
while not drone.get_flight_state() == FLIGHT:
wait(5, MSEC)
controller.screen.print("Take off!")
get_x_position#
get_x_position は、ドローンの x 座標を小数 (float) として返します。
Usage:
drone.get_x_position(units)
パラメータ |
説明 |
|---|---|
|
オプション。位置を表す単位:
|
# Move to (200, 0, 500)
drone.take_off(climb_to=500, units=MM)
wait(1, SECONDS)
drone.move_at(angle=90, velocity=50)
while not drone.get_x_position() > 200:
wait(5, MSEC)
drone.hover()
wait(1, SECONDS)
drone.land()
get_y_position#
get_y_position は、ドローンの y 座標を小数 (float) として返します。
使用法:
drone.get_y_position(units)
パラメータ |
説明 |
|---|---|
|
オプション。位置を表す単位:
|
# Move to (0, 200, 500)
drone.take_off(climb_to=500, units=MM)
wait(1, SECONDS)
drone.move_at(angle=0, velocity=50)
while not drone.get_y_position() > 200:
wait(5, MSEC)
drone.hover()
wait(1, SECONDS)
drone.land()
get_z_position#
get_y_position はドローンの z 座標を小数 (float) として返します。
使用法:
drone.get_z_position(units)
パラメータ |
説明 |
|---|---|
|
オプション。位置を表す単位:
|
# Move to (0, 0, 800)
drone.take_off(climb_to=500, units=MM)
wait(1, SECONDS)
drone.climb(UP, 50)
while not drone.get_z_position() > 800:
wait(5, MSEC)
drone.hover()
wait(1, SECONDS)
drone.land()
get_safe_mode#
get_safe_mode は、ドローンでプロペラロックが有効になっているかどうかを示すブール値 Boolean
True– プロペラロックが有効です。False– プロペラロックが有効になっていません。
使用法:
drone.get_safe_mode()
パラメータ |
説明 |
|---|---|
このメソッドにはパラメータがありません。 |
# Change the sound by enabling the Propeller Lock
while True:
if drone.get_safe_mode():
controller.sound.play(FAULT)
while controller.sound.is_active():
wait(50, MSEC)
else:
controller.sound.play(SUCCESS)
while controller.sound.is_active():
wait(50, MSEC)
wait(5, MSEC)
is_climb_active#
is_climb_active ドローンが上昇中かどうかを示すブール値を返します。 Boolean
True– ドローンは現在上昇中です。False– ドローンは上昇していません。
使用法:
drone.is_climb_active()
パラメータ |
説明 |
|---|---|
このメソッドにはパラメータがありません。 |
# After the drone starts to climb, play a sound and land
drone.take_off(climb_to=500, units=MM)
drone.climb(UP, 50)
wait(3, SECONDS)
if drone.is_climb_active():
controller.sound.play(SUCCESS)
drone.land()
is_move_active#
is_move_active ドローンが現在移動方法を使用しているかどうかを示す Boolean
True– ドローンは現在移動方法を使用しています。False– ドローンは現在移動方法を使用していません。
使用法:
drone.is_move_active()
パラメータ |
説明 |
|---|---|
このメソッドにはパラメータがありません。 |
# After the drone starts to move, play a sound and land
drone.take_off(climb_to=500, units=MM)
drone.move_at(angle=0, velocity=50)
wait(2, SECONDS)
if drone.is_move_active():
controller.sound.play(SUCCESS)
drone.land()
is_turn_active#
is_turn_active ドローンが旋回しているかどうかを示すブール値を返します。 Boolean
True– ドローンは現在旋回中です。False– ドローンが旋回していません。
使用法:
drone.is_turn_active()
パラメータ |
説明 |
|---|---|
このメソッドにはパラメータがありません。 |
# After the drone starts to turn, play a sound and land
drone.take_off(climb_to=500, units=MM)
drone.turn(RIGHT)
wait(2, SECONDS)
if drone.is_turn_active():
controller.sound.play(LOOPING)
while controller.sound.is_active():
wait(50, MSEC)
drone.land()
is_hovering#
is_hovering ドローンがその位置を維持している(ホバリングしている)かどうかを示す Boolean を返します。
True– ドローンは現在その位置を維持しています(ホバリング)。False– ドローンは現在位置を変更中です。
使用法:
drone.is_hovering()
パラメータ |
説明 |
|---|---|
このメソッドにはパラメータがありません。 |
# Play a sound after the drone has finished taking off
drone.take_off(climb_to=700, units=MM)
while not drone.is_hovering():
wait(5, MSEC)
controller.sound.play(PAUSE)
wait(2, SECONDS)
drone.land()
is_taking_off#
is_taking_off は、ドローンが離陸中かどうかを示す Boolean を返します。
True– ドローンは現在離陸中です。False– ドローンは離陸処理中ではありません。
使用法:
drone.is_taking_off()
パラメータ |
説明 |
|---|---|
このメソッドにはパラメータがありません。 |
# Play sounds while the drone is taking off
drone.take_off(climb_to=700, units=MM, wait=False)
wait(1, SECONDS)
while drone.is_taking_off():
controller.sound.play(LOOPING)
wait(5, MSEC)
is_landing#
is_landing は、ドローンが着陸処理中かどうかを示すブール値 Boolean
True– ドローンは現在着陸中です。False– ドローンは着陸処理中ではありません。
使用法:
drone.is_landing()
パラメータ |
説明 |
|---|---|
このメソッドにはパラメータがありません。 |
# Play sounds while the drone is landing
drone.take_off(climb_to=500, units=MM)
wait(1, SECONDS)
drone.land(wait=False)
wait(1, SECONDS)
while drone.is_landing():
controller.sound.play(LOOPING)
wait(5, MSEC)
is_landed#
is_landed ドローンが現在着陸しているかどうかを示すブール値を返します。 Boolean
True– ドローンが着陸しました。False– ドローンは着陸していません。
使用法:
drone.is_landed()
パラメータ |
説明 |
|---|---|
このメソッドにはパラメータがありません。 |
# Celebrate a successful landing
drone.take_off(climb_to=500, units=MM)
wait(1, SECONDS)
drone.land()
wait(1, SECONDS)
if drone.is_landed():
controller.sound.play(SUCCESS)