Joystick2PanTiltAngles.cpp
Go to the documentation of this file.
1 // -*- C++ -*-
10 #include "hrpsys/util/VectorConvert.h"
11 #include "Joystick2PanTiltAngles.h"
12 
13 // Module specification
14 // <rtc-template block="module_spec">
15 static const char* joystick2velocity_spec[] =
16  {
17  "implementation_id", "Joystick2PanTiltAngles",
18  "type_name", "Joystick2PanTiltAngles",
19  "description", "joystick output to velocity converter",
20  "version", HRPSYS_PACKAGE_VERSION,
21  "vendor", "AIST",
22  "category", "example",
23  "activity_type", "DataFlowComponent",
24  "max_instance", "10",
25  "language", "C++",
26  "lang_type", "compile",
27  // Configuration variables
28  "conf.default.debugLevel", "0",
29  "conf.default.axesIds", "0,1,2",
30  "conf.default.scales", "1.0,1.0,1.0",
31  "conf.default.neutrals", "0.0,0.0,0.0",
32  ""
33  };
34 // </rtc-template>
35 
37  : RTC::DataFlowComponentBase(manager),
38  // <rtc-template block="initializer">
39  m_axesIn("axes", m_axes),
40  m_anglesOut("angles", m_angles),
41  // </rtc-template>
42  dummy(0),
43  m_debugLevel(0)
44 {
45  // Registration: InPort/OutPort/Service
46  // <rtc-template block="registration">
47  // Set InPort buffers
48 
49  // Set OutPort buffer
50 
51  // Set service provider to Ports
52 
53  // Set service consumers to Ports
54 
55  // Set CORBA Service Ports
56 
57  // </rtc-template>
58 }
59 
61 {
62 }
63 
64 
65 
67 {
68  //std::cout << m_profile.instance_name << ": onInitialize()" << std::endl;
69  // <rtc-template block="bind_config">
70  // Bind variables and configuration variable
71  bindParameter("debugLevel", m_debugLevel, "0");
72  bindParameter("axesIds", m_axesIds, "0,1,2");
73  bindParameter("scales", m_scales, "1.0,1.0,1.0");
74  bindParameter("neutrals", m_neutrals, "0.0,0.0,0.0");
75 
76  // </rtc-template>
77  addInPort("axes", m_axesIn);
78  addOutPort("vel", m_anglesOut);
79 
80  m_axes.data.length(4);
81  for (unsigned int i=0; i<m_axes.data.length(); i++){
82  m_axes.data[i] = 0.0;
83  }
84 
85  return RTC::RTC_OK;
86 }
87 
88 
89 
90 /*
91 RTC::ReturnCode_t Joystick2PanTiltAngles::onFinalize()
92 {
93  return RTC::RTC_OK;
94 }
95 */
96 
97 /*
98 RTC::ReturnCode_t Joystick2PanTiltAngles::onStartup(RTC::UniqueId ec_id)
99 {
100  return RTC::RTC_OK;
101 }
102 */
103 
104 /*
105 RTC::ReturnCode_t Joystick2PanTiltAngles::onShutdown(RTC::UniqueId ec_id)
106 {
107  return RTC::RTC_OK;
108 }
109 */
110 
112 {
113  return RTC::RTC_OK;
114 }
115 
117 {
118  return RTC::RTC_OK;
119 }
120 
122 {
123  if (m_debugLevel > 0){
124  std::cout << m_profile.instance_name<< ": onExecute(" << ec_id << ")"
125  << std::endl;
126  }
127 
128  if (m_axesIn.isNew()) m_axesIn.read();
129 
130  m_angles.pan = m_neutrals[0] + m_scales[0]*m_axes.data[m_axesIds[0]];
131  m_angles.tilt = m_neutrals[1] + m_scales[1]*m_axes.data[m_axesIds[1]];
132  if (m_debugLevel > 0) {
133  printf("pan/tilt command: %5.2f %5.2f",
134  m_angles.pan, m_angles.tilt);
135  }
136  m_anglesOut.write();
137 
138  return RTC::RTC_OK;
139 }
140 
141 /*
142 RTC::ReturnCode_t Joystick2PanTiltAngles::onAborting(RTC::UniqueId ec_id)
143 {
144  return RTC::RTC_OK;
145 }
146 */
147 
148 /*
149 RTC::ReturnCode_t Joystick2PanTiltAngles::onError(RTC::UniqueId ec_id)
150 {
151  return RTC::RTC_OK;
152 }
153 */
154 
155 /*
156 RTC::ReturnCode_t Joystick2PanTiltAngles::onReset(RTC::UniqueId ec_id)
157 {
158  return RTC::RTC_OK;
159 }
160 */
161 
162 /*
163 RTC::ReturnCode_t Joystick2PanTiltAngles::onStateUpdate(RTC::UniqueId ec_id)
164 {
165  return RTC::RTC_OK;
166 }
167 */
168 
169 /*
170 RTC::ReturnCode_t Joystick2PanTiltAngles::onRateChanged(RTC::UniqueId ec_id)
171 {
172  return RTC::RTC_OK;
173 }
174 */
175 
176 
177 
178 extern "C"
179 {
180 
182  {
184  manager->registerFactory(profile,
185  RTC::Create<Joystick2PanTiltAngles>,
186  RTC::Delete<Joystick2PanTiltAngles>);
187  }
188 
189 };
190 
191 
ComponentProfile m_profile
png_infop png_charpp int png_charpp profile
joystick out to velocity converter
InPort< TimedFloatSeq > m_axesIn
static const char * joystick2velocity_spec[]
png_uint_32 i
bool addOutPort(const char *name, OutPortBase &outport)
Joystick2PanTiltAngles(RTC::Manager *manager)
Constructor.
virtual ~Joystick2PanTiltAngles()
Destructor.
void Joystick2PanTiltAnglesInit(RTC::Manager *manager)
ExecutionContextHandle_t UniqueId
bool bindParameter(const char *param_name, VarType &var, const char *def_val, bool(*trans)(VarType &, const char *)=coil::stringTo)
std::vector< double > m_scales
std::vector< double > m_neutrals
virtual bool isNew()
virtual bool write(DataType &value)
virtual RTC::ReturnCode_t onInitialize()
std::vector< unsigned int > m_axesIds
bool addInPort(const char *name, InPortBase &inport)
virtual RTC::ReturnCode_t onDeactivated(RTC::UniqueId ec_id)
bool registerFactory(coil::Properties &profile, RtcNewFunc new_func, RtcDeleteFunc delete_func)
virtual RTC::ReturnCode_t onExecute(RTC::UniqueId ec_id)
virtual RTC::ReturnCode_t onActivated(RTC::UniqueId ec_id)
OutPort< PanTiltAngles > m_anglesOut


hrpsys
Author(s): AIST, Fumio Kanehiro
autogenerated on Sat Dec 17 2022 03:52:20