28 #include <SimoxUtility/algorithm/string/string_tools.h>
29 #include <VirtualRobot/SceneObjectSet.h>
30 #include <VirtualRobot/VirtualRobot.h>
45 #include <range/v3/view/for_each.hpp>
56 const std::string Component::defaultName =
"distance_to_obstacle_costmap_provider";
64 def->required(properties.robotName,
"p.robotName",
"Robot name.");
66 def->optional(properties.costmapBuilderParams.binaryGrid,
"p.costmapBuilderParams.binaryGrid");
67 def->optional(properties.costmapBuilderParams.cellSize,
"p.costmapBuilderParams.cellSize");
68 def->optional(properties.costmapBuilderParams.sceneBoundsMargin,
"p.costmapBuilderParams.sceneBoundsMargin");
70 def->optional(properties.colModel,
"p.colModel");
116 runningTask->start();
130 const std::vector<std::string> primitiveModelIds = [&]() -> std::vector<std::string>
132 if (not properties.primitiveModelIds.empty())
134 const std::vector<std::string> primitiveModelIds =
137 return primitiveModelIds;
143 const auto loadMode = primitiveModelIds.empty()
144 ? VirtualRobot::RobotIO::RobotDescription::eCollisionModel
145 : VirtualRobot::RobotIO::RobotDescription::eStructure;
147 const auto robot = virtualRobotReaderPlugin->get().getRobotWaiting(
152 if (not primitiveModelIds.empty())
154 ARMARX_INFO <<
"Using primitive approximation model";
155 robot->setPrimitiveApproximationModel(primitiveModelIds);
171 const VirtualRobot::SceneObjectSetPtr objects =
175 for (
const auto& objectPoseStaticArticulated : objectPosesStaticArticulated)
177 const auto articulatedObject =
179 objectPoseStaticArticulated.objectID.getClassID().str(),
182 objectPoseStaticArticulated.objectID.instanceName());
185 << objectPoseStaticArticulated.objectID.getClassID().str();
188 *articulatedObject,
Clock::Now(), std::nullopt));
190 std::set<std::string> primitiveIDs;
191 articulatedObject->getPrimitiveApproximationIDs(primitiveIDs);
193 if (articulatedObject->getCollisionModels().empty())
195 ARMARX_INFO <<
"The articualted object `" << articulatedObject->getType() <<
"/"
196 << articulatedObject->getName()
197 <<
"` does not have a collision model. Using primitive model instead.";
201 const std::vector<std::string> usedPrimitiveModelIDs(primitiveIDs.begin(),
203 articulatedObject->setPrimitiveApproximationModel(usedPrimitiveModelIDs);
211 ARMARX_INFO << objects->getSize() <<
" objects in the scene";
222 ARMARX_INFO <<
" - " <<
object->getType() <<
"/" <<
object->getName();
233 properties.costmapBuilderParams,
234 properties.colModel);
236 const auto costmap = costmapBuilder.
create();
239 return costmapWriterPlugin->get().store(
257 return Component::defaultName;
263 return Component::defaultName;