ExtractCameraImage.cpp
Go to the documentation of this file.
00001 // -*- C++ -*-
00010 #include "ExtractCameraImage.h"
00011 
00012 // Module specification
00013 // <rtc-template block="module_spec">
00014 static const char* extractcameraimage_spec[] =
00015   {
00016     "implementation_id", "ExtractCameraImage",
00017     "type_name",         "ExtractCameraImage",
00018     "description",       "extractcameraimage component",
00019     "version",           HRPSYS_PACKAGE_VERSION,
00020     "vendor",            "AIST",
00021     "category",          "example",
00022     "activity_type",     "DataFlowComponent",
00023     "max_instance",      "10",
00024     "language",          "C++",
00025     "lang_type",         "compile",
00026     // Configuration variables
00027     "conf.default.index","0",
00028 
00029     ""
00030   };
00031 // </rtc-template>
00032 
00033 ExtractCameraImage::ExtractCameraImage(RTC::Manager* manager)
00034   : RTC::DataFlowComponentBase(manager),
00035     // <rtc-template block="initializer">
00036     m_imagesIn("images", m_images),
00037     m_imageOut("image", m_image),
00038     // </rtc-template>
00039     m_index(0),
00040     dummy(0)
00041 {
00042 }
00043 
00044 ExtractCameraImage::~ExtractCameraImage()
00045 {
00046 }
00047 
00048 
00049 
00050 RTC::ReturnCode_t ExtractCameraImage::onInitialize()
00051 {
00052   std::cout << m_profile.instance_name << ": onInitialize()" << std::endl;
00053   // <rtc-template block="bind_config">
00054   // Bind variables and configuration variable
00055   bindParameter("index", m_index, "0");
00056   
00057   // </rtc-template>
00058 
00059   // Registration: InPort/OutPort/Service
00060   // <rtc-template block="registration">
00061   // Set InPort buffers
00062   addInPort("imagesIn", m_imagesIn);
00063 
00064   // Set OutPort buffer
00065   addOutPort("imageOut", m_imageOut);
00066   
00067   // Set service provider to Ports
00068   
00069   // Set service consumers to Ports
00070   
00071   // Set CORBA Service Ports
00072   
00073   // </rtc-template>
00074 
00075   return RTC::RTC_OK;
00076 }
00077 
00078 
00079 
00080 /*
00081 RTC::ReturnCode_t ExtractCameraImage::onFinalize()
00082 {
00083   return RTC::RTC_OK;
00084 }
00085 */
00086 
00087 /*
00088 RTC::ReturnCode_t ExtractCameraImage::onStartup(RTC::UniqueId ec_id)
00089 {
00090   return RTC::RTC_OK;
00091 }
00092 */
00093 
00094 /*
00095 RTC::ReturnCode_t ExtractCameraImage::onShutdown(RTC::UniqueId ec_id)
00096 {
00097   return RTC::RTC_OK;
00098 }
00099 */
00100 
00101 RTC::ReturnCode_t ExtractCameraImage::onActivated(RTC::UniqueId ec_id)
00102 {
00103   std::cout << m_profile.instance_name<< ": onActivated(" << ec_id << ")" << std::endl;
00104   return RTC::RTC_OK;
00105 }
00106 
00107 RTC::ReturnCode_t ExtractCameraImage::onDeactivated(RTC::UniqueId ec_id)
00108 {
00109   std::cout << m_profile.instance_name<< ": onDeactivated(" << ec_id << ")" << std::endl;
00110   return RTC::RTC_OK;
00111 }
00112 
00113 RTC::ReturnCode_t ExtractCameraImage::onExecute(RTC::UniqueId ec_id)
00114 {
00115   if (m_imagesIn.isNew()){
00116     m_imagesIn.read();
00117     if (m_images.data.image_seq.length() > m_index){
00118       m_image.tm = m_images.tm;
00119       m_image.data = m_images.data.image_seq[m_index];
00120       m_image.error_code = m_images.error_code;
00121       m_imageOut.write();
00122     }else{
00123       std::cerr << m_profile.instance_name << ": invalid index of image(" << m_index 
00124                 << "), length of images = " << m_images.data.image_seq.length() << std::endl;
00125     }
00126   }
00127   return RTC::RTC_OK;
00128 }
00129 
00130 /*
00131 RTC::ReturnCode_t ExtractCameraImage::onAborting(RTC::UniqueId ec_id)
00132 {
00133   return RTC::RTC_OK;
00134 }
00135 */
00136 
00137 /*
00138 RTC::ReturnCode_t ExtractCameraImage::onError(RTC::UniqueId ec_id)
00139 {
00140   return RTC::RTC_OK;
00141 }
00142 */
00143 
00144 /*
00145 RTC::ReturnCode_t ExtractCameraImage::onReset(RTC::UniqueId ec_id)
00146 {
00147   return RTC::RTC_OK;
00148 }
00149 */
00150 
00151 /*
00152 RTC::ReturnCode_t ExtractCameraImage::onStateUpdate(RTC::UniqueId ec_id)
00153 {
00154   return RTC::RTC_OK;
00155 }
00156 */
00157 
00158 /*
00159 RTC::ReturnCode_t ExtractCameraImage::onRateChanged(RTC::UniqueId ec_id)
00160 {
00161   return RTC::RTC_OK;
00162 }
00163 */
00164 
00165 
00166 
00167 extern "C"
00168 {
00169 
00170   void ExtractCameraImageInit(RTC::Manager* manager)
00171   {
00172     RTC::Properties profile(extractcameraimage_spec);
00173     manager->registerFactory(profile,
00174                              RTC::Create<ExtractCameraImage>,
00175                              RTC::Delete<ExtractCameraImage>);
00176   }
00177 
00178 };
00179 
00180 


hrpsys
Author(s): AIST, Fumio Kanehiro
autogenerated on Wed May 15 2019 05:02:17