10 #include <boost/foreach.hpp> 11 #include <boost/tokenizer.hpp> 28 int main(
int argc,
char* argv[])
30 CORBA::ORB_var orb = CORBA::ORB::_nil();
34 orb = CORBA::ORB_init(argc, argv);
36 CORBA::Object_var
obj;
38 obj = orb->resolve_initial_references(
"RootPOA");
39 PortableServer::POA_var poa = PortableServer::POA::_narrow(obj);
40 if(CORBA::is_nil(poa))
42 throw string(
"error: failed to narrow root POA.");
45 PortableServer::POAManager_var poaManager = poa->the_POAManager();
46 if(CORBA::is_nil(poaManager))
48 throw string(
"error: failed to narrow root POA manager.");
51 std::string inFileName, outFileName;
53 std::list<ManipulatorInfo> listmanipulators;
56 for(
int i=0;
i<(argc-1); ++
i)
58 if((strlen(argv[
i]) > 1) && (argv[
i][0] ==
'-'))
62 inFileName = std::string(argv[++i]);
64 else if(argv[i][1] ==
'o')
65 outFileName = std::string(argv[++i]);
67 else if(argv[i][1] ==
'a')
69 std::string armProfStr = std::string(argv[++i]);
70 std::vector<std::string> armVec;
71 boost::char_separator<char> sep1(
",");
72 boost::tokenizer< boost::char_separator<char> > armTolkens(armProfStr, sep1);
74 BOOST_FOREACH(std::string
t, armTolkens)
80 boost::tokenizer< boost::char_separator<char> >::iterator
81 armiter(armTolkens.begin());
82 tmpinfo.
name = *(armiter++);
83 std::cout <<
"tmpinfo.name = " << tmpinfo.
name <<
"\n";
85 std::cout <<
"tmpinfo.basename = " << tmpinfo.
basename <<
"\n";
87 std::cout <<
"tmpinfo.effectorname = " << tmpinfo.
effectorname << std::endl;
89 tmpinfo.
translation[0] = boost::lexical_cast<
double>(*(armiter++));
90 tmpinfo.
translation[1] = boost::lexical_cast<
double>(*(armiter++));
91 tmpinfo.
translation[2] = boost::lexical_cast<
double>(*(armiter++));
92 tmpinfo.
rotation[0] = boost::lexical_cast<
double>(*(armiter++));
93 tmpinfo.
rotation[1] = boost::lexical_cast<
double>(*(armiter++));
94 tmpinfo.
rotation[2] = boost::lexical_cast<
double>(*(armiter++));
95 tmpinfo.
rotation[3] = boost::lexical_cast<
double>(*(armiter++));
97 std::cout <<
"tmpinfo.rotation = " << tmpinfo.
rotation[0] <<
", " << tmpinfo.
rotation[1] <<
", " << tmpinfo.
rotation[2] <<
", " << tmpinfo.
rotation[3] << std::endl;
99 for(
int i=0; armiter != armTolkens.end(); ++
i,++armiter)
104 std::cout <<
"tmpinfo.gripperdir = " << *armiter;
109 std::cout <<
"tmpinfo.grippernames = " << *armiter;
111 std::cout << std::endl;
113 listmanipulators.push_back(tmpinfo);
120 if((inFileName !=
"") && (outFileName !=
""))
126 std::stringstream sstm;
127 for (
int i = 0;
i < argc;
i++)sstm << argv[
i] <<
" ";
131 cW.Save(outFileName);
132 std::cout << argv[0] <<
" " << inFileName <<
" was successfully exported to " << outFileName << std::endl;
136 std::cerr <<
"Usage: " << argv[0] <<
" " 137 <<
"-i <inFileName> " <<
"-o <outFileName> " 138 <<
"-a <manipulator_name>,<frame_origin>,<frame_tip>,<px>,<py>,<pz>,<rotX>,<rotY>,<rotZ>,<rotTheta[rad]>,<gripper_joint>,<closing_direction>...\n see http://openrave.org/docs/latest_stable/collada_robot_extensions/" 143 catch (CORBA::SystemException& ex)
145 cerr << ex._rep_id() << endl;
147 catch (
const string&
error)
149 cerr << error << endl;
int main(int argc, char *argv[])
virtual bool Write(BodyInfo_impl *bodyInfo)
std::list< std::string > grippernames
void error(char *msg) const
std::list< std::string > gripperdir
void loadModelFile(const std::string &filename)
This function loads a model file and creates a BodyInfo object.