RobotHardwareComp.cpp
Go to the documentation of this file.
1 // -*- C++ -*-
10 #include <rtm/Manager.h>
11 #include <rtm/ModuleManager.h>
12 #include <iostream>
13 #include <string>
14 #include "RobotHardware.h"
15 
16 
17 void MyModuleInit(RTC::Manager* manager)
18 {
19  RobotHardwareInit(manager);
20  RTC::RtcBase* comp;
21 
22  // Create a component
23  comp = manager->createComponent("RobotHardware");
24 
25 
26  // Example
27  // The following procedure is examples how handle RT-Components.
28  // These should not be in this function.
29 
30  // Get the component's object reference
31  RTC::RTObject_var rtobj;
32  rtobj = RTC::RTObject::_narrow(manager->getPOA()->servant_to_reference(comp));
33 
34  // Get the port list of the component
35  PortServiceList* portlist;
36  portlist = rtobj->get_ports();
37 
38  // getting port profiles
39  std::cout << "Number of Ports: ";
40  std::cout << portlist->length() << std::endl << std::endl;
41  for (CORBA::ULong i(0), n(portlist->length()); i < n; ++i)
42  {
43  PortService_ptr port;
44  port = (*portlist)[i];
45  std::cout << "Port" << i << " (name): ";
46  std::cout << port->get_port_profile()->name << std::endl;
47 
48  RTC::PortInterfaceProfileList iflist;
49  iflist = port->get_port_profile()->interfaces;
50  std::cout << "---interfaces---" << std::endl;
51  for (CORBA::ULong i(0), n(iflist.length()); i < n; ++i)
52  {
53  std::cout << "I/F name: ";
54  std::cout << iflist[i].instance_name << std::endl;
55  std::cout << "I/F type: ";
56  std::cout << iflist[i].type_name << std::endl;
57  const char* pol;
58  pol = iflist[i].polarity == 0 ? "PROVIDED" : "REQUIRED";
59  std::cout << "Polarity: " << pol << std::endl;
60  }
61  std::cout << "---properties---" << std::endl;
62  NVUtil::dump(port->get_port_profile()->properties);
63  std::cout << "----------------" << std::endl << std::endl;
64  }
65 
66  return;
67 }
68 
69 int main (int argc, char** argv)
70 {
72  manager = RTC::Manager::init(argc, argv);
73 
74  // Initialize manager
75  manager->init(argc, argv);
76 
77 #ifndef __APPLE__
78  try{
79  manager->load("libhrpEC.so", "hrpECInit");
80  }catch(RTC::ModuleManager::NotFound& ex){
81  std::cerr << ex.name << std::endl;
82  }catch(RTC::ModuleManager::Error& ex){
83  std::cerr << ex.reason << std::endl;
84  std::cerr << dlerror() << std::endl;
85  }catch(...){
86  std::cerr << "exception in loading libhrpEC.so" << std::endl;
87  }
88 #endif
89 
90  // Set module initialization proceduer
91  // This procedure will be invoked in activateManager() function.
93 
94  // Activate manager and register to naming service
95  manager->activateManager();
96 
97  // run the manager in blocking mode
98  // runManager(false) is the default.
99  manager->runManager();
100 
101  // If you want to run the manager in non-blocking mode, do like this
102  // manager->runManager(true);
103 
104  return 0;
105 }
RTObject_impl * createComponent(const char *comp_args)
PortableServer::POA_ptr getPOA()
void runManager(bool no_block=false)
void load(const char *fname, const char *initfunc)
manager
virtual PortServiceList * get_ports()
png_uint_32 i
int main(int argc, char **argv)
void RobotHardwareInit(RTC::Manager *manager)
static Manager * init(int argc, char **argv)
void MyModuleInit(RTC::Manager *manager)
n
void dump(const SDOPackage::NVList &nv)
bool activateManager()
std::vector< IPortService * > PortServiceList
void setModuleInitProc(ModuleInitProc proc)
robot hardware component


hrpsys
Author(s): AIST, Fumio Kanehiro
autogenerated on Thu May 6 2021 02:41:51