00001 // -*- C++ -*- 00010 #ifndef OGMAP3DVIEWER_H 00011 #define OGMAP3DVIEWER_H 00012 00013 #include <rtm/idl/BasicDataType.hh> 00014 #include <rtm/idl/InterfaceDataTypes.hh> 00015 #include <rtm/Manager.h> 00016 #include <rtm/DataFlowComponentBase.h> 00017 #include <rtm/CorbaPort.h> 00018 #include <rtm/DataInPort.h> 00019 #include <rtm/DataOutPort.h> 00020 #include <rtm/idl/BasicDataTypeSkel.h> 00021 #include <rtm/idl/InterfaceDataTypes.hh> 00022 //Open CV headder 00023 #include <cv.h> 00024 #include <highgui.h> 00025 #include "hrpsys/idl/OGMap3DService.hh" 00026 00027 class GLbody; 00028 class CMapSceneNode; 00029 00030 // Service implementation headers 00031 // <rtc-template block="service_impl_h"> 00032 00033 // </rtc-template> 00034 00035 // Service Consumer stub headers 00036 // <rtc-template block="consumer_stub_h"> 00037 00038 // </rtc-template> 00039 00040 using namespace RTC; 00041 00045 class OGMap3DViewer 00046 : public RTC::DataFlowComponentBase 00047 { 00048 public: 00053 OGMap3DViewer(RTC::Manager* manager); 00057 virtual ~OGMap3DViewer(); 00058 00059 // The initialize action (on CREATED->ALIVE transition) 00060 // formaer rtc_init_entry() 00061 virtual RTC::ReturnCode_t onInitialize(); 00062 00063 // The finalize action (on ALIVE->END transition) 00064 // formaer rtc_exiting_entry() 00065 // virtual RTC::ReturnCode_t onFinalize(); 00066 00067 // The startup action when ExecutionContext startup 00068 // former rtc_starting_entry() 00069 // virtual RTC::ReturnCode_t onStartup(RTC::UniqueId ec_id); 00070 00071 // The shutdown action when ExecutionContext stop 00072 // former rtc_stopping_entry() 00073 // virtual RTC::ReturnCode_t onShutdown(RTC::UniqueId ec_id); 00074 00075 // The activated action (Active state entry action) 00076 // former rtc_active_entry() 00077 virtual RTC::ReturnCode_t onActivated(RTC::UniqueId ec_id); 00078 00079 // The deactivated action (Active state exit action) 00080 // former rtc_active_exit() 00081 virtual RTC::ReturnCode_t onDeactivated(RTC::UniqueId ec_id); 00082 00083 // The execution action that is invoked periodically 00084 // former rtc_active_do() 00085 virtual RTC::ReturnCode_t onExecute(RTC::UniqueId ec_id); 00086 00087 // The aborting action when main logic error occurred. 00088 // former rtc_aborting_entry() 00089 // virtual RTC::ReturnCode_t onAborting(RTC::UniqueId ec_id); 00090 00091 // The error action in ERROR state 00092 // former rtc_error_do() 00093 // virtual RTC::ReturnCode_t onError(RTC::UniqueId ec_id); 00094 00095 // The reset action that is invoked resetting 00096 // This is same but different the former rtc_init_entry() 00097 // virtual RTC::ReturnCode_t onReset(RTC::UniqueId ec_id); 00098 00099 // The state update action that is invoked after onExecute() action 00100 // no corresponding operation exists in OpenRTm-aist-0.2.0 00101 // virtual RTC::ReturnCode_t onStateUpdate(RTC::UniqueId ec_id); 00102 00103 // The action that is invoked when execution context's rate is changed 00104 // no corresponding operation exists in OpenRTm-aist-0.2.0 00105 // virtual RTC::ReturnCode_t onRateChanged(RTC::UniqueId ec_id); 00106 00107 00108 protected: 00109 // Configuration variable declaration 00110 // <rtc-template block="config_declare"> 00111 00112 // </rtc-template> 00113 00114 OGMapCells m_cells; 00115 TimedDoubleSeq m_q; 00116 TimedPoint3D m_p; 00117 TimedOrientation3D m_rpy; 00118 00119 // DataInPort declaration 00120 // <rtc-template block="inport_declare"> 00121 InPort<TimedDoubleSeq> m_qIn; 00122 InPort<TimedPoint3D> m_pIn; 00123 InPort<TimedOrientation3D> m_rpyIn; 00124 00125 // </rtc-template> 00126 00127 // DataOutPort declaration 00128 // <rtc-template block="outport_declare"> 00129 00130 // </rtc-template> 00131 00132 // CORBA Port declaration 00133 // <rtc-template block="corbaport_declare"> 00134 RTC::CorbaPort m_OGMap3DServicePort; 00135 RTC::CorbaConsumer<OpenHRP::OGMap3DService> m_OGMap3DService; 00136 00137 // </rtc-template> 00138 00139 // Service declaration 00140 // <rtc-template block="service_declare"> 00141 00142 // </rtc-template> 00143 00144 // Consumer declaration 00145 // <rtc-template block="consumer_declare"> 00146 00147 // </rtc-template> 00148 00149 private: 00150 int dummy; 00151 bool m_isopen; 00152 double m_xSize, m_ySize, m_zSize; 00153 double m_xOrigin, m_yOrigin, m_zOrigin; 00154 bool m_generateImageSequence; 00155 GLbody *m_body; 00156 unsigned int m_imageCount; 00157 bool m_generateMovie, m_isGeneratingMovie; 00158 CMapSceneNode *m_mapNode; 00159 OpenHRP::OGMap3D *m_ogmap; 00160 CvVideoWriter *m_videoWriter; 00161 IplImage *m_cvImage; 00162 }; 00163 00164 00165 extern "C" 00166 { 00167 void OGMap3DViewerInit(RTC::Manager* manager); 00168 }; 00169 00170 #endif // OGMAP3DVIEWER_H