controllerclientcpp  0.6.1
 全て クラス ネームスペース ファイル 関数 変数 型定義 列挙型 列挙型の値 マクロ定義 ページ
mujinimportscene.cpp
説明を見る。
1 // -*- coding: utf-8 -*-
7 
8 #include <iostream>
9 
10 using namespace mujinclient;
11 
12 int main(int argc, char ** argv)
13 {
14  if( argc < 2 ) {
15  std::cout << "need username:password. Example: mujinclienttest myuser:mypass [url]\n\nurl - [optional] For example https://controller.mujin.co.jp/" << std::endl;
16  return 1;
17  }
18  try {
19  ControllerClientPtr controller;
20  if( argc >= 5 ) {
21  controller = CreateControllerClient(argv[1], argv[2], argv[3], argv[4]);
22  }
23  if( argc == 4 ) {
24  controller = CreateControllerClient(argv[1], argv[2], argv[3]);
25  }
26  else if( argc == 3 ) {
27  controller = CreateControllerClient(argv[1], argv[2]);
28  }
29  else {
30  controller = CreateControllerClient(argv[1]);
31  }
32  std::cout << "connected to controller v" << controller->GetVersion() << std::endl;
33 
34  std::string sceneuri = "mujin:/test.mujin.dae";
35  std::string scenepk = controller->GetScenePrimaryKeyFromURI_UTF8(sceneuri);
36 
37  // try to import the scene, if it already exists delete it and import again
38  try {
39  controller->ImportSceneToCOLLADA_UTF8("mujin:/densowave_wincaps_data/vs060a3_test0/test0.WPJ", "wincaps", sceneuri);
40  }
41  catch(const MujinException& ex) {
42  if( ex.message().find("need to remove it first") != std::string::npos ) {
43  std::cout << "file already imported, would you like to delete and re-import? (yes/no) ";
44  std::string answer;
45  std::cin >> answer;
46  if( answer == std::string("yes") ) {
47  std::cout << "try removing the file and importing again" << std::endl;
48  SceneResource oldscene(controller,"test.mujin.dae");
49  oldscene.Delete();
50  controller->ImportSceneToCOLLADA_UTF8("mujin:/densowave_wincaps_data/vs060a3_test0/test0.WPJ", "wincaps", sceneuri);
51  }
52  }
53  else {
54  std::cout << "error importing scene" << ex.message() << std::endl;
55  }
56  }
57 
58  // create the resource and query info
59  SceneResource scene(controller,scenepk);
60  std::vector<SceneResource::InstObjectPtr> instobjects;
61  scene.GetInstObjects(instobjects);
62  std::cout << "scene instance objects: ";
63  for(size_t i = 0; i < instobjects.size(); ++i) {
64  std::cout << instobjects[i]->name << ", ";
65  }
66  std::cout << std::endl;
67  }
68  catch(const MujinException& ex) {
69  std::cout << "exception thrown: " << ex.message() << std::endl;
70  }
71  // destroy all mujin controller resources
73 }