SampleCrawler.cpp
Go to the documentation of this file.
1 // -*- mode: c++; indent-tabs-mode: t; tab-width: 4; c-basic-offset: 4; -*-
2 /*
3  * Copyright (c) 2008, AIST, the University of Tokyo and General Robotix Inc.
4  * All rights reserved. This program is made available under the terms of the
5  * Eclipse Public License v1.0 which accompanies this distribution, and is
6  * available at http://www.eclipse.org/legal/epl-v10.html
7  * Contributors:
8  * National Institute of Advanced Industrial Science and Technology (AIST)
9  * General Robotix Inc.
10  */
19 #include "SampleCrawler.h"
20 
21 #include <iostream>
22 
23 namespace {
24  const bool CONTROLLER_BRIDGE_DEBUG = false;
25 }
26 
27 
28 // Module specification
29 // <rtc-template block="module_spec">
30 static const char* samplepd_spec[] =
31  {
32  "implementation_id", "SampleCrawler",
33  "type_name", "SampleCrawler",
34  "description", "Sample Crawler component",
35  "version", "0.1",
36  "vendor", "AIST",
37  "category", "Generic",
38  "activity_type", "DataFlowComponent",
39  "max_instance", "10",
40  "language", "C++",
41  "lang_type", "compile",
42  // Configuration variables
43 
44  ""
45  };
46 // </rtc-template>
47 
49  : RTC::DataFlowComponentBase(manager),
50  // <rtc-template block="initializer">
51  m_torqueOut("torque", m_torque),
52 
53  // </rtc-template>
54  dummy(0)
55 {
56  if( CONTROLLER_BRIDGE_DEBUG )
57  {
58  std::cout << "SampleCrawler::SampleCrawler" << std::endl;
59  }
60 
61  // Registration: InPort/OutPort/Service
62  // <rtc-template block="registration">
63 
64  // Set service provider to Ports
65 
66  // Set service consumers to Ports
67 
68  // Set CORBA Service Ports
69 
70  // </rtc-template>
71 }
72 
74 {
75 }
76 
77 
78 RTC::ReturnCode_t SampleCrawler::onInitialize()
79 {
80  // <rtc-template block="bind_config">
81  // Bind variables and configuration variable
82  if( CONTROLLER_BRIDGE_DEBUG )
83  {
84  std::cout << "onInitialize" << std::endl;
85  }
86 
87  // Set InPort buffers
88 
89  // Set OutPort buffer
90  addOutPort("torque", m_torqueOut);
91  // </rtc-template>
92 
93  m_torque.data.length(DOF);
94 
95  return RTC::RTC_OK;
96 }
97 
98 
99 /*
100 RTC::ReturnCode_t SampleCrawler::onFinalize()
101 {
102  return RTC::RTC_OK;
103 }
104 */
105 
106 /*
107 RTC::ReturnCode_t SampleCrawler::onStartup(RTC::UniqueId ec_id)
108 {
109  return RTC::RTC_OK;
110 }
111 */
112 
113 /*
114 RTC::ReturnCode_t SampleCrawler::onShutdown(RTC::UniqueId ec_id)
115 {
116  log("SampleCrawler::onShutdown");
117  return RTC::RTC_OK;
118 }
119 */
120 
122 {
123  std::cout << "onActivated" << std::endl;
124  cnt = 0;
125  return RTC::RTC_OK;
126 }
127 
128 
130 {
131  std::cout << "onDeactivated" << std::endl;
132  return RTC::RTC_OK;
133 }
134 
135 
136 
137 RTC::ReturnCode_t SampleCrawler::onExecute(RTC::UniqueId ec_id)
138 {
139  if (cnt < 500){
140  m_torque.data[0] = m_torque.data[1] = 0.0;
141  }else if (cnt < 1900){
142  m_torque.data[0] = m_torque.data[1] = 1.0;
143  }else if (cnt < 2100){
144  m_torque.data[0] = 1.0; m_torque.data[1] = -1.0;
145  }else{
146  m_torque.data[0] = m_torque.data[1] = -1.0;
147  }
148  m_torqueOut.write();
149  cnt++;
150 
151  return RTC::RTC_OK;
152 }
153 
154 /*
155 RTC::ReturnCode_t SampleCrawler::onAborting(RTC::UniqueId ec_id)
156 {
157  return RTC::RTC_OK;
158 }
159 */
160 
161 /*
162 RTC::ReturnCode_t SampleCrawler::onError(RTC::UniqueId ec_id)
163 {
164  return RTC::RTC_OK;
165 }
166 */
167 
168 /*
169 RTC::ReturnCode_t SampleCrawler::onReset(RTC::UniqueId ec_id)
170 {
171  return RTC::RTC_OK;
172 }
173 */
174 
175 /*
176 RTC::ReturnCode_t SampleCrawler::onStateUpdate(RTC::UniqueId ec_id)
177 {
178  return RTC::RTC_OK;
179 }
180 */
181 
182 /*
183 RTC::ReturnCode_t SampleCrawler::onRateChanged(RTC::UniqueId ec_id)
184 {
185  return RTC::RTC_OK;
186 }
187 */
188 
189 extern "C"
190 {
191 
193  {
195  manager->registerFactory(profile,
196  RTC::Create<SampleCrawler>,
197  RTC::Delete<SampleCrawler>);
198  }
199 
200 };
201 
png_infop png_charpp int png_charpp profile
Definition: png.h:2382
virtual RTC::ReturnCode_t onDeactivated(RTC::UniqueId ec_id)
static const char * samplepd_spec[]
virtual RTC::ReturnCode_t onActivated(RTC::UniqueId ec_id)
OutPort< TimedDoubleSeq > m_torqueOut
bool addOutPort(const char *name, OutPortBase &outport)
#define DOF
virtual RTC::ReturnCode_t onExecute(RTC::UniqueId ec_id)
ExecutionContextHandle_t UniqueId
DLL_EXPORT void SampleCrawlerInit(RTC::Manager *manager)
virtual RTC::ReturnCode_t onInitialize()
virtual bool write(DataType &value)
Sample PD component.
bool registerFactory(coil::Properties &profile, RtcNewFunc new_func, RtcDeleteFunc delete_func)
TimedDoubleSeq m_torque
SampleCrawler(RTC::Manager *manager)
#define DLL_EXPORT


openhrp3
Author(s): AIST, General Robotix Inc., Nakamura Lab of Dept. of Mechano Informatics at University of Tokyo
autogenerated on Sat May 8 2021 02:42:40