iRobot Roomba 530を動かす

iRobot Roomba 530の天板をはがすと出てくるシリアルポートにmbedを直結してコントロールするサンプルです。

http://www.youtube.com/watch?v=-3NZ8-50vnc

参考URL

接続

mbedRoomba
P9 - TX3: RXD (0 – 5V Serial input to Roomba)
P10 - RX4: RXD (0 – 5V Serial input to Roomba)
GND6: GND (Roomba battery ground)

参考画像:http://www.flickr.com/photos/ooba/4409522669/

mbedは3.3v、Roombaは5vでシリアル通信していると思うのですが、直結でもとりあえず動きました。

また、参考URLの仕様書のように、iRobot Createや古いRoombaと違ってRoomba 500シリーズはデフォルトのボーレートが115200になっています。 Clean/Powerボタンを10秒以上押し続けると、ボーレートを19200に変更することもできます。 mbedではデフォルトの115200のままでちゃんと通信できました。

サンプルコード

#include "mbed.h"

Serial device(p9, p10);  // tx, rx

int main() {
    device.baud(115200);    // the default baud rate of Roomba 530
    //device.baud(19200);

    // Start
    device.putc(128);   // Start -> Passive Mode
    wait(.05);
    device.putc(130);   // Safe Mode
    wait(.05);
    
    wait(1);

    // Forward
    device.putc(137);   // Drive
    device.putc(0x00);  // Velocity: 0x00c8 = 200
    device.putc(0xc8);
    device.putc(0x80);  // Radius: 0x8000 = Straight
    device.putc(0x00);

    wait(1);

    // Stop
    device.putc(137);   // Drive
    device.putc(0x00);
    device.putc(0x00);
    device.putc(0x00);
    device.putc(0x00);

    wait(.5);

    // Backward
    device.putc(137);   // Drive
    device.putc(0xff);  // Velocity: 0xff38 = -200
    device.putc(0x38);
    device.putc(0x80);  // Radius: 0x8000 = Straight
    device.putc(0x00);

    wait(1);

    // Stop
    device.putc(137);   // Drive
    device.putc(0x00);
    device.putc(0x00);
    device.putc(0x00);
    device.putc(0x00);

    wait(.5);

    // Turn in place counter-clockwise
    device.putc(137);   // Drive
    device.putc(0x00);  // Velocity: 0x00c8 = 200
    device.putc(0xc8);
    device.putc(0x00);  // Radius: 0x0001 = Turn in place counter-clockwise
    device.putc(0x01);

    wait(.5);

    // Turn in place clockwise
    device.putc(137);   // Drive
    device.putc(0x00);  // Velocity: 0x00c8 = 200
    device.putc(0xc8);
    device.putc(0xff);  // Radius: 0x0001 = Turn in place clockwise
    device.putc(0xff);

    wait(1);

    // Turn in place counter-clockwise
    device.putc(137);   // Drive
    device.putc(0x00);  // Velocity: 0x00c8 = 200
    device.putc(0xc8);
    device.putc(0x00);  // Radius: 0x0001 = Turn in place counter-clockwise
    device.putc(0x01);

    wait(.5);

    // Passive Mode
    device.putc(128);   // Start -> Passive Mode
}

オマケ:Roomba 530で利用可能なコンポーネント

  • モータ
    • ドライブモータ右
    • ドライブモータ左
    • メインブラシ(正転、逆転)
    • サイドブラシ(正転、逆転)
    • バキューム
  • LED
    • Home(緑)
    • Spot(緑)
    • Check Robot(オレンジ)
    • Debris(青)
    • Clean/Power(緑0から赤255まで256段階、明度256段階)
  • ボタン(遠隔操作用)
    • Dock
    • Spot
    • Clean
  • センサー
    • 脱輪センサー左
    • 脱輪センサー右
    • バンパー左
    • バンパー右
    • 壁センサー
    • 崖センサー左
    • 崖センサー左前
    • 崖センサー右前
    • 崖センサー右
    • ヴァーチャルウォールセンサー
    • and more


Please log in to post comments.