00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 #ifndef MovementController_H_DEFINED
00039 #define MovementController_H_DEFINED
00040
00041 #include "Component/ModelComponent.H"
00042 #include "Component/ModelOptionDef.H"
00043 #include "Component/ModelParam.H"
00044 #include "Component/OptionManager.H"
00045 #include "Image/Point2D.H"
00046 #include "SubController.H"
00047
00048 const ModelOptionCateg MOC_SeaBee_Movement_Controller = {
00049 MOC_SORTPRI_3, "SeaBee Movement Controller related options" };
00050
00051 static const ModelOptionDef OPT_DepthErrThresh =
00052 { MODOPT_ARG(int), "DepthErrThresh", &MOC_SeaBee_Movement_Controller, OPTEXP_SAVE,
00053 "Error threshold for depth",
00054 "depth-err-thresh", '\0', "<int>", "0" };
00055
00056 static const ModelOptionDef OPT_HeadingErrThresh =
00057 { MODOPT_ARG(int), "HeadingErrThresh", &MOC_SeaBee_Movement_Controller, OPTEXP_SAVE,
00058 "Error threshold for heading",
00059 "heading-err-thresh", '\0', "<int>", "0" };
00060
00061 static const ModelOptionDef OPT_DiveValue =
00062 { MODOPT_ARG(int), "DiveValue", &MOC_SeaBee_Movement_Controller, OPTEXP_SAVE,
00063 "Depth to dive",
00064 "depth-value", '\0', "<int>", "0" };
00065
00066 static const ModelOptionDef OPT_GoStraightTime =
00067 { MODOPT_ARG(int), "GoStraightTime", &MOC_SeaBee_Movement_Controller, OPTEXP_SAVE,
00068 "Time to go straight for",
00069 "straight-time", '\0', "<int>", "0" };
00070
00071 static const ModelOptionDef OPT_SpeedValue =
00072 { MODOPT_ARG(int), "SpeedValue", &MOC_SeaBee_Movement_Controller, OPTEXP_SAVE,
00073 "Value for speed",
00074 "speed-value", '\0', "<int>", "0" };
00075
00076 static const ModelOptionDef OPT_HeadingValue =
00077 { MODOPT_ARG(int), "HeadingValue", &MOC_SeaBee_Movement_Controller, OPTEXP_SAVE,
00078 "Value for heading",
00079 "heading-value", '\0', "<int>", "0" };
00080
00081 static const ModelOptionDef OPT_TimeoutValue =
00082 { MODOPT_ARG(int), "TimeoutValue", &MOC_SeaBee_Movement_Controller, OPTEXP_SAVE,
00083 "Value for timeout",
00084 "timeout-value", '\0', "<int>", "0" };
00085
00086
00087
00088 class MovementController : public ModelComponent
00089 {
00090 public:
00091
00092
00093
00094
00095
00096
00097 MovementController(OptionManager& mgr,
00098 nub::soft_ref<SubController> subController,
00099 const std::string& descrName = "MovementController",
00100 const std::string& tagName = "MovementController");
00101
00102
00103 ~MovementController();
00104
00105 bool dive(int depth, bool relative = false, int timeout = 0);
00106 bool goStraight(int speed, int time);
00107 bool setHeading(int heading, bool relative = false, int timeout = 0);
00108 int trackPipe(const Point2D<int>& pointToTrack, const Point2D<int>& desiredPoint);
00109
00110 void paramChanged(ModelParamBase* const param,
00111 const bool valueChanged,
00112 ParamClient::ChangeStatus* status);
00113
00114
00115
00116
00117
00118
00119
00120 OModelParam<int> itsDepthErrThresh;
00121 OModelParam<int> itsHeadingErrThresh;
00122
00123 NModelParam<float> pipeP;
00124 NModelParam<float> pipeI;
00125 NModelParam<float> pipeD;
00126 PID<float> itsPipePID;
00127
00128 OModelParam<int> setDiveValue;
00129 OModelParam<int> setGoStraightTimeValue;
00130 OModelParam<int> setSpeedValue;
00131 OModelParam<int> setHeadingValue;
00132 NModelParam<bool> setRelative;
00133 OModelParam<int> setTimeout;
00134
00135 private:
00136
00137 nub::soft_ref<SubController> itsSubController;
00138
00139 };
00140
00141 #endif
00142
00143
00144
00145
00146
00147