変わりモノがいい!

変わりモノには価値がある・・・ハズ?

ZumoのLine followerアルゴリズムの出来は完璧でした。

Zumo ロボットを走らせました。

Zumoロボット(Zumo shield for arduinoarduino unoを合体したもの)を走らせました。
今回は、Line followerというアプリを動かしました。

f:id:ken2017:20211124112134p:plain
最初の思惑は、車の操舵に使っているアルゴリズムが良くなさそうだったら色々と修正を加えてみようと思っていました。
ところがところが、予想に反してアルゴリズムは完璧でした。
完璧な操舵性能でした。

どうやって動かすの?

ZumoロボットのLine followerの操作と動作の流れを下記します。
・Zumoロボットの電源ON
・ZumoロボットのZumo shield for arduino上のボタンを押す
・ZumoロボットがLine follow用センサのキャリブレーションを始める
  ロボットはその場で左、右に回転し、センサの校正をします
  構成の仕方はココに書いてあります

www.pololu.com

キャリブレーションが終わるとZumoロボットは停止する
・Zumoロボットの位置をLineに対して正しく配置する
・ZumoロボットのZumo shield for arduino上のボタンを押す
・ZumoロボットがLine follow動作を開始し走行し始める
となります。
この動かし方はネットで調べないと判りません。
取扱説明書が付いてくるわけではなく、必要な情報は自分で全てネットから入手する必要があります。
そういう時代なんですね。

どんな感じで動いた?

Zumoロボットの操舵アルゴリズムの良し悪しを判断するために公式?の走行路を使うことにしました。
それがコレ。

www.pololu.com

寸法はコレ。

f:id:ken2017:20211124115915j:plain
この寸法に従って作ったものがコレ。

f:id:ken2017:20211124115952j:plain
ここでもダイソーが大活躍です。
この白い紙は4枚で税込み110円でした。
このコースの上にZumoロボットを置くとこんな感じになります。

f:id:ken2017:20211124120122j:plain
実際に動かした動画がコレ。

youtu.be

見て頂いたら判るように、直線走行での安定性は当然のことながら、カーブやカーブを抜けた後の操舵に全く無駄がありません。
ちなみにZumoロボットは、75:1のハイパワーモータを使っており最高速度における回転数は400rpmです。
この動画におけるZumoロボットの走行速度は最高速度で設定しています。
これはなかなかのものです。
特に修正が必要には思えません。

どんなアルゴリズムで操舵しているの?

Zumoロボットの操舵にはPID制御が使われています。
PID制御は目新しいものでは無く大昔からある制御方式です。
Zumoロボットのソースコードを見てみると下のようなPID制御の式になっていました。
計算で求めたspeedDifferenceの値を使って2つのモータの回転数を制御して操舵を行っています。

// Get motor speed difference using proportional and derivative PID terms
  // (the integral term is generally not very useful for line following).
  // Here we are using a proportional constant of 1/4 and a derivative
  // constant of 6, which should work decently for many Zumo motor choices.
  // You probably want to use trial and error to tune these constants for
  // your particular Zumo and line course.
  int speedDifference = error / 4 + 6 * (error - lastError);

  lastError = error;

  // Get individual motor speeds.  The sign of speedDifference
  // determines if the robot turns left or right.
  int m1Speed = MAX_SPEED + speedDifference;
  int m2Speed = MAX_SPEED - speedDifference;

  // Here we constrain our motor speeds to be between 0 and MAX_SPEED.
  // Generally speaking, one motor will always be turning at MAX_SPEED
  // and the other will be at MAX_SPEED-|speedDifference| if that is positive,
  // else it will be stationary.  For some applications, you might want to
  // allow the motor speed to go negative so that it can spin in reverse.
  if (m1Speed < 0)
    m1Speed = 0;
  if (m2Speed < 0)
    m2Speed = 0;
  if (m1Speed > MAX_SPEED)
    m1Speed = MAX_SPEED;
  if (m2Speed > MAX_SPEED)
    m2Speed = MAX_SPEED;

要は、PID制御のパラメータとして、
Pに対する定数は、1/4
Iに対する定数は、ゼロ
Dに対する定数は、6
でした。
この定数を決めるために色々と試行錯誤したのだろうと思います。
良くできていると感心しました。
Line followerを試したので次は迷路アプリを動かしてみようと思います。
今日はココまで。
では、また。

 

プライバシーポリシー お問い合わせ