RangeNoiseMixer.cpp
Go to the documentation of this file.
1 // -*- C++ -*-
10 #include "RangeNoiseMixer.h"
11 
12 // Module specification
13 // <rtc-template block="module_spec">
14 static const char* spec[] =
15  {
16  "implementation_id", "RangeNoiseMixer",
17  "type_name", "RangeNoiseMixer",
18  "description", "noise mixer for range data",
19  "version", HRPSYS_PACKAGE_VERSION,
20  "vendor", "AIST",
21  "category", "example",
22  "activity_type", "DataFlowComponent",
23  "max_instance", "10",
24  "language", "C++",
25  "lang_type", "compile",
26  // Configuration variables
27  "conf.default.maxDist", "0.02",
28 
29  ""
30  };
31 // </rtc-template>
32 
34  : RTC::DataFlowComponentBase(manager),
35  // <rtc-template block="initializer">
36  m_rangeIn("original", m_range),
37  m_rangeOut("mixed", m_range),
38  // </rtc-template>
39  dummy(0)
40 {
41 }
42 
44 {
45 }
46 
47 
48 
49 RTC::ReturnCode_t RangeNoiseMixer::onInitialize()
50 {
51  //std::cout << m_profile.instance_name << ": onInitialize()" << std::endl;
52  // <rtc-template block="bind_config">
53  // Bind variables and configuration variable
54  bindParameter("maxDist", m_maxDist, "0.02");
55 
56  // </rtc-template>
57 
58  // Registration: InPort/OutPort/Service
59  // <rtc-template block="registration">
60  // Set InPort buffers
61  addInPort("original", m_rangeIn);
62 
63  // Set OutPort buffer
64  addOutPort("mixed", m_rangeOut);
65 
66  // Set service provider to Ports
67 
68  // Set service consumers to Ports
69 
70  // Set CORBA Service Ports
71 
72  // </rtc-template>
73 
75 
76  return RTC::RTC_OK;
77 }
78 
79 
80 
81 /*
82 RTC::ReturnCode_t RangeNoiseMixer::onFinalize()
83 {
84  return RTC::RTC_OK;
85 }
86 */
87 
88 /*
89 RTC::ReturnCode_t RangeNoiseMixer::onStartup(RTC::UniqueId ec_id)
90 {
91  return RTC::RTC_OK;
92 }
93 */
94 
95 /*
96 RTC::ReturnCode_t RangeNoiseMixer::onShutdown(RTC::UniqueId ec_id)
97 {
98  return RTC::RTC_OK;
99 }
100 */
101 
103 {
104  std::cout << m_profile.instance_name<< ": onActivated(" << ec_id << ")" << std::endl;
105  return RTC::RTC_OK;
106 }
107 
109 {
110  std::cout << m_profile.instance_name<< ": onDeactivated(" << ec_id << ")" << std::endl;
111  return RTC::RTC_OK;
112 }
113 
115 {
116  //std::cout << m_profile.instance_name<< ": onExecute(" << ec_id << ")" << std::endl;
117 
118  if (m_rangeIn.isNew()){
119  m_rangeIn.read();
120 
121  for (unsigned int i=0; i<m_range.ranges.length(); i++){
122  if (m_range.ranges[i] != 0){
123  m_range.ranges[i] += m_maxDist*((2.0*rand())/RAND_MAX-1.0);
124  }
125  }
126 
127  m_rangeOut.write();
128  }
129 
130  return RTC::RTC_OK;
131 }
132 
133 /*
134 RTC::ReturnCode_t RangeNoiseMixer::onAborting(RTC::UniqueId ec_id)
135 {
136  return RTC::RTC_OK;
137 }
138 */
139 
140 /*
141 RTC::ReturnCode_t RangeNoiseMixer::onError(RTC::UniqueId ec_id)
142 {
143  return RTC::RTC_OK;
144 }
145 */
146 
147 /*
148 RTC::ReturnCode_t RangeNoiseMixer::onReset(RTC::UniqueId ec_id)
149 {
150  return RTC::RTC_OK;
151 }
152 */
153 
154 /*
155 RTC::ReturnCode_t RangeNoiseMixer::onStateUpdate(RTC::UniqueId ec_id)
156 {
157  return RTC::RTC_OK;
158 }
159 */
160 
161 /*
162 RTC::ReturnCode_t RangeNoiseMixer::onRateChanged(RTC::UniqueId ec_id)
163 {
164  return RTC::RTC_OK;
165 }
166 */
167 
168 
169 
170 extern "C"
171 {
172 
174  {
176  manager->registerFactory(profile,
177  RTC::Create<RangeNoiseMixer>,
178  RTC::Delete<RangeNoiseMixer>);
179  }
180 
181 };
182 
183 
ComponentProfile m_profile
png_infop png_charpp int png_charpp profile
noise mixer for range data
virtual RTC::ReturnCode_t onActivated(RTC::UniqueId ec_id)
static const char * spec[]
png_uint_32 i
coil::Properties & getProperties()
bool addOutPort(const char *name, OutPortBase &outport)
virtual ~RangeNoiseMixer()
Destructor.
ExecutionContextHandle_t UniqueId
bool bindParameter(const char *param_name, VarType &var, const char *def_val, bool(*trans)(VarType &, const char *)=coil::stringTo)
virtual RTC::ReturnCode_t onInitialize()
virtual RTC::ReturnCode_t onExecute(RTC::UniqueId ec_id)
prop
virtual bool isNew()
virtual bool write(DataType &value)
RangeNoiseMixer(RTC::Manager *manager)
Constructor.
bool addInPort(const char *name, InPortBase &inport)
bool registerFactory(coil::Properties &profile, RtcNewFunc new_func, RtcDeleteFunc delete_func)
virtual RTC::ReturnCode_t onDeactivated(RTC::UniqueId ec_id)
InPort< RangeData > m_rangeIn
void RangeNoiseMixerInit(RTC::Manager *manager)
OutPort< RangeData > m_rangeOut


hrpsys
Author(s): AIST, Fumio Kanehiro
autogenerated on Thu May 6 2021 02:41:50