Download
latest Releases : 2.0.0-RELESE
| 2.0.0-RELESE | Download page |
Number of Projects
| RT-Component | 154.5 |
| RT-Middleware | 35 |
| Tools | 23 |
| Documentation | 2 |
Choreonoid
Motion editor/Dynamics simulator
OpenHRP3
Dynamics simulator
OpenRTP
Integrated Development Platform
AIST RTC collection
RT-Components collection by AIST
TORK
Tokyo Opensource Robotics Association
DAQ-Middleware
Middleware for DAQ (Data Aquisition) by KEK
モーター
速度制御
速度を制御するためには以下のデバイスファイルに"on"と書き込む必要があります。
起動時には off になっているので速度制御はできません。 off の場合は duty_cycle_sp でデューティー比を設定できます。
そして以下のファイルに目標速度を書き込みます。
ここで指定する値は1秒間に何カウント動かすかという値なので、以下のデバイスファイルから取得する値を角速度に掛けて変換してください。 ※モーターM、モーターLの場合は count_per_rot で取得できる値が360なので変換しなくても影響はありません。
後は以下のコマンドを入力すると回転を開始します。
現在の角速度を取得するためには以下のデバイスファイルを使用します。
以上の手順を ev3dev-lang-cpp を利用して記述すると以下のようになります。
ev3dev::large_motor lm = ev3dev::large_motor(); lm.set_speed_regulation_enabled("on"); lm.set_speed_sp(50*lm.count_per_rot()); lm.run_forever(); std::cout << lm.speed()/lm.count_per_rot() << std::endl;ev3dev-lang-python を利用して記述すると以下のようになります。
lm = ev3.LargeMotor() lm.set_attr_string("speed_regulation", "on") lm.speed_sp = 50*lm.count_per_rot lm.run_forever() print lm.speed/lm.count_per_rot一定時間動作させる
モーターを一定時間動作させるには、まず以下のデバイスファイルで時間を設定してください。
そして以下のコマンドで動作を開始します。
位置制御
位置制御を行うためにはまず duty_cycle_sp (speed_regulation が on の場合は speed_sp) を設定しておく必要があります。
次に以下のデバイスファイルで位置を設定します。
この位置もカウント数で指定するため、count_per_rot で変換してください。
以下のコマンドで動作を開始します。
現在の位置からの相対的な角度を指定したい場合は以下のコマンドを利用します。
現在の位置は以下のデバイスファイルから取得できます。
以上の手順を ev3dev-lang-cpp を利用して記述すると以下のようになります。
ev3dev::large_motor lm = ev3dev::large_motor(); lm.set_speed_regulation_enabled("on"); lm.set_speed_sp(50*lm.count_per_rot()); lm.set_position_sp(100*lm.count_per_rot()); lm.run_to_abs_pos(100*lm.count_per_rot()); #lm.run_to_rel_pos(100*lm.count_per_rot());ev3dev-lang-python を利用して記述すると以下のようになります。
センサーの C++、Python による操作
カラーセンサーで反射光の強さ取得
タッチセンサーのオンオフ取得
ジャイロセンサーで角度取得
LCD の操作
ev3dev::lcd lcd = ev3dev::lcd(); unsigned char *fb = lcd.frame_buffer(); for(int i=0;i < 3072;i++) { if(i%24 < 12)fb[i] = 0x00; else fb[i] = 0xff; }lcd = ev3.Screen() lcd.mmap.seek(os.SEEK_SET) lcd.mmap.write(chr(0xff)*3072) for i in range(lcd.fix_info.smem_len): if i%24 < 12: lcd.mmap.seek(os.SEEK_SET) lcd.mmap.seek(i) lcd.mmap.write_byte(chr(0xff))