From 32ccbd4e4060b12062ebe9481271275cfc20bb89 Mon Sep 17 00:00:00 2001 From: Benjamin Navarro Date: Tue, 29 Sep 2020 09:25:35 +0000 Subject: [PATCH] workarounds for simulated robots --- src/helpers/driver_helpers.cpp | 27 +++++++++++++++++++++++++-- src/helpers/driver_helpers.hpp | 2 ++ src/naoqi_driver.cpp | 3 +++ 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/src/helpers/driver_helpers.cpp b/src/helpers/driver_helpers.cpp index 6fd014c8..d99c5748 100644 --- a/src/helpers/driver_helpers.cpp +++ b/src/helpers/driver_helpers.cpp @@ -41,8 +41,20 @@ static naoqi_bridge_msgs::RobotInfo& getRobotInfoLocal( const qi::SessionPtr& se // Get the robot type std::cout << "Receiving information about robot model" << std::endl; qi::AnyObject p_memory = session->service("ALMemory"); - std::string robot = p_memory.call("getData", "RobotConfig/Body/Type" ); - std::string version = p_memory.call("getData", "RobotConfig/Body/BaseVersion" ); + std::string robot; + try { + robot = p_memory.call("getData", "RobotConfig/Body/Type" ); + } + catch(const qi::FutureUserException& e) { + robot = p_memory.call("getData", "Dialog/RobotModel" ); + } + std::string version; + try { + version = p_memory.call("getData", "RobotConfig/Body/BaseVersion" ); + } + catch(const qi::FutureUserException& e) { + version = "unknown"; + } std::transform(robot.begin(), robot.end(), robot.begin(), ::tolower); if (std::string(robot) == "nao") @@ -259,6 +271,17 @@ bool isDepthStereo(const qi::SessionPtr &session) { } } +bool isRealRobot(const qi::SessionPtr &session) { + qi::AnyObject p_memory = session->service("ALMemory"); + try { + p_memory.call("getData", "RobotConfig/Body/Type" ); + return true; + } + catch(const qi::FutureUserException& e) { + return false; + } +} + } // driver } // helpers } // naoqi diff --git a/src/helpers/driver_helpers.hpp b/src/helpers/driver_helpers.hpp index 342c141d..3b247a80 100644 --- a/src/helpers/driver_helpers.hpp +++ b/src/helpers/driver_helpers.hpp @@ -44,6 +44,8 @@ std::string& getLanguage( const qi::SessionPtr& session ); bool isDepthStereo(const qi::SessionPtr &session); +bool isRealRobot(const qi::SessionPtr &session); + } // driver } // helpers } // naoqi diff --git a/src/naoqi_driver.cpp b/src/naoqi_driver.cpp index e25cf5a7..76fa40f0 100644 --- a/src/naoqi_driver.cpp +++ b/src/naoqi_driver.cpp @@ -165,6 +165,9 @@ void Driver::loadBootConfig() if (!file_path.empty()) { boost::property_tree::read_json( file_path, boot_config_ ); + if(!helpers::driver::isRealRobot(sessionPtr_)) { + boot_config_.put("converters.audio.enabled", false); + } } }