25#include <VirtualRobot/CollisionDetection/CollisionChecker.h>
26#include <VirtualRobot/XML/RobotIO.h>
31#include <MemoryX/interface/memorytypes/MemoryEntities.h>
60 const ::Ice::Current&)
68 const ::Ice::Current&)
70 ARMARX_VERBOSE <<
"Adding " << list.size() <<
" collision objects";
73 std::vector<CollisionObjectData> newObjects;
75 for (
const auto& elem : list)
80 newObject.
object = elem.objectClassBase;
83 << newObject.
object->getId();
86 memoryx::ObjectClassPtr::dynamicCast(elem.objectClassBase);
91 s <<
"Can't use object class with ice id " << elem.objectClassBase->ice_id();
93 throw armarx::InvalidArgumentException{s.str()};
100 VirtualRobot::ManipulationObjectPtr orgMo = sw->getManipulationObject();
101 std::string moName = orgMo->getName();
103 VirtualRobot::ManipulationObjectPtr mo = orgMo->clone(moName);
107 const auto objectPose = armarx::PosePtr::dynamicCast(elem.objectPose);
112 s <<
"Can't convert pose of " << objectClass->getName() <<
" to armarx::Pose.";
114 throw armarx::InvalidArgumentException{s.str()};
117 mo->setGlobalPose(objectPose->toEigen());
120 VirtualRobot::CollisionModelPtr colModel = mo->getCollisionModel();
123 newObjects.push_back(newObject);
124 ARMARX_VERBOSE <<
"Object: " << newObjects.size() - 1 <<
" done.";
128 std::copy(newObjects.begin(), newObjects.end(), std::back_inserter(
objects));
131 <<
" collision objects. (Total: " <<
objects.size() <<
")";
143 const std::string& agentColModelName,
144 const ::Ice::Current&)
146 ARMARX_VERBOSE <<
"Setting agent '" << newAgent->getName() <<
"' with id " << newAgent->getId();
148 std::string agentFilePath = newAgent->getAgentFilePath();
152 ARMARX_ERROR <<
"Could not find robot file " << agentFilePath << std::flush;
155 <<
" additional paths";
167 auto agent2 = VirtualRobot::RobotIO::loadRobot(agentFilePath, VirtualRobot::RobotIO::eFull);
173 s <<
"Can't load agent from: " << agentFilePath;
175 throw armarx::InvalidArgumentException{s.str()};
179 if (!agent2->hasRobotNode(agentColModelName) ||
180 !agent2->getRobotNode(agentColModelName)->getCollisionModel())
183 s <<
"Agent has no collision model with name " << agentColModelName;
185 throw armarx::InvalidArgumentException{s.str()};
200 s <<
"Invalid margin: " << margin <<
" < 0.0";
202 throw armarx::InvalidArgumentException{s.str()};
213 throw std::logic_error{
"no agent collision model"};
222 Eigen::Matrix4f pose = Eigen::Matrix4f::Identity();
223 pose.block<3, 3>(0, 0) =
224 VirtualRobot::MathTools::axisangle2eigen3f(Eigen::Vector3f{0.f, 0.f, 1.f}, position.z);
225 pose(0, 3) = position.x;
226 pose(1, 3) = position.y;
228 agent->setGlobalPose(pose);
232 for (
const auto&
object :
objects)
235 VirtualRobot::CollisionChecker::getGlobalCollisionChecker()->calculateDistance(
247 for (
const auto&
object :
objects)
249 bool col = VirtualRobot::CollisionChecker::getGlobalCollisionChecker()->checkCollision(
static bool getAbsolutePath(const std::string &relativeFilename, std::string &storeAbsoluteFilename, const std::vector< std::string > &additionalSearchPaths={}, bool verbose=true)
static std::vector< std::string > getDataPaths()
Property< PropertyType > getProperty(const std::string &name)
bool usingProxy(const std::string &name, const std::string &endpoints="")
Registers a proxy for retrieval after initialization and adds it to the dependency list.
Ice::ObjectPrx getProxy(long timeoutMs=0, bool waitForScheduler=true) const
Returns the proxy of this object (optionally it waits for the proxy)
void onInitComponent() override
memoryx::CommonStorageInterfacePrx commonStoragePrx
VirtualRobot::CollisionModelPtr agentCollisionModel
void setAgent(const ::memoryx::AgentInstanceBasePtr &newAgent, const std::string &agentColModelName, const ::Ice::Current &=Ice::emptyCurrent) override
memoryx::WorkingMemoryInterfacePrx workingMemoryPrx
void addCollisionObjects(const ::armarx::ObjectPositionBaseList &list, const ::Ice::Current &=Ice::emptyCurrent) override
bool isPositionValid(armarx::Vector3 position) const
void setCollisionObjects(const ::armarx::ObjectPositionBaseList &list, const ::Ice::Current &=Ice::emptyCurrent) override
memoryx::GridFileManagerPtr fileManager
void setSafetyMargin(::Ice::Float margin, const ::Ice::Current &=Ice::emptyCurrent) override
void onConnectComponent() override
void clearCollisionObjects(const ::Ice::Current &=Ice::emptyCurrent) override
std::vector< CollisionObjectData > objects
VirtualRobot::RobotPtr agent
SimoxObjectWrapper offers a simplified access to the Simox ManipulationObject (i.e visualization,...
GridFileManager provides utility functions for working with files in Mongo GridFS and links to them s...
#define ARMARX_ERROR_S
The logging level for unexpected behaviour, that must be fixed.
#define ARMARX_ERROR
The logging level for unexpected behaviour, that must be fixed.
#define ARMARX_VERBOSE
The logging level for verbose information.
IceInternal::Handle< SimoxObjectWrapper > SimoxObjectWrapperPtr
IceInternal::Handle< ObjectClass > ObjectClassPtr
memoryx::ObjectClassBasePtr object
VirtualRobot::CollisionModelPtr colModel