VirtualRobotRTC.h
Go to the documentation of this file.
1 // -*- C++ -*-
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  */
16 #ifndef OPENHRP_CONTROLLER_BRIDGE_VIRTUAL_ROBOT_RTC_H_INCLUDED
17 #define OPENHRP_CONTROLLER_BRIDGE_VIRTUAL_ROBOT_RTC_H_INCLUDED
18 
19 #include <set>
20 #include <string>
21 #include <rtm/Manager.h>
22 #include <rtm/DataFlowComponentBase.h>
23 
25 
26 class Controller_impl;
27 
29 {
30 public:
31 
32  static void registerFactory(RTC::Manager* manager, const char* componentTypeName);
33 
34  VirtualRobotRTC(RTC::Manager* manager);
36 
37  RTC::ReturnCode_t onInitialize();
38 
39  PortHandlerPtr getPortHandler(const std::string& name);
40 
41  RTC::RTCList* getConnectedRtcs();
42 
43  void inputDataFromSimulator(Controller_impl* controller);
44  void outputDataToSimulator(Controller_impl* controller);
45 
46  void writeDataToOutPorts(Controller_impl* controller);
47  void readDataFromInPorts(Controller_impl* controller);
48  void stop();
49  bool checkOutPortStepTime(double controlTimeStep);
51 
52 private:
53 
54  typedef std::map<std::string, OutPortHandlerPtr> OutPortHandlerMap;
55  OutPortHandlerMap outPortHandlers;
56 
57  typedef std::map<std::string, InPortHandlerPtr> InPortHandlerMap;
58  InPortHandlerMap inPortHandlers;
59 
60 
61 #ifdef OPENRTM_VERSION_042
62  void createOutPortHandler(PortInfo& portInfo);
63  void createInPortHandler(PortInfo& portInfo);
64  template <class TOutPortHandler>
65  void registerOutPortHandler(TOutPortHandler* handler) {
66  const std::string& name = handler->portName;
67  if(!getPortHandler(name)){
68  registerOutPort(name.c_str(), handler->outPort);
69  outPortHandlers.insert(std::make_pair(name, OutPortHandlerPtr(handler)));
70  }
71  }
72  template <class TInPortHandler>
73  void registerInPortHandler(TInPortHandler* handler) {
74  const std::string& name = handler->portName;
75  if(!getPortHandler(name)){
76  registerInPort(name.c_str(), handler->inPort);
77  inPortHandlers.insert(std::make_pair(name, InPortHandlerPtr(handler)));
78  }
79  }
80 #else
81  bool createOutPortHandler(PortInfo& portInfo);
82  bool createInPortHandler(PortInfo& portInfo);
83  template <class TOutPortHandler>
84  bool registerOutPortHandler(TOutPortHandler* handler) {
85  const std::string& name = handler->portName;
86  if(!getPortHandler(name)){
87  if (!addOutPort(name.c_str(), handler->outPort)) return false;
88  outPortHandlers.insert(std::make_pair(name, OutPortHandlerPtr(handler)));
89  }
90  return true;
91  }
92 
93  template <class TInPortHandler>
94  bool registerInPortHandler(TInPortHandler* handler) {
95  const std::string& name = handler->portName;
96  if(!getPortHandler(name)){
97  if (!addInPort(name.c_str(), handler->inPort)) return false;
98  inPortHandlers.insert(std::make_pair(name, InPortHandlerPtr(handler)));
99  }
100  return true;
101  }
102 #endif
103  void updatePortObjectRefs();
104 
105  void addConnectedRtcs(Port_Service_Ptr_Type portRef, RTC::RTCList& rtcList, std::set<std::string>& foundRtcNames);
106 };
107 
108 
109 #endif
bool createInPortHandler(PortInfo &portInfo)
std::map< std::string, OutPortHandlerPtr > OutPortHandlerMap
void readDataFromInPorts(Controller_impl *controller)
void writeDataToOutPorts(Controller_impl *controller)
void outputDataToSimulator(Controller_impl *controller)
void addConnectedRtcs(Port_Service_Ptr_Type portRef, RTC::RTCList &rtcList, std::set< std::string > &foundRtcNames)
boost::shared_ptr< InPortHandler > InPortHandlerPtr
PortHandlerPtr getPortHandler(const std::string &name)
png_infop png_charpp name
Definition: png.h:2382
manager
std::map< std::string, InPortHandlerPtr > InPortHandlerMap
boost::shared_ptr< OutPortHandler > OutPortHandlerPtr
VirtualRobotRTC(RTC::Manager *manager)
bool addOutPort(const char *name, OutPortBase &outport)
boost::shared_ptr< PortHandler > PortHandlerPtr
void inputDataFromSimulator(Controller_impl *controller)
bool checkOutPortStepTime(double controlTimeStep)
InPortHandlerMap inPortHandlers
void registerInPort(const char *name, InPortBase &inport)
static void registerFactory(RTC::Manager *manager, const char *componentTypeName)
RTC::RTCList * getConnectedRtcs()
RTC::PortService_ptr Port_Service_Ptr_Type
bool registerInPortHandler(TInPortHandler *handler)
bool addInPort(const char *name, InPortBase &inport)
void registerOutPort(const char *name, OutPortBase &outport)
bool registerOutPortHandler(TOutPortHandler *handler)
OutPortHandlerMap outPortHandlers
RTC::ReturnCode_t onInitialize()
bool createOutPortHandler(PortInfo &portInfo)


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:41