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>
42 defineRequiredProperty<std::string>(
"RobotFileName",
43 "Robot file name, e.g. robot_model.xml");
44 defineOptionalProperty<std::string>(
"RobotFileNameProject",
46 "Project in which the robot filename is located "
47 "(if robot is loaded from an external project)");
49 defineOptionalProperty<std::string>(
52 "Override robot name if you want to load multiple robots of the same type");
53 defineOptionalProperty<std::string>(
56 "Robot node set name as defined in robot xml file, e.g. 'LeftArm'");
57 defineOptionalProperty<std::string>(
60 "Name of the platform needs to correspond to a node in the virtual robot.");
61 defineOptionalProperty<bool>(
"PlatformAndLocalizationUnitsEnabled",
63 "Enable or disable the platform and localization units.");
64 defineOptionalProperty<std::string>(
"PlatformInstanceName",
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};
149 std::string robotName = getProperty<std::string>(
"RobotName").getValue();
151 robotNodeSetName = getProperty<std::string>(
"RobotNodeSetName").getValue();
152 robotProjectName = getProperty<std::string>(
"RobotFileNameProject").getValue();
153 robotFileName = getProperty<std::string>(
"RobotFileName").getValue();
154 robotPlatformName = getProperty<std::string>(
"PlatformName").getValue();
155 _arePlatformAndLocalizationUnitsEnabled =
156 getProperty<bool>(
"PlatformAndLocalizationUnitsEnabled").getValue();
157 robotPlatformInstanceName = getProperty<std::string>(
"PlatformInstanceName").getValue();
161 Ice::StringSeq includePaths;
162 if (!robotProjectName.empty())
165 auto pathsString = finder.getDataDir();
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());
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));