RobotHardwareComp.cpp
Go to the documentation of this file.
00001 // -*- C++ -*-
00010 #include <rtm/Manager.h>
00011 #include <rtm/ModuleManager.h>
00012 #include <iostream>
00013 #include <string>
00014 #include "RobotHardware.h"
00015 
00016 
00017 void MyModuleInit(RTC::Manager* manager)
00018 {
00019   RobotHardwareInit(manager);
00020   RTC::RtcBase* comp;
00021 
00022   // Create a component
00023   comp = manager->createComponent("RobotHardware");
00024 
00025 
00026   // Example
00027   // The following procedure is examples how handle RT-Components.
00028   // These should not be in this function.
00029 
00030   // Get the component's object reference
00031  RTC::RTObject_var rtobj;
00032  rtobj = RTC::RTObject::_narrow(manager->getPOA()->servant_to_reference(comp));
00033 
00034   // Get the port list of the component
00035  PortServiceList* portlist;
00036  portlist = rtobj->get_ports();
00037 
00038   // getting port profiles
00039  std::cout << "Number of Ports: ";
00040  std::cout << portlist->length() << std::endl << std::endl; 
00041  for (CORBA::ULong i(0), n(portlist->length()); i < n; ++i)
00042  {
00043    PortService_ptr port;
00044    port = (*portlist)[i];
00045    std::cout << "Port" << i << " (name): ";
00046    std::cout << port->get_port_profile()->name << std::endl;
00047    
00048    RTC::PortInterfaceProfileList iflist;
00049    iflist = port->get_port_profile()->interfaces;
00050    std::cout << "---interfaces---" << std::endl;
00051    for (CORBA::ULong i(0), n(iflist.length()); i < n; ++i)
00052    {
00053      std::cout << "I/F name: ";
00054      std::cout << iflist[i].instance_name << std::endl;
00055      std::cout << "I/F type: ";
00056      std::cout << iflist[i].type_name << std::endl;
00057      const char* pol;
00058      pol = iflist[i].polarity == 0 ? "PROVIDED" : "REQUIRED";
00059      std::cout << "Polarity: " << pol << std::endl;
00060    }
00061    std::cout << "---properties---" << std::endl;
00062    NVUtil::dump(port->get_port_profile()->properties);
00063    std::cout << "----------------" << std::endl << std::endl;
00064  }
00065 
00066   return;
00067 }
00068 
00069 int main (int argc, char** argv)
00070 {
00071   RTC::Manager* manager;
00072   manager = RTC::Manager::init(argc, argv);
00073 
00074   // Initialize manager
00075   manager->init(argc, argv);
00076 
00077 #ifndef __APPLE__
00078   try{
00079       manager->load("libhrpEC.so", "hrpECInit");
00080   }catch(RTC::ModuleManager::NotFound& ex){
00081       std::cerr << ex.name << std::endl;
00082   }catch(RTC::ModuleManager::Error& ex){
00083       std::cerr << ex.reason << std::endl;
00084       std::cerr << dlerror() << std::endl;
00085   }catch(...){
00086       std::cerr << "exception in loading libhrpEC.so" << std::endl;
00087   }
00088 #endif
00089 
00090   // Set module initialization proceduer
00091   // This procedure will be invoked in activateManager() function.
00092   manager->setModuleInitProc(MyModuleInit);
00093 
00094   // Activate manager and register to naming service
00095   manager->activateManager();
00096 
00097   // run the manager in blocking mode
00098   // runManager(false) is the default.
00099   manager->runManager();
00100 
00101   // If you want to run the manager in non-blocking mode, do like this
00102   // manager->runManager(true);
00103 
00104   return 0;
00105 }


hrpsys
Author(s): AIST, Fumio Kanehiro
autogenerated on Wed May 15 2019 05:02:18