VirtualCamera.h
Go to the documentation of this file.
00001 // -*- C++ -*-
00010 #ifndef VIRTUAL_CAMERA_H
00011 #define VIRTUAL_CAMERA_H
00012 
00013 #include <rtm/idl/BasicDataType.hh>
00014 #include <rtm/idl/InterfaceDataTypes.hh>
00015 #include "hrpsys/idl/HRPDataTypes.hh"
00016 #include "hrpsys/idl/Img.hh"
00017 #include "hrpsys/idl/pointcloud.hh"
00018 #include <rtm/Manager.h>
00019 #include <rtm/DataFlowComponentBase.h>
00020 #include <rtm/CorbaPort.h>
00021 #include <rtm/DataInPort.h>
00022 #include <rtm/DataOutPort.h>
00023 #include <rtm/idl/BasicDataTypeSkel.h>
00024 //Open CV headder
00025 #include <cv.h>
00026 #include <highgui.h>
00027 //
00028 #include "hrpsys/util/LogManager.h"
00029 #include "hrpsys/util/SDLUtil.h"
00030 #include "GLscene.h"
00031 class GLcamera;
00032 class RTCGLbody;
00033 
00034 // Service implementation headers
00035 // <rtc-template block="service_impl_h">
00036 
00037 // </rtc-template>
00038 
00039 // Service Consumer stub headers
00040 // <rtc-template block="consumer_stub_h">
00041 
00042 // </rtc-template>
00043 
00044 using namespace RTC;
00045 
00049 class VirtualCamera
00050   : public RTC::DataFlowComponentBase
00051 {
00052  public:
00057   VirtualCamera(RTC::Manager* manager);
00061   virtual ~VirtualCamera();
00062 
00063   // The initialize action (on CREATED->ALIVE transition)
00064   // formaer rtc_init_entry()
00065   virtual RTC::ReturnCode_t onInitialize();
00066 
00067   // The finalize action (on ALIVE->END transition)
00068   // formaer rtc_exiting_entry()
00069   // virtual RTC::ReturnCode_t onFinalize();
00070 
00071   // The startup action when ExecutionContext startup
00072   // former rtc_starting_entry()
00073   // virtual RTC::ReturnCode_t onStartup(RTC::UniqueId ec_id);
00074 
00075   // The shutdown action when ExecutionContext stop
00076   // former rtc_stopping_entry()
00077   // virtual RTC::ReturnCode_t onShutdown(RTC::UniqueId ec_id);
00078 
00079   // The activated action (Active state entry action)
00080   // former rtc_active_entry()
00081   virtual RTC::ReturnCode_t onActivated(RTC::UniqueId ec_id);
00082 
00083   // The deactivated action (Active state exit action)
00084   // former rtc_active_exit()
00085   virtual RTC::ReturnCode_t onDeactivated(RTC::UniqueId ec_id);
00086 
00087   // The execution action that is invoked periodically
00088   // former rtc_active_do()
00089   virtual RTC::ReturnCode_t onExecute(RTC::UniqueId ec_id);
00090 
00091   // The aborting action when main logic error occurred.
00092   // former rtc_aborting_entry()
00093   // virtual RTC::ReturnCode_t onAborting(RTC::UniqueId ec_id);
00094 
00095   // The error action in ERROR state
00096   // former rtc_error_do()
00097   // virtual RTC::ReturnCode_t onError(RTC::UniqueId ec_id);
00098 
00099   // The reset action that is invoked resetting
00100   // This is same but different the former rtc_init_entry()
00101   // virtual RTC::ReturnCode_t onReset(RTC::UniqueId ec_id);
00102 
00103   // The state update action that is invoked after onExecute() action
00104   // no corresponding operation exists in OpenRTm-aist-0.2.0
00105   // virtual RTC::ReturnCode_t onStateUpdate(RTC::UniqueId ec_id);
00106 
00107   // The action that is invoked when execution context's rate is changed
00108   // no corresponding operation exists in OpenRTm-aist-0.2.0
00109   // virtual RTC::ReturnCode_t onRateChanged(RTC::UniqueId ec_id);
00110 
00111 
00112  protected:
00113   // Configuration variable declaration
00114   // <rtc-template block="config_declare">
00115   
00116   // </rtc-template>
00117 
00118   OpenHRP::SceneState m_sceneState;
00119   RTC::TimedPoint3D m_basePos;
00120   RTC::TimedOrientation3D m_baseRpy;
00121   RTC::TimedDoubleSeq m_q;
00122 
00123   // DataInPort declaration
00124   // <rtc-template block="inport_declare">
00125   InPort<OpenHRP::SceneState> m_sceneStateIn;
00126   InPort<RTC::TimedPoint3D> m_basePosIn;
00127   InPort<RTC::TimedOrientation3D> m_baseRpyIn;
00128   InPort<RTC::TimedDoubleSeq> m_qIn;
00129   
00130   // </rtc-template>
00131 
00132   Img::TimedCameraImage m_image;
00133   RangeData m_range;  
00134   PointCloudTypes::PointCloud m_cloud;
00135   TimedPose3D m_poseSensor;
00136 
00137   // DataOutPort declaration
00138   // <rtc-template block="outport_declare">
00139   OutPort<Img::TimedCameraImage> m_imageOut;
00140   OutPort<RangeData> m_rangeOut;
00141   OutPort<PointCloudTypes::PointCloud> m_cloudOut;
00142   OutPort<TimedPose3D> m_poseSensorOut;
00143   
00144   // </rtc-template>
00145 
00146   // CORBA Port declaration
00147   // <rtc-template block="corbaport_declare">
00148   
00149   // </rtc-template>
00150 
00151   // Service declaration
00152   // <rtc-template block="service_declare">
00153   
00154   // </rtc-template>
00155 
00156   // Consumer declaration
00157   // <rtc-template block="consumer_declare">
00158   
00159   // </rtc-template>
00160 
00161  private:
00162   void setupRangeData();  
00163   void setupPointCloud();  
00164   GLscene m_scene;
00165   LogManager<OpenHRP::SceneState> m_log;
00166   SDLwindow m_window;
00167   GLcamera *m_camera;
00168   bool m_generateRange;
00169   bool m_generatePointCloud;
00170   int m_generatePointCloudStep;
00171   std::string m_pcFormat;
00172   bool m_generateMovie, m_isGeneratingMovie;
00173   int m_debugLevel;
00174   CvVideoWriter *m_videoWriter;
00175   IplImage *m_cvImage;
00176   std::string m_projectName;
00177   std::string m_cameraName;
00178   std::map<std::string, RTCGLbody *> m_bodies;
00179   int dummy;
00180 };
00181 
00182 
00183 extern "C"
00184 {
00185   void VirtualCameraInit(RTC::Manager* manager);
00186 };
00187 
00188 #endif // VIRTUAL_CAMERA_H


hrpsys
Author(s): AIST, Fumio Kanehiro
autogenerated on Wed Sep 6 2017 02:35:56