19 #include <qi/applicationsession.hpp> 20 #include <qi/anymodule.hpp> 23 #include <boost/program_options.hpp> 28 #if LIBQI_VERSION >= 29 33 int main(
int argc,
char** argv)
35 const std::string no_password =
"no_password";
36 std::string protocol =
"tcp://";
39 qi::ApplicationSession
app(argc, argv);
41 std::vector<std::string> args_out;
44 namespace po = boost::program_options;
45 po::options_description desc(
"Options");
47 (
"help,h",
"print help message")
48 (
"nao_ip", po::value<std::string>(),
"the ip of the robot")
49 (
"nao_port", po::value<int>(),
"the ip of the robot")
50 (
"user,u", po::value<std::string>(),
"the user profile on the robot, nao by default")
51 (
"password,p", po::value<std::string>(),
"the password of the robot")
52 (
"roscore_ip,r", po::value<std::string>(),
"set the ip of the roscore to use")
53 (
"network_interface,i", po::value<std::string>()->default_value(
"eth0"),
"set the network interface over which to connect")
54 (
"namespace,n", po::value<std::string>()->default_value(
"naoqi_driver_node"),
"set an explicit namespace in case ROS namespace variables cannot be used");
59 po::store( po::parse_command_line(argc, argv, desc), vm );
61 catch (boost::program_options::invalid_command_line_syntax& e)
63 std::cout <<
"error " << e.what() << std::endl;
66 catch (boost::program_options::unknown_option& e)
68 std::cout <<
"error 2 " << e.what() << std::endl;
72 if( vm.count(
"help") )
74 std::cout <<
"This is the help message for the ROS-Driver C++ bridge" << std::endl << desc << std::endl;
78 if (vm[
"password"].as<std::string>().compare(no_password) != 0) {
82 factory->
user = vm[
"user"].as<std::string>();
83 factory->
pass = vm[
"password"].as<std::string>();
84 app.session()->setClientAuthenticatorFactory(qi::ClientAuthenticatorFactoryPtr(factory));
87 <<
"No need to set a password" 93 qi::Url url(protocol + vm[
"nao_ip"].as<std::string>() +
":" + std::to_string(vm[
"nao_port"].as<int>()));
94 qi::Future<void> connection = app.session()->connect(url);
96 if (connection.hasError()) {
102 app.session()->registerService(
"ROS-Driver", bs);
105 if ( vm.count(
"roscore_ip") )
107 std::string roscore_ip = vm[
"roscore_ip"].as<std::string>();
108 std::string network_interface = vm[
"network_interface"].as<std::string>();
110 std::cout <<
BOLDYELLOW <<
"using ip address: " 113 bs->setMasterURINet(
"http://"+roscore_ip+
":11311", network_interface);
117 std::cout <<
BOLDRED <<
"No ip address given. Run qicli call to set the master uri" <<
RESETCOLOR << std::endl;
124 app.session()->close();
int main(int argc, char **argv)
ROSCPP_DECL void removeROSArgs(int argc, const char *const *argv, V_string &args_out)