ビクター883モーター#
導入#
motor_victor クラスは、3線式ポートに接続された Victor 883 モーターコントローラーを制御するために使用されます。Victor 883 モーターコントローラーは、EXP Brain から PWM 信号を送信し、スマートポートに直接接続できない互換性のある VEXpro または VEX EDR DC モーターを制御します。
Victor 883モーターコントローラーはVEXcodeでは設定できないため、使用するにはコードで手動で構築する必要があります。
クラスコンストラクタ#
1 — 指定された 3 線ポートに接続された Victor 883 モーター コントローラー用の
motor_victorオブジェクトを作成します。motor_victor( triport::port& port );
2 — 指定された 3 線ポート上に
motor_victorオブジェクトを作成し、必要に応じてその方向を反転します。motor_victor( triport::port& port, bool reverse );
クラスデストラクタ#
motor_victor オブジェクトを破棄し、関連するリソースを解放します。
~motor_victor();
パラメータ#
パラメータ |
タイプ |
説明 |
|---|---|---|
|
|
Victor 883 モーターが接続されている 3 線ポートは、 |
|
|
モーターの回転方向を反転するかどうかを設定します。
|
例#
// Create the motor_victor instance on 3-Wire Port A
motor_victor victor = motor_victor(Brain.ThreeWirePort.A);
// Create the motor_victor instance with reversed direction
motor_victor victor2 = motor_victor(Brain.ThreeWirePort.B, true);
メンバーの機能#
motor_victor クラスには、以下のメンバ関数が含まれています。
spin— モーターを指定された方向に回転させます。stop— モーターを停止します。setVelocity— モーターに回転速度を指示します。setReversed— モーターの方向を反転するかどうかを設定します。
motor_victor メンバ関数を呼び出す前に、以下に示すように motor_victor インスタンスを作成する必要があります。
/* This constructor is required to use a
Victor 883 Motor. Replace the values
as needed. */
// Create the motor_victor instance on 3-Wire Port A
motor_victor victor = motor_victor(Brain.ThreeWirePort.A);
spin#
モーターを指定された方向に永久に回転させます。
Available Functions1 — 現在設定されているモーター速度を使用してモーターを回転させます。
void spin( directionType dir );
Parameters2 — モーターを指定された速度で回転させます。
void spin( directionType dir, double velocity, velocityUnits units );
パラメータ |
タイプ |
説明 |
|---|---|---|
|
|
モーターが回転する方向: |
|
|
|
|
|
速度の単位:
|
この関数は値を返しません。
Notesモーターは、
stopが呼び出されるか、別の動作関数が実行されるまで回転し続けます。
// Spin forward, then stop
victor.spin(forward);
wait(1, seconds);
victor.stop();
// Spin forward at 100 rpm
victor.spin(forward, 100, rpm);
wait(1, seconds);
victor.stop();
stop#
モーターの回転を停止します。
Available Functionsvoid stop();
この関数は引数を受け付けません。
Return Valuesこの関数は値を返しません。
Notesstopを呼び出すと、モーターの現在の動作が即座に停止します。
// Spin and then stop
victor.spin(forward);
wait(1, seconds);
victor.stop();
setVelocity#
モーターの回転速度を指定します。パーセンテージが高いほどモーターの回転速度が速くなり、低いほど回転速度が遅くなります。
すべてのプロジェクトは、接続されている各モーターがデフォルトで50%の速度で回転する状態から始まります。
Available Functionsvoid setVelocity(
double velocity,
percentUnits units );
パラメータ |
タイプ |
説明 |
|---|---|---|
|
|
|
|
|
速度の単位: |
この関数は値を返しません。
Notes速度を明示的に指定しない後続の Victor 883 モーターの動作関数 (
spinなど) は、この値を使用します。
// Set velocity to 50%, then spin
victor.setVelocity(50, percent);
victor.spin(forward);
setReversed#
モーターの回転方向を反転させるかどうかを設定します。
Available Functionsvoid setReversed( bool value );
パラメータ |
タイプ |
説明 |
|---|---|---|
|
|
モーターの回転方向を反転するかどうか:
|
この関数は値を返しません。
Notesこれは、コンストラクタの
reverseパラメータを変更することと同じです。
// Reverse the motor direction
victor.setReversed(true);
victor.spin(forward); // Will actually spin in reverse