etrobocon2018 feat.KatLab  770af34cce41ae9c30c41303275e1add2daae0c3 (with uncommitted changes)
 全て クラス 名前空間 ファイル 関数 変数 列挙型 列挙値 フレンド マクロ定義 ページ
公開メンバ関数 | 静的公開変数類 | 限定公開メンバ関数 | フレンド | 全メンバ一覧
ev3api::Motor クラス

#include <Motor.h>

ev3api::Motor 連携図
Collaboration graph

公開メンバ関数

 Motor (ePortM port, bool brake=true, motor_type_t type=LARGE_MOTOR)
 
 ~Motor (void)
 
void reset (void)
 
int32_t getCount (void) const
 
void setCount (int32_t count)
 
void setPWM (int pwm)
 
void setBrake (bool brake)
 
void stop ()
 

静的公開変数類

static const int PWM_MAX = 100
 
static const int PWM_MIN = -100
 

限定公開メンバ関数

motor_port_t getPort (void) const
 
bool getBrake (void) const
 
int getPWM (void) const
 

フレンド

class Steering
 

詳解

EV3 モータクラス

Motor.h17 行目に定義があります。

構築子と解体子

Motor::Motor ( ePortM  port,
bool  brake = true,
motor_type_t  type = LARGE_MOTOR 
)
explicit

コンストラクタ

引数
portモータポート番号
braketrue:ブレーキモード/false:フロートモード
typeモータタイプ
戻り値
-

Motor.cpp12 行目に定義があります。

13 :mPort(static_cast<motor_port_t>(port)),
14  mBrake(brake),
15  mType(type),
16  mPWM(0),
17  mOffset(0)
18 {
19  ev3_motor_config(getPort(), type);
20 }
motor_port_t getPort(void) const
Definition: Motor.h:105

呼び出し関係図:

Motor::~Motor ( void  )

デストラクタ
モータを停止する

引数
-
戻り値
-

Motor.cpp24 行目に定義があります。

25 {
26  ev3_motor_stop(mPort, true); // set brake to stop the motor immidiately
27 }

関数詳解

bool ev3api::Motor::getBrake ( void  ) const
inlineprotected

ブレーキ設定取得

引数
-
戻り値
trueブレーキモード
falseフロートモード

Motor.h113 行目に定義があります。

113 { return mBrake; }
int32_t ev3api::Motor::getCount ( void  ) const
inline

オフセット付き角位置取得

引数
-
戻り値
モータ角位置 [deg]

Motor.h67 行目に定義があります。

67 { return ev3_motor_get_counts(mPort) - mOffset; }

被呼び出し関係図:

motor_port_t ev3api::Motor::getPort ( void  ) const
inlineprotected

モータ接続ポート取得

引数
-
戻り値
モータ接続ポート

Motor.h105 行目に定義があります。

105 { return mPort; }

被呼び出し関係図:

int ev3api::Motor::getPWM ( void  ) const
inlineprotected

PWM設定値取得

引数
-
戻り値
PWM設定値

Motor.h120 行目に定義があります。

120 { return mPWM; }
void ev3api::Motor::reset ( void  )
inline

モータリセット
モータ停止および角位置の0リセット、オフセット初期化を行う

引数
-
戻り値
-

Motor.h55 行目に定義があります。

56  {
57  ev3_motor_stop(mPort, true); // need to set brake to stop the motor immidiately
58  ev3_motor_reset_counts(mPort);
59  mOffset = 0;
60  }

被呼び出し関係図:

void Motor::setBrake ( bool  brake)

ブレーキモード設定

引数
braketrue:ブレーキモード/false:フロートモード
戻り値
-

Motor.cpp47 行目に定義があります。

48 {
49  mBrake = brake;
50  setPWM(mPWM);
51 }
void setPWM(int pwm)
Definition: Motor.cpp:31

呼び出し関係図:

被呼び出し関係図:

void ev3api::Motor::setCount ( int32_t  count)
inline

角位置設定
現在のモータ角位置と設定角位置との差分をオフセットとして設定する

引数
countモータ角位置 [deg]
戻り値
-

Motor.h75 行目に定義があります。

75 { mOffset = ev3_motor_get_counts(mPort) - count; }
void Motor::setPWM ( int  pwm)

モータPWM値設定
ブレーキモードでPWM値が0の場合、モータを停止する

引数
pwmPWM値 (-100 - 100)
戻り値
-

Motor.cpp31 行目に定義があります。

32 {
33  mPWM = (pwm>PWM_MAX)? PWM_MAX:((pwm<PWM_MIN)? PWM_MIN:pwm);
34 
35  if (mBrake == true && pwm == 0)
36  {
37  ev3_motor_stop(mPort, true);
38  }
39  else
40  {
41  ev3_motor_set_power(mPort, mPWM);
42  }
43 }
static const int PWM_MIN
Definition: Motor.h:30
static const int PWM_MAX
Definition: Motor.h:25

被呼び出し関係図:

void ev3api::Motor::stop ( )
inline

停止する。

引数
-
戻り値
-

Motor.h97 行目に定義があります。

97 { (void)ev3_motor_stop(mPort, mBrake); }

被呼び出し関係図:

フレンドと関連関数の詳解

friend class Steering
friend

Motor.h20 行目に定義があります。

メンバ詳解

const int ev3api::Motor::PWM_MAX = 100
static

PWM最大値

Motor.h25 行目に定義があります。

const int ev3api::Motor::PWM_MIN = -100
static

PWM最小値

Motor.h30 行目に定義があります。


このクラス詳解は次のファイルから抽出されました: