rtcsh.cpp
Go to the documentation of this file.
1 // -*- C++ -*-
19 #include <iostream>
20 #include <boost/regex.hpp>
21 #include <boost/tokenizer.hpp>
22 #include <vector>
23 #include <string>
24 #include <rtm/RtcNaming.h>
25 #include <rtm/RtcConfig.h>
26 #include <rtm/RtcManager.h>
27 
28 using namespace RTM;
29 using namespace std;
30 
31 
32 int main(int argc, char** argv)
33 {
34  RtcConfig config(argc, argv);
35  RtcNaming naming;
36  CORBA::ORB_var orb;
37 
38  char** _argv = config.getOrbInitArgv();
39  int _argc = config.getOrbInitArgc();
40 
41  try {
42  orb = CORBA::ORB_init(_argc, _argv);
43  cout << "ORB init done" << endl;
44  }
45  catch (...) {
46  cout << "error cought" << endl;
47  }
48 
49  naming.initNaming(orb);
50  cout << "Naming init done" << endl;
51 
52  string mgrname(".*/.*/Manager.*");
53  vector<CORBA::Object_ptr> vObj;
54  naming.findManager(mgrname, vObj);
55 
56  cout << "Number of objects:" << vObj.size() << endl;
57 
58  if (vObj.size() == 0) {
59  cout << "Manager could not find." << endl;
60  return -1;
61  }
62 
63  CORBA::Object_ptr obj = *(vObj.end()-1);
64  if (CORBA::is_nil(obj)) {
65  cout << "manager not found" << endl;
66  return 0;
67  }
68 
69  RTM::RTCManager_var mgr = RTM::RTCManager::_narrow(obj);
70  if (CORBA::is_nil(mgr)) {
71  cout << "manager not found" << endl;
72  return 0;
73  }
74 
75  char* retval;
76 
77  string cmd;
78  while (1) {
79  cout << ">> ";
80  getline(cin, cmd);
81 
82  // retval = NULL;
83  if (cmd.size() > 0 && !CORBA::is_nil(mgr)) {
84  bool ret = mgr->command(cmd.c_str(), retval);
85 
86  if (ret == true) {
87  // cout << "Success: " << endl;
88  cout << "Success: " << retval << endl;
89  // CORBA::string_free(retval);
90  } else {
91  cout << "Error" << endl;
92  }
93  }
94  }
95  return 0;
96 }
RTC::ReturnCode_t ret(RTC::Local::ReturnCode_t r)
list cmd
Definition: omniwxs.py:88
int main(int argc, char **argv)
Definition: rtcsh.cpp:32
RT-Middleware.
Definition: Manager.h:38


openrtm_aist
Author(s): Noriaki Ando
autogenerated on Mon Jun 10 2019 14:07:54