SampleCrawler.cpp
Go to the documentation of this file.
00001 // -*- mode: c++; indent-tabs-mode: t; tab-width: 4; c-basic-offset: 4; -*-
00002 /*
00003  * Copyright (c) 2008, AIST, the University of Tokyo and General Robotix Inc.
00004  * All rights reserved. This program is made available under the terms of the
00005  * Eclipse Public License v1.0 which accompanies this distribution, and is
00006  * available at http://www.eclipse.org/legal/epl-v10.html
00007  * Contributors:
00008  * National Institute of Advanced Industrial Science and Technology (AIST)
00009  * General Robotix Inc. 
00010  */
00019 #include "SampleCrawler.h"
00020 
00021 #include <iostream>
00022 
00023 namespace {
00024   const bool CONTROLLER_BRIDGE_DEBUG = false;
00025 }
00026 
00027 
00028 // Module specification
00029 // <rtc-template block="module_spec">
00030 static const char* samplepd_spec[] =
00031   {
00032     "implementation_id", "SampleCrawler",
00033     "type_name",         "SampleCrawler",
00034     "description",       "Sample Crawler component",
00035     "version",           "0.1",
00036     "vendor",            "AIST",
00037     "category",          "Generic",
00038     "activity_type",     "DataFlowComponent",
00039     "max_instance",      "10",
00040     "language",          "C++",
00041     "lang_type",         "compile",
00042     // Configuration variables
00043 
00044     ""
00045   };
00046 // </rtc-template>
00047 
00048 SampleCrawler::SampleCrawler(RTC::Manager* manager)
00049   : RTC::DataFlowComponentBase(manager),
00050     // <rtc-template block="initializer">
00051     m_torqueOut("torque", m_torque),
00052     
00053     // </rtc-template>
00054     dummy(0)
00055 {
00056   if( CONTROLLER_BRIDGE_DEBUG )
00057   {
00058     std::cout << "SampleCrawler::SampleCrawler" << std::endl;
00059   }
00060 
00061   // Registration: InPort/OutPort/Service
00062   // <rtc-template block="registration">
00063   
00064   // Set service provider to Ports
00065   
00066   // Set service consumers to Ports
00067   
00068   // Set CORBA Service Ports
00069   
00070   // </rtc-template>
00071 }
00072 
00073 SampleCrawler::~SampleCrawler()
00074 {
00075 }
00076 
00077 
00078 RTC::ReturnCode_t SampleCrawler::onInitialize()
00079 {
00080   // <rtc-template block="bind_config">
00081   // Bind variables and configuration variable
00082   if( CONTROLLER_BRIDGE_DEBUG )
00083   {
00084     std::cout << "onInitialize" << std::endl;
00085   }
00086 
00087   // Set InPort buffers
00088   
00089   // Set OutPort buffer
00090   addOutPort("torque", m_torqueOut);
00091   // </rtc-template>
00092 
00093   m_torque.data.length(DOF);
00094 
00095   return RTC::RTC_OK;
00096 }
00097 
00098 
00099 /*
00100 RTC::ReturnCode_t SampleCrawler::onFinalize()
00101 {
00102   return RTC::RTC_OK;
00103 }
00104 */
00105 
00106 /*
00107 RTC::ReturnCode_t SampleCrawler::onStartup(RTC::UniqueId ec_id)
00108 {
00109   return RTC::RTC_OK;
00110 }
00111 */
00112 
00113 /*
00114 RTC::ReturnCode_t SampleCrawler::onShutdown(RTC::UniqueId ec_id)
00115 {
00116     log("SampleCrawler::onShutdown");
00117   return RTC::RTC_OK;
00118 }
00119 */
00120 
00121 RTC::ReturnCode_t SampleCrawler::onActivated(RTC::UniqueId ec_id)
00122 {
00123   std::cout << "onActivated" << std::endl;
00124   cnt = 0;
00125   return RTC::RTC_OK;
00126 }
00127 
00128 
00129 RTC::ReturnCode_t SampleCrawler::onDeactivated(RTC::UniqueId ec_id)
00130 {
00131   std::cout << "onDeactivated" << std::endl;
00132   return RTC::RTC_OK;
00133 }
00134 
00135 
00136 
00137 RTC::ReturnCode_t SampleCrawler::onExecute(RTC::UniqueId ec_id)
00138 {
00139   if (cnt < 500){
00140     m_torque.data[0] = m_torque.data[1] = 0.0;  
00141   }else if (cnt < 1900){
00142     m_torque.data[0] = m_torque.data[1] = 1.0;  
00143   }else if (cnt < 2100){
00144     m_torque.data[0] = 1.0; m_torque.data[1] = -1.0;    
00145   }else{
00146     m_torque.data[0] = m_torque.data[1] = -1.0; 
00147   }
00148   m_torqueOut.write();
00149   cnt++;
00150   
00151   return RTC::RTC_OK;
00152 }
00153 
00154 /*
00155 RTC::ReturnCode_t SampleCrawler::onAborting(RTC::UniqueId ec_id)
00156 {
00157     return RTC::RTC_OK;
00158 }
00159 */
00160 
00161 /*
00162 RTC::ReturnCode_t SampleCrawler::onError(RTC::UniqueId ec_id)
00163 {
00164     return RTC::RTC_OK;
00165 }
00166 */
00167 
00168 /*
00169 RTC::ReturnCode_t SampleCrawler::onReset(RTC::UniqueId ec_id)
00170 {
00171     return RTC::RTC_OK;
00172 }
00173 */
00174 
00175 /*
00176 RTC::ReturnCode_t SampleCrawler::onStateUpdate(RTC::UniqueId ec_id)
00177 {
00178     return RTC::RTC_OK;
00179 }
00180 */
00181 
00182 /*
00183 RTC::ReturnCode_t SampleCrawler::onRateChanged(RTC::UniqueId ec_id)
00184 {
00185     return RTC::RTC_OK;
00186 }
00187 */
00188 
00189 extern "C"
00190 {
00191 
00192   DLL_EXPORT void SampleCrawlerInit(RTC::Manager* manager)
00193   {
00194     coil::Properties profile(samplepd_spec);
00195     manager->registerFactory(profile,
00196                              RTC::Create<SampleCrawler>,
00197                              RTC::Delete<SampleCrawler>);
00198   }
00199 
00200 };
00201 


openhrp3
Author(s): AIST, General Robotix Inc., Nakamura Lab of Dept. of Mechano Informatics at University of Tokyo
autogenerated on Sun Apr 2 2017 03:43:56