RangeNoiseMixer.cpp
Go to the documentation of this file.
00001 // -*- C++ -*-
00010 #include "RangeNoiseMixer.h"
00011 
00012 // Module specification
00013 // <rtc-template block="module_spec">
00014 static const char* spec[] =
00015   {
00016     "implementation_id", "RangeNoiseMixer",
00017     "type_name",         "RangeNoiseMixer",
00018     "description",       "noise mixer for range data",
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.maxDist", "0.02",
00028 
00029     ""
00030   };
00031 // </rtc-template>
00032 
00033 RangeNoiseMixer::RangeNoiseMixer(RTC::Manager* manager)
00034   : RTC::DataFlowComponentBase(manager),
00035     // <rtc-template block="initializer">
00036     m_rangeIn("original", m_range),
00037     m_rangeOut("mixed", m_range),
00038     // </rtc-template>
00039     dummy(0)
00040 {
00041 }
00042 
00043 RangeNoiseMixer::~RangeNoiseMixer()
00044 {
00045 }
00046 
00047 
00048 
00049 RTC::ReturnCode_t RangeNoiseMixer::onInitialize()
00050 {
00051   //std::cout << m_profile.instance_name << ": onInitialize()" << std::endl;
00052   // <rtc-template block="bind_config">
00053   // Bind variables and configuration variable
00054   bindParameter("maxDist", m_maxDist, "0.02");
00055   
00056   // </rtc-template>
00057 
00058   // Registration: InPort/OutPort/Service
00059   // <rtc-template block="registration">
00060   // Set InPort buffers
00061   addInPort("original", m_rangeIn);
00062 
00063   // Set OutPort buffer
00064   addOutPort("mixed", m_rangeOut);
00065   
00066   // Set service provider to Ports
00067   
00068   // Set service consumers to Ports
00069   
00070   // Set CORBA Service Ports
00071   
00072   // </rtc-template>
00073 
00074   RTC::Properties& prop = getProperties();
00075 
00076   return RTC::RTC_OK;
00077 }
00078 
00079 
00080 
00081 /*
00082 RTC::ReturnCode_t RangeNoiseMixer::onFinalize()
00083 {
00084   return RTC::RTC_OK;
00085 }
00086 */
00087 
00088 /*
00089 RTC::ReturnCode_t RangeNoiseMixer::onStartup(RTC::UniqueId ec_id)
00090 {
00091   return RTC::RTC_OK;
00092 }
00093 */
00094 
00095 /*
00096 RTC::ReturnCode_t RangeNoiseMixer::onShutdown(RTC::UniqueId ec_id)
00097 {
00098   return RTC::RTC_OK;
00099 }
00100 */
00101 
00102 RTC::ReturnCode_t RangeNoiseMixer::onActivated(RTC::UniqueId ec_id)
00103 {
00104   std::cout << m_profile.instance_name<< ": onActivated(" << ec_id << ")" << std::endl;
00105   return RTC::RTC_OK;
00106 }
00107 
00108 RTC::ReturnCode_t RangeNoiseMixer::onDeactivated(RTC::UniqueId ec_id)
00109 {
00110   std::cout << m_profile.instance_name<< ": onDeactivated(" << ec_id << ")" << std::endl;
00111   return RTC::RTC_OK;
00112 }
00113 
00114 RTC::ReturnCode_t RangeNoiseMixer::onExecute(RTC::UniqueId ec_id)
00115 {
00116   //std::cout << m_profile.instance_name<< ": onExecute(" << ec_id << ")" << std::endl;
00117 
00118   if (m_rangeIn.isNew()){
00119     m_rangeIn.read();
00120 
00121     for (unsigned int i=0; i<m_range.ranges.length(); i++){
00122       if (m_range.ranges[i] != 0){
00123         m_range.ranges[i] += m_maxDist*((2.0*rand())/RAND_MAX-1.0);
00124       }
00125     }
00126 
00127     m_rangeOut.write();
00128   }
00129 
00130   return RTC::RTC_OK;
00131 }
00132 
00133 /*
00134 RTC::ReturnCode_t RangeNoiseMixer::onAborting(RTC::UniqueId ec_id)
00135 {
00136   return RTC::RTC_OK;
00137 }
00138 */
00139 
00140 /*
00141 RTC::ReturnCode_t RangeNoiseMixer::onError(RTC::UniqueId ec_id)
00142 {
00143   return RTC::RTC_OK;
00144 }
00145 */
00146 
00147 /*
00148 RTC::ReturnCode_t RangeNoiseMixer::onReset(RTC::UniqueId ec_id)
00149 {
00150   return RTC::RTC_OK;
00151 }
00152 */
00153 
00154 /*
00155 RTC::ReturnCode_t RangeNoiseMixer::onStateUpdate(RTC::UniqueId ec_id)
00156 {
00157   return RTC::RTC_OK;
00158 }
00159 */
00160 
00161 /*
00162 RTC::ReturnCode_t RangeNoiseMixer::onRateChanged(RTC::UniqueId ec_id)
00163 {
00164   return RTC::RTC_OK;
00165 }
00166 */
00167 
00168 
00169 
00170 extern "C"
00171 {
00172 
00173   void RangeNoiseMixerInit(RTC::Manager* manager)
00174   {
00175     RTC::Properties profile(spec);
00176     manager->registerFactory(profile,
00177                              RTC::Create<RangeNoiseMixer>,
00178                              RTC::Delete<RangeNoiseMixer>);
00179   }
00180 
00181 };
00182 
00183 


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