25#include <SimoxUtility/algorithm/string/string_tools.h>
26#include <VirtualRobot/Robot.h>
27#include <VirtualRobot/RobotNodeSet.h>
28#include <VirtualRobot/VirtualRobotException.h>
29#include <VirtualRobot/XML/RobotIO.h>
43 "Robot file name, e.g. robot_model.xml");
46 "Project in which the robot filename is located "
47 "(if robot is loaded from an external project)");
52 "Override robot name if you want to load multiple robots of the same type");
56 "Robot node set name as defined in robot xml file, e.g. 'LeftArm'");
60 "Name of the platform needs to correspond to a node in the virtual robot.");
63 "Enable or disable the platform and localization units.");
66 "Name of the platform instance (will publish "
67 "values on PlatformInstanceName + 'State')");
73 return _arePlatformAndLocalizationUnitsEnabled;
81 << __FUNCTION__ <<
" should only be called after _initVirtualRobot was called";
82 return robotPlatformName;
88 return robotPlatformInstanceName;
96 << __FUNCTION__ <<
" should only be called after _initVirtualRobot was called";
97 return robotNodeSetName;
105 << __FUNCTION__ <<
" should only be called after _initVirtualRobot was called";
106 return robotProjectName;
114 << __FUNCTION__ <<
" should only be called after _initVirtualRobot was called";
115 return robotFileName;
122 std::lock_guard<std::mutex> guard{robotMutex};
124 << __FUNCTION__ <<
" should only be called after _initVirtualRobot was called";
125 return robot->getName();
132 std::lock_guard<std::mutex> guard{robotMutex};
134 << __FUNCTION__ <<
" should only be called after _initVirtualRobot was called";
137 clone->setUpdateVisualization(
false);
138 clone->setUpdateCollisionModel(updateCollisionModel);
143 RobotData::_initVirtualRobot()
146 std::lock_guard<std::mutex> guard{robotMutex};
155 _arePlatformAndLocalizationUnitsEnabled =
161 Ice::StringSeq includePaths;
162 if (!robotProjectName.empty())
165 auto pathsString = finder.getDataDir();
166 includePaths = simox::alg::split(pathsString,
";,");
171 std::stringstream
str;
172 str <<
"Could not find robot file " + robotFileName
173 <<
"\nCollected paths from RobotFileNameProject '" << robotProjectName
174 <<
"':" << includePaths;
175 throw UserException(
str.str());
182 VirtualRobot::RobotIO::loadRobot(robotFileName, VirtualRobot::RobotIO::eCollisionModel);
183 if (robotName.empty())
185 robotName = robot->getName();
189 robot->setName(robotName);
192 catch (VirtualRobot::VirtualRobotException& e)
194 throw UserException(e.what());
197 <<
"\n\tProject : " << robotProjectName
198 <<
"\n\tName : " << robotName
199 <<
"\n\tRobot file : " << robotFileName
200 <<
"\n\tRobotNodeSet : " << robotNodeSetName <<
"\n\tNodeNames : "
201 << robot->getRobotNodeSet(robotNodeSetName)->getNodeNames();
203 robotPool.reset(
new RobotPool(robot, 20));
static bool getAbsolutePath(const std::string &relativeFilename, std::string &storeAbsoluteFilename, const std::vector< std::string > &additionalSearchPaths={}, bool verbose=true)
static void addDataPaths(const std::string &dataPathList)
The CMakePackageFinder class provides an interface to the CMake Package finder capabilities.
Property< PropertyType > getProperty(const std::string &name)
std::string prefix
Prefix of the properties such as namespace, domain, component name, etc.
PropertyDefinition< PropertyType > & defineOptionalProperty(const std::string &name, PropertyType defaultValue, const std::string &description="", PropertyDefinitionBase::PropertyConstness constness=PropertyDefinitionBase::eConstant)
PropertyDefinition< PropertyType > & defineRequiredProperty(const std::string &name, const std::string &description="", PropertyDefinitionBase::PropertyConstness constness=PropertyDefinitionBase::eConstant)
ModuleBasePropertyDefinitions(std::string prefix)
void throwIfInControlThread(const std::string &fnc) const
Throws if the current thread is the ControlThread.
RobotDataPropertyDefinitions(std::string prefix)
const std::string & getRobotFileName() const
Returns the file name of the robot's model.
const std::string & getRobotNodetSeName() const
Returns the name of the robot's RobotNodeSet.
const std::string & getRobotProjectName() const
Returns the name of the project containing the robot's model.
bool arePlatformAndLocalizationUnitsEnabled() const
const std::string & getRobotPlatformName() const
Returns the name of the robot's platform.
std::string getRobotName() const
Returns the robot's name.
VirtualRobot::RobotPtr cloneRobot(bool updateCollisionModel=false) const
Returns a clone of the robot's model.
std::string getRobotPlatformInstanceName() const
Returns the name of the robot platform instance.
#define ARMARX_CHECK_EXPRESSION(expression)
This macro evaluates the expression and if it turns out to be false it will throw an ExpressionExcept...
#define ARMARX_CHECK_IS_NULL(ptr)
This macro evaluates whether ptr is null and if it turns out to be false it will throw an ExpressionE...
#define ARMARX_CHECK_NOT_NULL(ptr)
This macro evaluates whether ptr is not null and if it turns out to be false it will throw an Express...
#define ARMARX_INFO
The normal logging level.
std::shared_ptr< class Robot > RobotPtr