31 static naoqi_bridge_msgs::RobotInfo info;
32 static qi::Url robot_url;
34 if (robot_url == session->url())
39 robot_url = session->url();
42 std::cout <<
"Receiving information about robot model" << std::endl;
43 qi::AnyObject p_memory = session->service(
"ALMemory");
44 std::string robot = p_memory.call<std::string>(
"getData",
"RobotConfig/Body/Type" );
45 std::string version = p_memory.call<std::string>(
"getData",
"RobotConfig/Body/BaseVersion" );
46 std::transform(robot.begin(), robot.end(), robot.begin(), ::tolower);
48 if (std::string(robot) ==
"nao")
55 if (std::string(robot) ==
"pepper" || std::string(robot) ==
"juliette" )
62 if (std::string(robot) ==
"romeo" )
71 qi::AnyObject p_motion = session->service(
"ALMotion");
72 std::vector<std::vector<qi::AnyValue> > config = p_motion.call<std::vector<std::vector<qi::AnyValue> > >(
"getRobotConfig");
76 for (
size_t i=0; i<config[0].size();++i)
78 if (config[0][i].as<std::string>() ==
"Model Type")
81 info.model = config[1][i].as<std::string>();
83 catch(
const std::exception& e)
85 std::cout <<
"Error in robot config variable " << (config[0][i]).as<std::string>() << std::endl;
89 if (config[0][i].as<std::string>() ==
"Head Version")
92 info.head_version = config[1][i].as<std::string>();
94 catch(
const std::exception& e)
96 std::cout <<
"Error in robot config variable " << (config[0][i]).as<std::string>() << std::endl;
100 if (config[0][i].as<std::string>() ==
"Body Version")
103 info.body_version = config[1][i].as<std::string>();
105 catch(
const std::exception& e)
107 std::cout <<
"Error in robot config variable " << (config[0][i]).as<std::string>() << std::endl;
111 if (config[0][i].as<std::string>() ==
"Arm Version")
114 info.arm_version = config[1][i].as<std::string>();
116 catch(
const std::exception& e)
118 std::cout <<
"Error in robot config variable " << (config[0][i]).as<std::string>() << std::endl;
122 if (config[0][i].as<std::string>() ==
"Laser")
125 info.has_laser = config[1][i].as<
bool>();
127 catch(
const std::exception& e)
129 std::cout <<
"Error in robot config variable " << (config[0][i]).as<std::string>() << std::endl;
133 if (config[0][i].as<std::string>() ==
"Extended Arms")
136 info.has_extended_arms = config[1][i].as<
bool>();
138 catch(
const std::exception& e)
140 std::cout <<
"Error in robot config variable " << (config[0][i]).as<std::string>() << std::endl;
144 if (config[0][i].as<std::string>() ==
"Number of Legs")
147 info.number_of_legs = config[1][i].as<
int>();
149 catch(
const std::exception& e)
151 std::cout <<
"Error in robot config variable " << (config[0][i]).as<std::string>() << std::endl;
155 if (config[0][i].as<std::string>() ==
"Number of Arms")
158 info.number_of_arms = config[1][i].as<
int>();
160 catch(
const std::exception& e)
162 std::cout <<
"Error in robot config variable " << (config[0][i]).as<std::string>() << std::endl;
166 if (config[0][i].as<std::string>() ==
"Number of Hands")
169 info.number_of_hands = config[1][i].as<
int>();
171 catch(
const std::exception& e)
173 std::cout <<
"Error in robot config variable " << (config[0][i]).as<std::string>() << std::endl;
201 const naoqi_bridge_msgs::RobotInfo&
getRobotInfo(
const qi::SessionPtr& session )
209 bool&
setLanguage(
const qi::SessionPtr& session, naoqi_bridge_msgs::SetStringRequest req)
212 std::cout <<
"Receiving service call of setting speech language" << std::endl;
214 qi::AnyObject p_text_to_speech = session->service(
"ALTextToSpeech");
215 p_text_to_speech.call<
void>(
"setLanguage", req.data);
219 catch(
const std::exception& e){
229 static std::string language;
230 std::cout <<
"Receiving service call of getting speech language" << std::endl;
231 qi::AnyObject p_text_to_speech = session->service(
"ALTextToSpeech");
232 language = p_text_to_speech.call<std::string>(
"getLanguage");
240 std::vector<std::string> sensor_names;
243 qi::AnyObject p_motion = session->service(
"ALMotion");
244 sensor_names = p_motion.call<std::vector<std::string> >(
"getSensorNames");
246 if (std::find(sensor_names.begin(),
248 "CameraStereo") != sensor_names.end()) {
256 }
catch (
const std::exception &e) {
257 std::cerr << e.what() << std::endl;
const naoqi_bridge_msgs::RobotInfo & getRobotInfo(const qi::SessionPtr &session)
static naoqi_bridge_msgs::RobotInfo & getRobotInfoLocal(const qi::SessionPtr &session)
bool isDepthStereo(const qi::SessionPtr &session)
std::string & getLanguage(const qi::SessionPtr &session)
bool & setLanguage(const qi::SessionPtr &session, naoqi_bridge_msgs::SetStringRequest req)
const robot::Robot & getRobot(const qi::SessionPtr &session)