Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Roomba.cpp
00001 #include <mbed.h> 00002 #include "Roomba.h" 00003 00004 /** 00005 * @bref コンストラクタ 00006 * @param tx 00007 * @param rx 00008 */ 00009 Roomba::Roomba(PinName tx, PinName rx): 00010 _s(tx, rx) { 00011 _mode = Roomba::Mode::Off; 00012 } 00013 00014 00015 /** 00016 * @bref start 00017 * @return true 00018 */ 00019 bool Roomba::start() { 00020 00021 _s.putc(128); 00022 00023 return true; 00024 } 00025 00026 00027 /** 00028 * @bref 操作モード変更メソッド 00029 * @param 操作モード 00030 * @return true 00031 */ 00032 bool Roomba::mode(Roomba::Mode::EMode m) { 00033 00034 _s.putc(132);//Full; 00035 00036 return true; 00037 } 00038 00039 00040 /** 00041 * @bref 00042 * @param true 00043 */ 00044 bool Roomba::drive (int rightWheelVelocity, int leftWheelVelocity) { 00045 00046 bool ret = false; 00047 00048 char command[10]; 00049 00050 if ((-500 <= rightWheelVelocity && rightWheelVelocity <= 500) 00051 && (-500 <= leftWheelVelocity && leftWheelVelocity <= 500)) { 00052 00053 command[0] = 145; 00054 command[1] = (rightWheelVelocity & 0xFF00) >> 8; //MSB 00055 command[2] = rightWheelVelocity & 0xFF; //LSB 00056 command[3] = (leftWheelVelocity & 0xFF00) >> 8; //MSB 00057 command[4] = leftWheelVelocity & 0xFF; //LSB 00058 command[5] = '\0'; 00059 00060 for (int i = 0; i < 5; i++) { 00061 _s.putc(command[i]); 00062 } 00063 ret = true; 00064 } 00065 return ret; 00066 } 00067 00068 /** 00069 * @bref バッテリ状態 00070 * 実装未完了 00071 * @param true 00072 * @return 00073 * @retval 00074 */ 00075 bool Roomba::battery(int* batteryCapacity) { 00076 bool ret = false; 00077 00078 *batteryCapacity = 100; 00079 00080 return ret; 00081 }
Generated on Sat Jul 16 2022 09:17:49 by
