Kiso sekkei 01rev03
- 10. Arbotix Getting Started
• (step1) Arduino IDEのインストール
• (step2) FTDI driver のインストール
• (step3) Arbotix-M library and hardware filefile を
適切な場所に置く
• (step4) FTDI 接続
• (step5) ボードとシリアルポートの指定
• (step6) ボードとサーボモータを接続
10
- 21. (step3) ArbotiX library and hardware file
21
Arbotixライブラリファイルとハードウェアファイル
の置き場所
この 1.6 にはこのフォルダーは含まれていない.
(必要に応じて古いリンクから持ってきましょう.)
- 26. • Arbotix-Mボード上のLEDを光らせる.
26
void setup() {
// initialize the digital pin as an output.
pinMode(0, OUTPUT); // Pin 0 maps to the USER LED on the ArbotiX Robocontroller.
}
void loop() {
digitalWrite(0, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(0, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}
- 27. • サーボモータを1個動かす.
27
#include <ax12.h>
int t;
int id;
void setup() {
dxlInit(1000000);
id = 1;
Serial.begin(9600);
}
void loop() {
t = dxlGetTemperature(id);
Serial.print(" Temp = ");
Serial.println(t, DEC);
if(t < 60){
SetPosition(id, 400);
delay(1000);
SetPosition(id, 600);
}
delay(1000);
}
- 28. • サーボモータのLEDを光らせる.
28
#include <ax12.h> //include the ArbotiX DYNAMIXEL library
const int SERVO_ID = 1; // Identifier of the servo
const int BLINK_TIME = 1000; //time foe each LED to be on
void setup()
{
dxlInit(1000000); //start dynamixel library at 1mbps to communicate with the servos
}
void loop()
{
dxlLEDOn(SERVO_ID);
delay(BLINK_TIME);
dxlLEDOff(SERVO_ID);
delay(BLINK_TIME);
}
- 29. • サーボモータのIDを変える.
29
#include <ax12.h>
int id_old, id_new;
void setup(){
dxlInit(1000000); //start dynamixel library at 1mbps to communicate with the servos
id_old = 1;
id_new = 2;
ax12SetRegister(id_old, AX_ID, id_new); // IDの書き換え
}
void loop(){
}
この sketch を実行するときには,ボードには1個だけの
サーボモータが接続されている状況にしておくこと.
ID番号は0から253まで使用可能.254はブロードキャストのIDとして特別に使用される.
書き換えがうまくいったことの確認のために,
ここに,新IDのモータを動かすか
新IDのモータのLEDを点滅させる
コードなどを書くといいかもしれない.
このスケッチを実行後に別の作業を行う場合は,
トラブル回避のため
スケッチ「Arbotix-Mボード上のLEDを光らせる.」
をボードに書き込んでおくこと.
- 30. • サーボモータを2個同時に動かす.
30
#include <ax12.h>
int id_A;
int id_B;
int pos_h = 350;
int dp;
void setup() {
dxlInit(1000000);
id_A = 1;
id_B = 2;
dp = 250;
}
void loop() {
SetPosition(id_A, pos_h);
SetPosition(id_B, pos_h);
delay(500);
SetPosition(id_B, pos_h - dp);
delay(500);
SetPosition(id_A, pos_h + dp);
SetPosition(id_B, pos_h + dp);
delay(1000);
}
2個のサーボはそれぞれ,
ID=1,ID=2 とセットしておく.
一般的注意:コントローラに接続されているサーボモータのIDは相異なっている必要があります.
同一のIDのサーボがあってはいけません.
- 31. • 2個のサーボモータで「動きコピー」デモ.
31
//////////////////////
//// motion copy
//// サーボ id_w の位置をサーボ id_r の位置と同じにする.
//////////////////////
#include <ax12.h>
int id_r;
int id_w;
int pos;
void setup() {
dxlInit(1000000);
id_r = 1;
id_w = 2;
dxlSetRunningTorqueLimit(id_r, 0); //フリーラン状態にする
}
void loop() {
pos = GetPosition(id_r);
SetPosition(id_w, pos);
delay(10);
}
ID = 1ID = 2
モータの最大トルクは0から1023まで使用可能.
電源投入時に512(最大出力の50%)にセットされる.
- 32. サーボモータに関する命令
• Document -> Arduino -> libraries -> ArbotiX -> ax12.h
• 上記テキストファイル ax12.h を見れば,
どのような命令が用意されているかがわかります.
32
スマートサーボモータAX12のマニュアル(日本語)は下記サイトにあります.
http://support.robotis.com/jp/product/dynamixel/ax_series/dxl_ax_actuator.htm
- 38. まとめ
• コントローラ(Arbotix-M)を Arduino IDE で用いるためのセット
アップ方法を学んだ.
• スマートサーボ(AX-12)を動かすためにArduino IDE でコント
ローラをプログラミングする方法を学んだ.
• スマートサーボの基本的取り扱い方を学んだ.
• 実際にスマートサーボを動かしてみた.
• LiPo(リチウムポリマー)バッテリーの取り扱い方を学んだ.
38