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 "Image/DrawOps.H" 00008 #include "GUI/XWinManaged.H" 00009 #include "GUI/ImageDisplayStream.H" 00010 #include "Robots/RobotBrain/RobotBrainComponent.H" 00011 #include "Util/Timer.H" 00012 #include "Component/ModelParam.H" 00013 #include "Component/ModelOptionDef.H" 00014 00015 #include "Ice/RobotBrainObjects.ice.H" 00016 #include "Ice/RobotSimEvents.ice.H" 00017 #include <IceUtil/Thread.h> 00018 00019 #include <vector> 00020 00021 #include "Devices/Serial.H" 00022 00023 typedef struct { 00024 double dist,angle; 00025 } sonarData; 00026 00027 class BeoSonar : public RobotBrainComponent 00028 { 00029 public: 00030 00031 BeoSonar(int id, OptionManager& mgr, 00032 const std::string& descrName = "BeoSonar", 00033 const std::string& tagName = "BeoSonar"); 00034 00035 ~BeoSonar(); 00036 00037 virtual void evolve(); 00038 00039 //!Get a message 00040 virtual void updateMessage(const RobotSimEvents::EventMessagePtr& eMsg, 00041 const Ice::Current&); 00042 00043 virtual void registerTopics(); 00044 00045 void plotDists(); 00046 00047 void start3(); 00048 00049 private: 00050 nub::soft_ref<Serial> itsSerial; 00051 00052 std::vector<sonarData> itsData; 00053 nub::soft_ref<OutputFrameSeries> itsOfs; 00054 Timer itsDisplayTimer; 00055 float itsDisplayUpdateRate; 00056 00057 OModelParam<std::string> itsSerialDev; 00058 };