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


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