Controller_impl.h
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  */
16 #ifndef OPENHRP_CONTROLLER_BRIDGE_CONTROLLER_IMPL_H_INCLUDED
17 #define OPENHRP_CONTROLLER_BRIDGE_CONTROLLER_IMPL_H_INCLUDED
18 
19 #include <string>
20 #include <map>
21 #include <rtm/RTC.h>
22 #include <rtm/RTObject.h>
23 #include <rtm/CorbaNaming.h>
24 #include <rtm/idl/RTCStub.h>
25 
26 #include <hrpCorba/Controller.hh>
27 #include <hrpCorba/ViewSimulator.hh>
28 #include <hrpCorba/DynamicsSimulator.hh>
29 
30 #include "BridgeConf.h"
31 
32 #include "config.h"
33 
34 using namespace OpenHRP;
35 
36 class BridgeConf;
37 class VirtualRobotRTC;
38 
40  : virtual public POA_OpenHRP::Controller
41 {
42 public:
43  Controller_impl(RTC::Manager* rtcManager, BridgeConf* bridgeConf);
44  ~Controller_impl();
45 
46  SensorState& getCurrentSensorState();
47  DblSequence* getLinkDataFromSimulator
48  (const std::string& linkName, DynamicsSimulator::LinkDataType linkDataType);
49  DblSequence* getSensorDataFromSimulator(const std::string& sensorName);
50  ImageData* getCameraImageFromSimulator(int cameraId);
51  DblSequence& getJointDataSeqRef(DynamicsSimulator::LinkDataType linkDataType);
52  void flushJointDataSeqToSimulator(DynamicsSimulator::LinkDataType linkDataType);
53  void flushLinkDataToSimulator(const std::string& linkName,
54  DynamicsSimulator::LinkDataType linkDataType,
55  const DblSequence& linkData);
56 
57  virtual void setDynamicsSimulator(DynamicsSimulator_ptr dynamicsSimulator);
58  virtual void setViewSimulator(ViewSimulator_ptr viewSimulator);
59  void setTimeStep(CORBA::Double _timeStep){
60  timeStep = _timeStep;
61  }
62  double getTimeStep(){
63  return timeStep;
64  }
65 
66  virtual void start();
67  virtual void control();
68  virtual void input();
69  virtual void output();
70  virtual void stop();
71  virtual void destroy();
72 
73  virtual void shutdown();
74  virtual omniObjRef* _do_get_interface(){return _this();}
75  virtual void setModelName(const char* localModelName){ modelName = localModelName;}
76  virtual void initialize();
77  double controlTime;
78 
79 private:
82 
83  std::string modelName;
85 
86  typedef std::map<std::string, Port_Service_Var_Type> PortMap;
87 
88  struct RtcInfo
89  {
90  RTC::RTObject_var rtcRef;
91  PortMap portMap;
93  double timeRate;
95  };
96  typedef boost::shared_ptr<RtcInfo> RtcInfoPtr;
97 
98  typedef std::map<std::string, RtcInfoPtr> RtcInfoMap;
99  RtcInfoMap rtcInfoMap;
100  typedef std::vector<RtcInfoPtr> RtcInfoVector;
101  RtcInfoVector rtcInfoVector;
102 
104 
105  DynamicsSimulator_var dynamicsSimulator;
106  ViewSimulator_var viewSimulator;
107 
108  SensorState_var sensorState;
110 
112  bool flushed;
113  DblSequence values;
114  };
115 
116  typedef std::map<DynamicsSimulator::LinkDataType, JointValueSeqInfo> JointValueSeqInfoMap;
117  JointValueSeqInfoMap outputJointValueSeqInfos;
118 
119  CameraSequence_var cameras;
120  Camera::CameraParameter_var cparam;
121 
122  void detectRtcs();
123  void makePortMap(RtcInfoPtr& rtcInfo);
124  Controller_impl::RtcInfoPtr addRtcVectorWithConnection(RTC::RTObject_var rtcRef);
125  void setupRtcConnections();
126  int connectPorts(Port_Service_Ptr_Type outPort, Port_Service_Ptr_Type inPort);
127 
128  void activeComponents();
129  void deactiveComponents();
130  void disconnectRtcConnections(PortMap& refPortMap);
131  double timeStep;
132  bool bRestart;
133  void restart();
134 };
135 
136 #endif
virtual omniObjRef * _do_get_interface()
Camera::CameraParameter_var cparam
VirtualRobotRTC * virtualRobotRTC
std::map< DynamicsSimulator::LinkDataType, JointValueSeqInfo > JointValueSeqInfoMap
OpenRTM::ExtTrigExecutionContextService_var ExtTrigExecutionContextService_Var_Type
RTC::RTObject_var rtcRef
RTC::Manager * rtcManager
boost::shared_ptr< RtcInfo > RtcInfoPtr
std::string modelName
RtcInfoMap rtcInfoMap
std::vector< RtcInfoPtr > RtcInfoVector
JointValueSeqInfoMap outputJointValueSeqInfos
DynamicsSimulator_var dynamicsSimulator
virtual void setModelName(const char *localModelName)
BridgeConf * bridgeConf
RTC::CorbaNaming * naming
CameraSequence_var cameras
local int destroy(gz_stream *s)
Definition: gzio.c:355
png_size_t start
Definition: png.h:1496
ExtTrigExecutionContextService_Var_Type execContext
std::map< std::string, RtcInfoPtr > RtcInfoMap
RtcInfoVector rtcInfoVector
RTC::PortService_ptr Port_Service_Ptr_Type
double getTimeStep()
std::map< std::string, Port_Service_Var_Type > PortMap
void setTimeStep(CORBA::Double _timeStep)
ViewSimulator_var viewSimulator
SensorState_var sensorState
output(gif_dest_ptr dinfo, int code)
Definition: wrgif.c:105


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