MovementControllerI.H
00001 #include "Component/ModelManager.H"
00002 #include "Component/OptionManager.H"
00003 #include "Component/ModelComponent.H"
00004 #include "Component/ModelParam.H"
00005 #include "Media/FrameSeries.H"
00006 #include "Transport/FrameInfo.H"
00007 #include "Raster/GenericFrame.H"
00008 #include "Image/Image.H"
00009 #include "GUI/XWinManaged.H"
00010 #include "GUI/ImageDisplayStream.H"
00011 #include "Image/Image.H"
00012 #include "Image/Pixels.H"
00013 #include "Robots/RobotBrain/RobotBrainComponent.H"
00014 #include "Ice/RobotBrainObjects.ice.H"
00015 #include "Ice/RobotSimEvents.ice.H"
00016 #include "Ice/IceImageUtils.H"
00017 #include <IceUtil/Thread.h>
00018
00019 #ifndef MOVEMENTCONTROLLERI_H
00020 #define MOVEMENTCONTROLLERI_H
00021
00022
00023 #define STATE_INIT 0
00024 #define STATE_DO_GATE 1
00025 #define STATE_FIND_FLARE 2
00026 #define STATE_DO_FLARE 3
00027 #define STATE_FIND_BARBWIRE 4
00028 #define STATE_DO_BARBWIRE 5
00029 #define STATE_FIND_BOMBING 6
00030 #define STATE_DO_BOMBING 7
00031 #define STATE_FIND_BRIEFCASE 8
00032 #define STATE_DO_BRIEFCASE 9
00033 #define STATE_PATH_FOLLOW 10
00034
00035
00036 class MovementControllerI : public RobotBrainComponent
00037 {
00038 public:
00039
00040 MovementControllerI(int id, OptionManager& mgr,
00041 const std::string& descrName = "MovementController",
00042 const std::string& tagName = "MovementController");
00043
00044 ~MovementControllerI();
00045
00046 virtual void evolve();
00047
00048 virtual void updateMessage(const RobotSimEvents::EventMessagePtr& eMsg,
00049 const Ice::Current&);
00050
00051 virtual void registerTopics();
00052
00053
00054
00055 struct SensorPose
00056 {
00057 float val;
00058 float weight;
00059 float decay;
00060 };
00061
00062
00063 enum SensorType { PATH, SALIENCY, PINGER, BARBWIRE };
00064
00065
00066
00067 struct SensorVote
00068 {
00069 enum SensorType type;
00070 SensorPose heading;
00071 SensorPose depth;
00072
00073 bool init;
00074 };
00075
00076 private:
00077
00078
00079 void state_init();
00080 void state_do_gate();
00081 void state_find_flare();
00082 void state_do_flare();
00083 void state_find_barbwire();
00084 void state_do_barbwire();
00085 void state_find_bombing();
00086 void state_do_bombing();
00087 void state_find_briefcase();
00088 void state_do_briefcase();
00089 void state_path_follow();
00090
00091
00092
00093 void set_heading(int heading);
00094 void set_depth(int depth);
00095 void set_speed(int speed);
00096
00097
00098 void enablePID();
00099 void disablePID();
00100
00101
00102 void initSensorVotes();
00103
00104
00105
00106
00107
00108 OModelParam<float> itsGateFwdTime;
00109
00110 OModelParam<float> itsGateDepth;
00111
00112
00113 OModelParam<float> itsSaliencyHeadingCorrScale;
00114
00115 OModelParam<float> itsSaliencyDepthCorrScale;
00116
00117 OModelParam<float> itsSpeedCorrScale;
00118
00119
00120
00121
00122
00123 unsigned int itsCurrentState;
00124
00125
00126 int checker_path_follow_1;
00127 int checker_path_follow_2;
00128 int checker_path_follow_3;
00129
00130
00131
00132 int its_current_heading;
00133 int its_current_ex_pressure;
00134 int its_current_int_pressure;
00135
00136
00137 IceUtil::Mutex its_current_pose_mutex;
00138
00139
00140 char itsKillSwitchState;
00141
00142
00143 std::vector<SensorVote> itsSensorVotes;
00144
00145
00146 float itsPoseError;
00147
00148
00149
00150
00151
00152 float itsLastCompositeHeading, itsLastCompositeDepth, itsLastSpeed;
00153
00154
00155 bool isInit;
00156
00157
00158
00159 int itsDiveVal;
00160
00161
00162 char itsDiveCount;
00163
00164
00165 int itsHeadingVal;
00166
00167
00168
00169 bool itsPIDEnabled;
00170
00171
00172 bool itsSpeedEnabled;
00173 };
00174
00175 #endif