| 1 |
#ifndef RUN_CTRL_H |
| 2 |
#define RUN_CTRL_H |
| 3 |
|
| 4 |
/*! |
| 5 |
\file |
| 6 |
\brief 走行制御ライブラリ |
| 7 |
|
| 8 |
\author Satofumi KAMIMURA |
| 9 |
|
| 10 |
\todo 車輪が逆回転できるかの設定を導入する |
| 11 |
\todo 旋回半径の設定関数を導入する |
| 12 |
|
| 13 |
\todo 自己位置の取得方法を、どうするか考える |
| 14 |
\todo 返される自己位置を 3D で返させる |
| 15 |
|
| 16 |
$Id$ |
| 17 |
*/ |
| 18 |
|
| 19 |
#include "RunCtrlInterface.h" |
| 20 |
#include "FollowLineInterface.h" |
| 21 |
#include "GetPositionInterface.h" |
| 22 |
#include "DirectWheelCtrlInterface.h" |
| 23 |
#include <memory> |
| 24 |
#include <cstddef> |
| 25 |
|
| 26 |
|
| 27 |
namespace beego { |
| 28 |
/*! |
| 29 |
\brief 走行制御クラス |
| 30 |
*/ |
| 31 |
class RunCtrl : public RunCtrlInterface, |
| 32 |
public FollowLineInterface, |
| 33 |
public GetPositionInterface, |
| 34 |
public DirectWheelCtrlInterface { |
| 35 |
RunCtrl(const RunCtrl& rhs); |
| 36 |
RunCtrl& operator = (const RunCtrl& rhs); |
| 37 |
|
| 38 |
struct pImpl; |
| 39 |
const std::auto_ptr<pImpl> pimpl; |
| 40 |
|
| 41 |
public: |
| 42 |
enum { |
| 43 |
DefaultBaudrate = 115200, |
| 44 |
LeftWheel = 0, |
| 45 |
RightWheel, |
| 46 |
}; |
| 47 |
RunCtrl(void); |
| 48 |
~RunCtrl(void); |
| 49 |
const char* what(void); |
| 50 |
|
| 51 |
// システムコマンド |
| 52 |
bool connect(int argc, char *argv[]); |
| 53 |
bool connect(const char* device, long baudrate = DefaultBaudrate); |
| 54 |
bool connect(ConnectionInterface* con); |
| 55 |
void disconnect(void); |
| 56 |
bool isConnected(void); |
| 57 |
ConnectionInterface*& getConnection(void); |
| 58 |
|
| 59 |
void set_sendRetryTimes(size_t times); |
| 60 |
void set_recvTimeout(size_t msec); |
| 61 |
void set_watchDogTimer(size_t msec); |
| 62 |
|
| 63 |
// !!! 旋回半径を定義するコマンド |
| 64 |
|
| 65 |
void push_runState(void); |
| 66 |
void pop_runState(void); |
| 67 |
|
| 68 |
// 移動コマンド |
| 69 |
void stop(void); |
| 70 |
void set_servoFree(void); |
| 71 |
|
| 72 |
// !!! Position でなく、Line 型を定義して利用可能にする |
| 73 |
void follow_line(const CoordinateCtrl* crd, const Position<int>& position); |
| 74 |
void follow_circle(const CoordinateCtrl* crd, |
| 75 |
const Grid<int>& point, const int radius); |
| 76 |
|
| 77 |
// !!! 並進速度を下げてでも、経路通りに走行するコマンドを追加する |
| 78 |
// !!! 直線 |
| 79 |
// !!! 円弧 |
| 80 |
|
| 81 |
// !!! line がまぎらわしい。端っこまで移動、というニュアンスの単語に変える |
| 82 |
// !!! また、停止線は、2点で指定できるようにもしたい |
| 83 |
// !!! stop_toLine() なら、まだわかるかも |
| 84 |
void stop_toLine(const CoordinateCtrl* crd, |
| 85 |
const Position<int>& position); |
| 86 |
|
| 87 |
// !!! どういう動きをするのか、わからない |
| 88 |
// !!! 目標位置に向かう、でいいのかな? |
| 89 |
// !!! 直線追従 + 速度制御 |
| 90 |
void stop_toPoint(const CoordinateCtrl* crd, const Grid<int>& point); |
| 91 |
|
| 92 |
// !!! 指定距離以上だけ動作するのか? どういう動きなのかわからない。 |
| 93 |
// !!! 直線移動 + 停止、なんだろうけど... |
| 94 |
// !!! もっとわかりやすい名前にする |
| 95 |
// !!! 直線移動についてのパラメータ指定がないのも気になる |
| 96 |
void move_length(const int length); |
| 97 |
|
| 98 |
void rotate_angle(const Angle& angle); |
| 99 |
|
| 100 |
// !!! stop_toAngle() にすべきか? |
| 101 |
void stop_toAngle(const CoordinateCtrl* crd, const Angle& angle); |
| 102 |
|
| 103 |
//void getParams_ |
| 104 |
//void setParams_ |
| 105 |
|
| 106 |
// !!! 接線指定の円弧追従 |
| 107 |
// !!! 速度指定の回転 |
| 108 |
// !!! 直前の移動コマンドを再発行 |
| 109 |
|
| 110 |
// 判定コマンド |
| 111 |
// !!! 以下のコマンドは、getPosition() から作りましょう。別ファイルにて |
| 112 |
bool isStable(void); |
| 113 |
int getLength_toLine(const CoordinateCtrl* crd, |
| 114 |
const Position<int>& position); |
| 115 |
int getLength_toPoint(const CoordinateCtrl* crd, const Grid<int>& point); |
| 116 |
|
| 117 |
Angle getAngle_toDirection(void); |
| 118 |
Angle getAngle_toPoint(void); |
| 119 |
Angle getAngle_toLine(void); |
| 120 |
|
| 121 |
int getVelocityDiff_straight(const int velocity); |
| 122 |
Angle getVelocityDiff_rotate(const Angle velocity); |
| 123 |
|
| 124 |
int getVelocity_straight(void); |
| 125 |
Angle getVelocity_rotate(void); |
| 126 |
|
| 127 |
// 座標系コマンド |
| 128 |
// !!! |
| 129 |
// !!! ここで自己位置を取得する |
| 130 |
Position<int> getPosition(const CoordinateCtrl* crd = NULL); |
| 131 |
|
| 132 |
// パラメータ操作コマンド |
| 133 |
//GetParams getParams; |
| 134 |
// !!! |
| 135 |
|
| 136 |
//SetParams setParams; |
| 137 |
// !!! |
| 138 |
|
| 139 |
size_t getRawTimestamp(void); |
| 140 |
|
| 141 |
// デバイスの直接制御コマンド |
| 142 |
// !!! PWM の直接制御 |
| 143 |
// !!! モータモードの直接制御 |
| 144 |
// !!! エンコーダ値の直接取得 |
| 145 |
void direct_setWheelVelocity(const int id, const int velocity_mm); |
| 146 |
|
| 147 |
void direct_setStraightVelocity(const int velocity_mm); |
| 148 |
void direct_setRotateVelocity(const Angle& velocity_angle); |
| 149 |
}; |
| 150 |
}; |
| 151 |
|
| 152 |
#endif /* !RUN_CTRL_H */ |