29 #include <MemoryX/interface/components/WorkingMemoryInterface.h>
32 #include <RobotAPI/interface/core/RobotState.h>
33 #include <RobotAPI/interface/visualization/DebugDrawerInterface.h>
36 #include <RobotComponents/interface/components/CollisionCheckerInterface.h>
38 #include <VirtualRobot/Robot.h>
39 #include <VirtualRobot/SceneObject.h>
56 defineRequiredProperty<bool>(
"UseWorkingMemory",
"If true, the WorkingMemory is used to get all SceneObjects. Otherwise a RobotStateComponent is used.");
57 defineOptionalProperty<std::string>(
"WorkingMemoryName",
"WorkingMemory",
"The name of the WorkingMemory.");
58 defineOptionalProperty<std::string>(
"WorkingMemoryListenerTopicName",
"WorkingMemoryUpdates",
"The name of the topic to listen for WorkingMemory updates.");
59 defineOptionalProperty<std::string>(
"RobotStateComponentName",
"RobotStateComponent",
"The name of the RobotStateComponent.");
60 defineOptionalProperty<int>(
"interval", 100,
"The interval of time to check for collisions. (in ms)");
61 defineOptionalProperty<std::string>(
"CollisionPairs",
"[]",
"A list of tripels including two SceneObjects or SceneObject lists and a distance from which to warn. Example: [{Armar3:(Ring L J0,Ring L J1),Armar3:(Ring R J0,Ring R J1),2.0},{Armar3:Index L J0,tableb,3.0}]");
62 defineOptionalProperty<std::string>(
"DistanceListenerTopicName",
"DistanceListener",
"The topic name to get information about the distances.");
63 defineOptionalProperty<std::string>(
"CollisionListenerTopicName",
"CollisionListener",
"The topic name to get information about collisions.");
64 defineOptionalProperty<bool>(
"UseDebugDrawer",
"false",
"If true, the distances are printet using the debug drawer.");
65 defineOptionalProperty<std::string>(
"DebugDrawerTopicName",
"DebugDrawerUpdates",
"The name of the debug drawer topic.");
82 virtual public armarx::CollisionCheckerInterface
87 VirtualRobot::SceneObjectSetPtr objects1;
88 std::string robotName1;
89 std::vector<std::string> nodeNames1;
91 std::string nodeSetName1;
92 VirtualRobot::SceneObjectSetPtr objects2;
93 std::string robotName2;
94 std::vector<std::string> nodeNames2;
96 std::string nodeSetName2;
97 double warningDistance;
113 return "CollisionCheckerComponent";
116 void addCollisionPair(
const std::string& robotName1,
const std::vector<std::string>& nodeNames1,
const std::string& robotName2,
const std::vector<std::string>& nodeNames2,
double warningDistance,
const Ice::Current& = Ice::emptyCurrent)
override;
118 void removeCollisionPair(
const std::string& robotName1,
const std::vector<std::string>& nodeNames1,
const std::string& robotName2,
const std::vector<std::string>& nodeNames2,
const Ice::Current& = Ice::emptyCurrent)
override;
120 bool hasCollisionPair(
const std::string& robotName1,
const std::vector<std::string>& nodeNames1,
const std::string& robotName2,
const std::vector<std::string>& nodeNames2,
const Ice::Current& = Ice::emptyCurrent)
const override;
122 void setWarningDistance(
const std::string& robotName1,
const std::vector<std::string>& nodeNames1,
const std::string& robotName2,
const std::vector<std::string>& nodeNames2,
double warningDistance,
const Ice::Current& = Ice::emptyCurrent)
override;
123 double getWarningDistance(
const std::string& robotName1,
const std::vector<std::string>& nodeNames1,
const std::string& robotName2,
const std::vector<std::string>& nodeNames2,
const Ice::Current& = Ice::emptyCurrent)
const override;
127 int getInterval(
const Ice::Current& = Ice::emptyCurrent)
const override;
128 void setInterval(
int interval,
const Ice::Current& = Ice::emptyCurrent)
override;
157 bool resolveCollisionPair(SceneObjectPair& pair);
159 bool parseNodeSet(
const std::string& setAsString, std::string& robotName, std::vector<std::string>& nodeNames,
bool& usesNodeSet, std::string& nodeSetName);
160 void reportDistancesAndCollisions();
162 void synchronizeObjectsFromWorkingMemory();
164 virtual void addCollisionPair(
const std::string& robotName1,
const std::vector<std::string>& nodeNames1,
const bool usesNodeSet1,
const std::string& nodeSetName1,
const std::string& robotName2,
const std::vector<std::string>& nodeNames2,
const bool usesNodeSet2,
const std::string& nodeSetName2,
double warningDistance);
166 void reportEntityCreated(
const std::string& segmentName, const ::memoryx::EntityBasePtr& entity, const ::Ice::Current& = Ice::emptyCurrent)
override;
167 void reportEntityUpdated(
const std::string& segmentName, const ::memoryx::EntityBasePtr& entityOld, const ::memoryx::EntityBasePtr& entityNew, const ::Ice::Current& = Ice::emptyCurrent)
override;
168 void reportEntityRemoved(
const std::string& segmentName, const ::memoryx::EntityBasePtr& entity, const ::Ice::Current& = Ice::emptyCurrent)
override;
169 void reportSnapshotLoaded(
const std::string& segmentName, const ::Ice::Current& = Ice::emptyCurrent)
override;
170 void reportSnapshotCompletelyLoaded(
const Ice::Current&
c = Ice::emptyCurrent)
override;
171 void reportMemoryCleared(
const std::string& segmentName, const ::Ice::Current& = Ice::emptyCurrent)
override;
173 bool useWorkingMemory;
175 std::string workingMemoryName;
176 memoryx::WorkingMemoryInterfacePrx workingMemoryPrx;
177 memoryx::ObjectInstanceMemorySegmentBasePrx objectInstancesPrx;
178 memoryx::AgentInstancesSegmentBasePrx agentInstancesPrx;
180 std::vector<VirtualRobot::SceneObjectPtr> workingMemorySceneObjects;
181 std::map<std::string, armarx::PosePtr> currentPositions;
182 std::mutex wmPositionMutex;
184 std::string robotStateComponentName;
186 std::vector<RobotPair> robots;
188 std::vector<SceneObjectPair> sceneObjectPairs;
190 VirtualRobot::CollisionCheckerPtr collisionChecker;
192 CollisionListenerPrx collisionListenerPrx;
193 DistanceListenerPrx distanceListenerPrx;
197 mutable std::mutex dataMutex;
200 std::shared_mutex connectedMutex;