25 #include <SimoxUtility/algorithm/string/string_tools.h>
26 #include <VirtualRobot/RobotNodeSet.h>
27 #include <VirtualRobot/XML/RobotIO.h>
40 defineRequiredProperty<std::string>(
"RobotFileName",
41 "Robot file name, e.g. robot_model.xml");
42 defineOptionalProperty<std::string>(
"RobotFileNameProject",
44 "Project in which the robot filename is located "
45 "(if robot is loaded from an external project)");
47 defineOptionalProperty<std::string>(
50 "Override robot name if you want to load multiple robots of the same type");
51 defineOptionalProperty<std::string>(
54 "Robot node set name as defined in robot xml file, e.g. 'LeftArm'");
55 defineOptionalProperty<std::string>(
58 "Name of the platform needs to correspond to a node in the virtual robot.");
59 defineOptionalProperty<bool>(
"PlatformAndLocalizationUnitsEnabled",
61 "Enable or disable the platform and localization units.");
62 defineOptionalProperty<std::string>(
"PlatformInstanceName",
64 "Name of the platform instance (will publish "
65 "values on PlatformInstanceName + 'State')");
71 return _arePlatformAndLocalizationUnitsEnabled;
79 << __FUNCTION__ <<
" should only be called after _initVirtualRobot was called";
80 return robotPlatformName;
86 return robotPlatformInstanceName;
94 << __FUNCTION__ <<
" should only be called after _initVirtualRobot was called";
95 return robotNodeSetName;
103 << __FUNCTION__ <<
" should only be called after _initVirtualRobot was called";
104 return robotProjectName;
112 << __FUNCTION__ <<
" should only be called after _initVirtualRobot was called";
113 return robotFileName;
120 std::lock_guard<std::mutex> guard{robotMutex};
122 << __FUNCTION__ <<
" should only be called after _initVirtualRobot was called";
123 return robot->getName();
130 std::lock_guard<std::mutex> guard{robotMutex};
132 << __FUNCTION__ <<
" should only be called after _initVirtualRobot was called";
135 clone->setUpdateVisualization(
false);
136 clone->setUpdateCollisionModel(updateCollisionModel);
141 RobotData::_initVirtualRobot()
144 std::lock_guard<std::mutex> guard{robotMutex};
147 std::string robotName = getProperty<std::string>(
"RobotName").getValue();
149 robotNodeSetName = getProperty<std::string>(
"RobotNodeSetName").getValue();
150 robotProjectName = getProperty<std::string>(
"RobotFileNameProject").getValue();
151 robotFileName = getProperty<std::string>(
"RobotFileName").getValue();
152 robotPlatformName = getProperty<std::string>(
"PlatformName").getValue();
153 _arePlatformAndLocalizationUnitsEnabled =
154 getProperty<bool>(
"PlatformAndLocalizationUnitsEnabled").getValue();
155 robotPlatformInstanceName = getProperty<std::string>(
"PlatformInstanceName").getValue();
159 Ice::StringSeq includePaths;
160 if (!robotProjectName.empty())
163 auto pathsString = finder.getDataDir();
169 std::stringstream
str;
170 str <<
"Could not find robot file " + robotFileName
171 <<
"\nCollected paths from RobotFileNameProject '" << robotProjectName
172 <<
"':" << includePaths;
173 throw UserException(
str.str());
181 if (robotName.empty())
183 robotName = robot->getName();
187 robot->setName(robotName);
190 catch (VirtualRobot::VirtualRobotException& e)
192 throw UserException(e.what());
195 <<
"\n\tProject : " << robotProjectName
196 <<
"\n\tName : " << robotName
197 <<
"\n\tRobot file : " << robotFileName
198 <<
"\n\tRobotNodeSet : " << robotNodeSetName <<
"\n\tNodeNames : "
199 << robot->getRobotNodeSet(robotNodeSetName)->getNodeNames();
201 robotPool.reset(
new RobotPool(robot, 20));