慣性#
導入#
VEX 123ロボットには慣性センサーが内蔵されています。このセンサーはロボットの動きを測定できます。
慣性センサーは、加速度計を使用して、加速、減速、衝突時の急停止など、動きの変化を測定します。
以下は、すべての慣性計測方法の一覧です。
ゲッター — ロボットの動き方を返します。
is_crashed— ロボットが衝突を検出したかどうかを返します。get_acceleration— 選択した軸上でロボットがどれだけ速く加速または減速しているかを返します。
ゲッター#
is_crashed#
is_crashed 、ロボットが衝突(急停止または衝撃)を検出したかどうかを報告する Boolean を返します。
True— ロボットが衝突を検知しました。False— ロボットは衝突を検知していません。
Usage:
robot.is_crashed()
パラメータ |
説明 |
|---|---|
このメソッドにはパラメータがありません。 |
# Back up after a crash.
robot.drive(FORWARD)
while not robot.is_crashed():
wait(0.05, SECONDS)
robot.drive_for(REVERSE, 200, MM)
get_acceleration#
加速度とは、ロボットが加速または減速する速さのことです。get_acceleration get_acceleration は、選択した軸におけるロボットの加速度を -4.0 G から 4.0 G の範囲で返します。
G は加速度を測定するために使用される単位です。1Gは、静止しているときに重力によって感じる加速度に相当します。
The value can be positive or negative depending on the direction of acceleration on the selected axis. The axis options are X, Y, and Z.
Usage:
robot.inertial.get_acceleration(axis)
パラメータ |
説明 |
|---|---|
|
加速度を測定する軸: |
# Display the acceleration on the X axis
while True:
console.clear()
console.print(robot.inertial.get_acceleration(X), precision=2)
wait(0.1, SECONDS)