VirtualRobotRTC.h
Go to the documentation of this file.
00001 // -*- C++ -*-
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  */
00016 #ifndef OPENHRP_CONTROLLER_BRIDGE_VIRTUAL_ROBOT_RTC_H_INCLUDED
00017 #define OPENHRP_CONTROLLER_BRIDGE_VIRTUAL_ROBOT_RTC_H_INCLUDED
00018 
00019 #include <set>
00020 #include <string>
00021 #include <rtm/Manager.h>
00022 #include <rtm/DataFlowComponentBase.h>
00023 
00024 #include "VirtualRobotPortHandler.h"
00025 
00026 class Controller_impl;
00027 
00028 class VirtualRobotRTC : public RTC::DataFlowComponentBase
00029 {
00030 public:
00031 
00032     static void registerFactory(RTC::Manager* manager, const char* componentTypeName);
00033 
00034     VirtualRobotRTC(RTC::Manager* manager);
00035     ~VirtualRobotRTC();
00036 
00037     RTC::ReturnCode_t onInitialize();
00038 
00039     PortHandlerPtr getPortHandler(const std::string& name);
00040 
00041     RTC::RTCList* getConnectedRtcs();
00042 
00043     void inputDataFromSimulator(Controller_impl* controller);
00044     void outputDataToSimulator(Controller_impl* controller);
00045 
00046     void writeDataToOutPorts(Controller_impl* controller);
00047     void readDataFromInPorts(Controller_impl* controller);
00048     void stop();
00049     bool checkOutPortStepTime(double controlTimeStep);
00050     bool isOwnedByController;
00051 
00052 private:
00053 
00054     typedef std::map<std::string, OutPortHandlerPtr> OutPortHandlerMap;
00055     OutPortHandlerMap outPortHandlers;
00056 
00057     typedef std::map<std::string, InPortHandlerPtr> InPortHandlerMap;
00058     InPortHandlerMap inPortHandlers;
00059 
00060 
00061 #ifdef OPENRTM_VERSION_042
00062     void createOutPortHandler(PortInfo& portInfo);
00063     void createInPortHandler(PortInfo& portInfo);
00064     template <class TOutPortHandler>
00065     void registerOutPortHandler(TOutPortHandler* handler) {
00066         const std::string& name = handler->portName;
00067         if(!getPortHandler(name)){
00068             registerOutPort(name.c_str(), handler->outPort);
00069             outPortHandlers.insert(std::make_pair(name, OutPortHandlerPtr(handler)));
00070         }
00071     }
00072     template <class TInPortHandler>
00073     void registerInPortHandler(TInPortHandler* handler) {
00074         const std::string& name = handler->portName;
00075         if(!getPortHandler(name)){
00076             registerInPort(name.c_str(), handler->inPort);
00077             inPortHandlers.insert(std::make_pair(name, InPortHandlerPtr(handler)));
00078         }
00079     }
00080 #else
00081     bool createOutPortHandler(PortInfo& portInfo);
00082     bool createInPortHandler(PortInfo& portInfo);
00083     template <class TOutPortHandler>
00084     bool registerOutPortHandler(TOutPortHandler* handler) {
00085         const std::string& name = handler->portName;
00086         if(!getPortHandler(name)){
00087             if (!addOutPort(name.c_str(), handler->outPort)) return false;
00088             outPortHandlers.insert(std::make_pair(name, OutPortHandlerPtr(handler)));
00089         }
00090         return true;
00091     }
00092 
00093     template <class TInPortHandler>
00094     bool registerInPortHandler(TInPortHandler* handler) {
00095         const std::string& name = handler->portName;
00096         if(!getPortHandler(name)){
00097             if (!addInPort(name.c_str(), handler->inPort)) return false;
00098             inPortHandlers.insert(std::make_pair(name, InPortHandlerPtr(handler)));
00099         }
00100         return true;
00101     }
00102 #endif
00103     void updatePortObjectRefs();
00104 
00105     void addConnectedRtcs(Port_Service_Ptr_Type portRef, RTC::RTCList& rtcList, std::set<std::string>& foundRtcNames);
00106 };
00107 
00108 
00109 #endif


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