Skip to content
Snippets Groups Projects
Commit 6ffb7583 authored by Nikolaus Vahrenkamp's avatar Nikolaus Vahrenkamp
Browse files

Added method to RobotStateComponent that allows to get all dependent ArmarXPackages.

Updated RobotState gui plugin in order to search loacl robot in data paths of all dependent ArmarXPackages
parent 05381979
No related branches found
No related tags found
No related merge requests found
......@@ -31,6 +31,7 @@
#include <Core/core/system/ArmarXDataPath.h>
#include <Core/core/ArmarXManager.h>
#include <Core/core/ArmarXObjectScheduler.h>
#include <Core/core/application/Application.h>
using namespace std;
using namespace VirtualRobot;
......@@ -182,7 +183,23 @@ namespace armarx
std::string RobotStateComponent::getRobotFilename(const Ice::Current&) const
{
return relativeRobotFile;
}
}
std::vector<string> RobotStateComponent::getArmarXPackages(const Current &) const
{
std::vector<string> result;
auto packages = armarx::Application::GetProjectDependencies();
packages.push_back(Application::GetProjectName());
for(const std::string &projectName : packages)
{
if(projectName.empty())
continue;
result.push_back(projectName);
}
return result;
}
void RobotStateComponent::reportControlModeChanged(const NameControlModeMap& jointModes, bool aValueChanged,const Current& c){}
void RobotStateComponent::reportJointVelocities(const NameValueMap& jointVelocities, bool aValueChanged,const Current& c)
......
......@@ -92,6 +92,12 @@ namespace armarx
*/
virtual std::string getRobotFilename(const Ice::Current&) const;
/*!
* \brief getArmarXPackages
* \return All dependent packages, which might contain a robot file.
*/
virtual std::vector< std::string > getArmarXPackages(const Ice::Current&) const;
/**
*
* \return The name of this robot instance.
......
......@@ -6,6 +6,8 @@
#include <Core/core/system/ArmarXDataPath.h>
#include <Core/core/ArmarXObjectScheduler.h>
#include <Core/core/ArmarXManager.h>
#include <Core/core/system/cmake/CMakePackageFinder.h>
#include <Core/core/application/Application.h>
#include <VirtualRobot/XML/RobotIO.h>
......@@ -108,10 +110,40 @@ void RobotViewerWidgetController::onConnectComponent()
robotVisu->removeAllChildren();
robot.reset();
std::string rfile;
StringList includePaths;
// get robot filename
try {
std::string rfile = robotStateComponentPrx->getRobotFilename();
StringList packages = robotStateComponentPrx->getArmarXPackages();
packages.push_back(Application::GetProjectName());
ARMARX_VERBOSE << "ArmarX packages " << packages;
for(const std::string &projectName : packages)
{
if(projectName.empty())
continue;
CMakePackageFinder project(projectName);
StringList projectIncludePaths;
auto pathsString = project.getDataDir();
boost::split(projectIncludePaths,
pathsString,
boost::is_any_of(";,"),
boost::token_compress_on);
includePaths.insert(includePaths.end(), projectIncludePaths.begin(), projectIncludePaths.end());
}
rfile = robotStateComponentPrx->getRobotFilename();
ARMARX_VERBOSE << "Relative robot file " << rfile;
ArmarXDataPath::getAbsolutePath(rfile, rfile, includePaths);
ARMARX_VERBOSE << "Absolute robot file " << rfile;
} catch (...)
{
ARMARX_ERROR << "Unable to retrieve robot filename";
}
try {
ARMARX_INFO << "Loading robot from file " << rfile;
robot = loadRobotFile(rfile);
} catch (...)
{
......
......@@ -143,6 +143,13 @@ module armarx
string getRobotFilename();
/**
* @return All dependent packages, which might contain a robot file.
*/
["cpp:const"]
idempotent
StringList getArmarXPackages();
/**
* @return The name of the robot represented by this component. Same as
* getSynchronizedRobot()->getName()
*
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment