12 using namespace mujinclient;
14 int main(
int argc,
char ** argv)
17 std::cout <<
"need username:password. Example: mujinclienttest myuser:mypass [url]\n\nurl - [optional] For example https://controller.mujin.co.jp/" << std::endl;
28 else if( argc == 3 ) {
34 std::cout <<
"connected to controller v" << controller->GetVersion() << std::endl;
37 std::vector<std::string> scenekeys;
38 controller->GetScenePrimaryKeys(scenekeys);
40 cout <<
"user has " << scenekeys.size() <<
" scenes: " << endl;
41 for(
size_t i = 0; i < scenekeys.size(); ++i) {
42 cout << scenekeys[i] << endl;
47 if( find(scenekeys.begin(),scenekeys.end(), string(
"YG_LAYOUT")) != scenekeys.end() ) {
51 cout <<
"opening scene " << scenekeys.at(0) << endl;
56 std::vector<std::string> taskkeys;
57 scene->GetTaskPrimaryKeys(taskkeys);
58 if( taskkeys.size() == 0 ) {
59 std::cout <<
"no tasks for this scene" << std::endl;
64 cout <<
"got task " << task->Get(
"name") << endl;
65 cout <<
"program is " << task->Get(
"taskgoalxml") << endl;
70 cout <<
"result for task exists and can be completed in " << result->Get(
"task_time") <<
" seconds." << endl;
74 std::vector<std::string> optimizationkeys;
75 task->GetOptimizationPrimaryKeys(optimizationkeys);
78 cout <<
"found optimization " << optimization->Get(
"name") << endl;
80 std::vector<PlanningResultResourcePtr> results;
81 optimization->GetResults(results,0,10);
82 if( results.size() > 0 ) {
83 cout <<
"the top results have times: ";
84 for(
size_t i = 0; i < results.size(); ++i) {
85 cout << results[i]->Get(
"task_time") <<
", ";
90 bestresult->GetEnvironmentState(envstate);
91 cout <<
"robot position of best result is: ";
92 for(EnvironmentState::iterator it = envstate.begin(); it != envstate.end(); ++it) {
100 result->GetPrograms(programs);
101 std::cout <<
"found " << programs.
programs.size() <<
" programs" << std::endl;
102 for(std::map<std::string, RobotProgramData>::iterator it = programs.
programs.begin(); it != programs.
programs.end(); ++it ) {
103 std::cout <<
"[" << it->first <<
"]" << std::endl << it->second.programdata << std::endl << std::endl;
105 std::cout <<
"final task_time is " << result->Get(
"task_time") << std::endl;
109 std::cout <<
"exception thrown: " << ex.
message() << std::endl;