Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

workarounds for simulated robots #136

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 25 additions & 2 deletions src/helpers/driver_helpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::string>("getData", "RobotConfig/Body/Type" );
std::string version = p_memory.call<std::string>("getData", "RobotConfig/Body/BaseVersion" );
std::string robot;
try {
robot = p_memory.call<std::string>("getData", "RobotConfig/Body/Type" );
}
catch(const qi::FutureUserException& e) {
robot = p_memory.call<std::string>("getData", "Dialog/RobotModel" );
}
std::string version;
try {
version = p_memory.call<std::string>("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")
Expand Down Expand Up @@ -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<std::string>("getData", "RobotConfig/Body/Type" );
return true;
}
catch(const qi::FutureUserException& e) {
return false;
}
}

} // driver
} // helpers
} // naoqi
2 changes: 2 additions & 0 deletions src/helpers/driver_helpers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions src/naoqi_driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}

Expand Down