BeeStemI.H

00001 #include "Component/ModelComponent.H"
00002 #include "Component/ModelParam.H"
00003 #include "Media/FrameSeries.H"
00004 #include "Transport/FrameInfo.H"
00005 #include "Raster/GenericFrame.H"
00006 #include "Image/Image.H"
00007 #include "GUI/XWinManaged.H"
00008 #include "GUI/ImageDisplayStream.H"
00009 #include "Image/Image.H"
00010 #include "Image/Pixels.H"
00011 #include "Robots/RobotBrain/RobotBrainComponent.H"
00012 
00013 #include "Ice/RobotBrainObjects.ice.H"
00014 #include "Ice/RobotSimEvents.ice.H"
00015 #include "Ice/IceImageUtils.H"
00016 #include <IceUtil/Thread.h>
00017 
00018 #include "Devices/BeeStem3.H"
00019 #include <vector>
00020 
00021 #define HEADING_K 0
00022 #define HEADING_P 15
00023 #define HEADING_I 0
00024 #define HEADING_D 0
00025 
00026 #define DEPTH_K 0
00027 #define DEPTH_P 33
00028 #define DEPTH_I 0
00029 #define DEPTH_D 0
00030 
00031 class BeeStemI: public RobotBrainComponent
00032 {
00033 public:
00034 
00035         struct FiringDeviceID
00036         {
00037                 const static int Null = -1;
00038                 const static int MIN = 0;
00039                 const static int Shooter = 0;
00040                 const static int DropperStage1 = 1;
00041                 const static int DropperStage2 = 2;
00042                 const static int MAX = 2;
00043         };
00044 
00045         struct ShooterState
00046         {
00047                 const static int Idle = 0;
00048                 const static int Armed = 1;
00049                 const static int Firing = 2;
00050                 const static int Reset = 3;
00051                 const static int MAX = 3;
00052         };
00053 
00054         /*
00055          * Ensures proper functioning of the dropper;
00056          * -Each stage must be armed prior to dropping
00057          * -Stage2 can't be armed until Stage1 has been reset
00058          */
00059         struct DropperState
00060         {
00061                 const static int AllIdle = 0;
00062                 const static int Stage1Armed = 1;
00063                 const static int Stage1Dropping = 2;
00064                 const static int Stage1Reset = 3;
00065                 const static int Stage1Idle = 4;
00066                 const static int Stage2Armed = 5;
00067                 const static int Stage2Dropping = 6;
00068                 const static int Stage2Reset = 7;
00069                 const static int MAX = 7;
00070         };
00071 
00072         struct BeeStemFlags
00073         {
00074                 bool needsUpdateFromJoystick;
00075                 bool initFlag;
00076 
00077                 BeeStemFlags()
00078                 {
00079                         needsUpdateFromJoystick = false;
00080                         initFlag = false;
00081                 }
00082         };
00083 
00084         BeeStemI(int id, OptionManager& mgr, const std::string& descrName =
00085                         "BeeStemI", const std::string& tagName = "BeeStemI");
00086 
00087         ~BeeStemI();
00088 
00089         virtual void evolve();
00090 
00091         //!Get a message
00092         virtual void updateMessage(const RobotSimEvents::EventMessagePtr& eMsg,
00093                         const Ice::Current&);
00094 
00095         virtual void registerTopics();
00096 
00097         void fireDevice(int deviceID);
00098 
00099         static void getMotorControllerMsg(RobotSimEvents::BeeStemMotorControllerMessagePtr & msg, int mc0, int mc1, int mc2, int mc3, int mc4, int mc5, int mc6, int mc7, int mc8);
00100 
00101 private:
00102 
00103         void initPose();
00104         void setValuesFromJoystick();
00105 
00106         nub::soft_ref<BeeStem3> itsStem;
00107         //  nub::soft_ref<Serial> itsKillSwitch;
00108         //  pthread_mutex_t itsKillSwitchLock;
00109 
00110         IceUtil::Mutex itsStemMutex;
00111         std::map<int, int> itsJSMappings;
00112         //std::vector<int> itsJSValues;
00113         std::vector<int> itsButValues;
00114         int itsDesiredHeading, itsDesiredDepth, itsDesiredSpeed;
00115         int itsUpdateHeading, itsUpdateDepth, itsUpdateSpeed;
00116         int itsLastUpdateHeading, itsLastUpdateDepth, itsLastUpdateSpeed;
00117         IceUtil::Mutex itsUpdateMutex;
00118         int mShooterState;
00119         int mDropperState;
00120         int mFiringDeviceID;
00121 
00122         BeeStemFlags mFlags;
00123 };
Generated on Sun May 8 08:41:32 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3