センサー#

導入#

VEX AIRドローンには、回転運動を測定し、動きの変化を検出する慣性センサーと、距離を検出するレンジセンサーが搭載されています。また、バッテリー残量も監視できます。これらのセンサーにより、ドローンは機体の向き、進行方向、加速度、および物体からの距離を追跡できます。

以下に、利用可能なメソッドの一覧を示します。

慣性センサー - ドローンの回転運動を追跡します。

  • get_rotation – ドローンが開始してからどれだけ回転したかを返します。

  • get_heading – 現在の方位角 (0 ~ 359.99°) を返します。

  • get_yaw – ヨー角(-180~180°)を返します。

  • get_roll – ロール角度 (-180~180°) を返します。

  • get_pitch – ピッチ角 (-180~180°) を返します。

  • reset_rotation – 回転値を 0 にリセットします。

  • reset_heading – 現在の見出しを0に設定します。

  • set_heading – 見出しを特定の値に設定します。

  • get_acceleration – 特定の方向の加速度を返します。

  • get_turn_rate – 1秒あたりの回転速度を度単位で返します。

範囲 — ドローンの距離センサーから距離を検出します。

  • get_distance — 選択したレンジセンサーと最も近い検出オブジェクト間の距離を返します。

バッテリー - ドローンのバッテリー残量を表示します。

  • get_battery_level – ドローンのバッテリーレベルをパーセントで返します。

慣性#

get_rotation#

get_rotation は、ドローンが起動してから回転した角度を返します。すべての回転数を合計し、合計値を度数で返します。正の値は時計回り、負の値は反時計回りです。

Usage:
drone.inertial.get_rotation()

パラメータ

説明

このメソッドにはパラメータがありません。

# Display the rotation after turning
drone.take_off(climb_to=500)
drone.turn_for(LEFT, 450, 50)
print(drone.inertial.get_rotation(), end="")
drone.land()

get_heading#

get_heading は、ドローンの進行方向の角度を 0 ~ 359.99 度の範囲の浮動小数点数として返します。

Usage:
drone.inertial.get_heading()

パラメータ

説明

このメソッドにはパラメータがありません。

# Display the drone's heading after turning
drone.take_off(climb_to=500)
drone.set_turn_velocity(100)
drone.turn(RIGHT)
wait(5, SECONDS)
controller.screen.print("Heading: ")
controller.screen.print(drone.inertial.get_heading())
drone.land()

get_yaw#

get_yaw は、ドローンのヨー角を -180.0 度から 180.0 度の範囲で float 型として返します。

下の図は、矢印を使ってヨー角の正の回転方向を示しています。

機首が右下隅を向いているVEX AIRドローン。中央から下向きに青い矢印が伸びています。青い矢印の周りには、時計回りに湾曲した黒い矢印があり、「Yaw」と表示されています。これはヨーの正の方向を示しています。

Usage:
drone.inertial.get_yaw

パラメータ

説明

このメソッドにはパラメータがありません。

# Display the yaw angle as you rotate the drone by hand
while True:
    controller.screen.clear_screen()
    controller.screen.set_cursor(1, 1)
    controller.screen.print("Yaw: ")
    controller.screen.print(drone.inertial.get_yaw())
    wait(0.2, SECONDS)

get_roll#

get_roll は、ドローンのロール角度を -180.0 度から 180.0 度の範囲で float 型として返します。

下の図では、矢印を使ってロールの正の回転方向を示しています。

機首が右下隅を向いているVEX AIRドローン。機首から緑色の矢印がまっすぐ伸びています。緑色の矢印の周りには、反時計回りに曲がった黒い矢印があり、正のロール方向を示しています。

Usage:
drone.inertial.get_roll()

パラメータ

説明

このメソッドにはパラメータがありません。

# Display the roll angle as you rotate the drone by hand
while True:
    controller.screen.clear_screen()
    controller.screen.set_cursor(1, 1)
    controller.screen.print("Roll: ")
    controller.screen.print(drone.inertial.get_roll())
    wait(0.2, SECONDS)

get_pitch#

get_pitch は、ドローンのピッチ角を -180.0 度から 180.0 度の範囲で float 型として返します。

下の図では、矢印を使ってピッチの正の回転方向を示しています。

右下隅を向いたVEX AIRドローン。ドローンの右側から赤い矢印が伸びており、VEXロゴの横にある。赤い矢印の周りには、反時計回りに曲がった黒い矢印があり、ピッチの正の方向を示している。

Usage:
drone.inertial.get_pitch()

パラメータ

説明

このメソッドにはパラメータがありません。

# Display the pitch angle as you rotate the drone by hand
while True:
    controller.screen.clear_screen()
    controller.screen.set_cursor(1, 1)
    controller.screen.print("Pitch: ")
    controller.screen.print(drone.inertial.get_pitch())
    wait(0.2, SECONDS)

reset_rotation#

reset_rotation は、ドローンの回転値を 0 度にリセットします。

Usage:
drone.inertial.reset_rotation()

パラメータ

説明

このメソッドにはパラメータがありません。

# Display the new rotation after resetting
drone.take_off(climb_to=500)
drone.turn(RIGHT)
while not drone.inertial.get_rotation() > 360:
    wait(5, MSEC)
drone.hover()
drone.inertial.reset_rotation()
wait(1, SECONDS)
print(drone.inertial.get_rotation(), end="")
drone.land()

reset_heading#

reset_heading はドローンの進行方向を0度にリセットします。

使用法:

drone.inertial.reset_heading()

パラメータ

説明

このメソッドにはパラメータがありません。

# Turn to a heading, reset the heading, and turn to the same heading.
drone.take_off(climb_to=500)
drone.turn_to(heading=180, velocity=50)
wait(3,SECONDS)
drone.inertial.reset_heading()
drone.turn_to(heading=180, velocity=50)
wait(3,SECONDS)
drone.land()

set_heading#

set_heading は、ドローンの進行方向を指定された度数に設定します。

使用法:

drone.inertial.set_heading(heading)

パラメータ

説明

heading

新しい方位角に使用する値(0~359.99度の範囲)。

# Turn to a heading, set the heading, and turn to the same heading.
drone.take_off(climb_to=500)
drone.turn_to(heading=180, velocity=50)
wait(3,SECONDS)
drone.inertial.set_heading(90)
drone.turn_to(heading=180, velocity=50)
wait(3,SECONDS)
drone.land()

get_acceleration#

get_acceleration は、指定された方向におけるドローンの加速度を返します。返される値は、速度の変化率を表し、単位は g (1g ≈ 9.81 m/s²) で、-4.00 から 4.00 の範囲の浮動小数点数です。

下の図は、矢印を用いて、前方および右方向への加速度が正の方向であり、下方への加速度が負の方向であることを示しています。

VEX AIRドローンが表示されています。ドローンの先端から伸びる緑色の矢印には「前方」とラベルが付けられ、ドローンの底部中央から伸びる青色の矢印には「下方」とラベルが付けられ、ドローンの右側、VEXロゴの横から伸びる赤色の矢印には「右方」とラベルが付けられています。

使用法:

drone.inertial.get_acceleration(type)

パラメータ

説明

type

報告する加速度の方向:

  • DOWNWARD
  • FORWARD
  • RIGHTWARD

# Display the acceleration as the drone takes off
drone.take_off(500, wait=False)
while True:
    controller.screen.clear_screen()
    controller.screen.set_cursor(1, 1)
    controller.screen.print(drone.inertial.get_acceleration(DOWNWARD))
    wait(5, MSEC)

get_turn_rate#

get_turn_rate get_turn_rate は、ドローンが指定された軸に沿って回転する速度を返します。これは、-1000.00 から 1000.00 dps の範囲の浮動小数点数として、度/秒 \(dps\) の値が返されます。

下の図は、矢印を用いてロール、ピッチ、ヨーの正の回転方向を示しています。

VEX AIRドローンに方向矢印が表示されています。ドローンの先端から緑色の矢印が伸びており、その周りを反時計回りに黒い曲線矢印が囲んでおり、「ロール」とラベルが付けられています。ドローンの底部中央から青色の矢印が伸びており、その周りを時計回りに黒い曲線矢印が囲んでおり、「ヨー」とラベルが付けられています。また、VEXロゴの横にあるドローンの右側から赤色の矢印が伸びており、その周りを反時計回りに黒い曲線矢印が囲んでおり、「ピッチ」とラベルが付けられています。

Usage:
drone.inertial.get_turn_rate(axis)

パラメータ

説明

axis

報告する向き:

  • YAW
  • ROLL
  • PITCH

# Display the drone turn rate as it is rotated by hand.
while True:
    controller.screen.clear_screen()
    controller.screen.set_cursor(7, 1)
    controller.screen.print(drone.inertial.get_turn_rate(ROLL))

範囲#

get_distance#

get_distance は、選択されたレンジセンサーと最も近い検出されたオブジェクト間の距離を返します。

Usage:
drone.range.get_distance(range, units)

パラメータ

説明

range

The Range Sensor to use: FORWARD_RANGE or DOWNWARD_RANGE. FORWARD_RANGE reports distance from the front of the drone. DOWNWARD_RANGE reports distance from the bottom of the drone.

units

オプション。距離の単位:

  • MM (デフォルト)—ミリメートル
  • CM —センチメートル
  • INCHES

# Fly forward until close to an object
drone.take_off(climb_to=500)
drone.move_at(direction=0, velocity=50)
while not drone.range.get_distance(FORWARD_RANGE, MM) < 750:
    wait(0.1, SECONDS)
drone.land()

バッテリー#

get_battery_level#

get_battery_level は、ドローンのバッテリー充電レベルをパーセンテージで返します。これは0から100までの数値を返します。

Usage:
drone.get_battery_level()

パラメータ

説明

このメソッドにはパラメータがありません。

# Display the drone's battery level
if drone.get_battery_level() < 25:
    controller.screen.print("Charge the drone Battery!")
else:
    controller.screen.print("Ready to fly!")