Go to the documentation of this file.
29 #include <condition_variable>
36 #include "../../util/PlanningUtil.h"
37 #include <RobotComponents/interface/components/MotionPlanning/Tasks/AdaptiveDynamicDomainInformedRRTStar/ManagerNode.h>
38 #include <RobotComponents/interface/components/MotionPlanning/Tasks/AdaptiveDynamicDomainInformedRRTStar/WorkerNode.h>
44 template <
class IceBaseClass,
class DerivedClass>
class GenericFactory;
59 virtual public ManagerNodeBase,
65 using ClockType = std::chrono::system_clock;
86 RemoteObjectNodePrxList remoteObjectNodes,
90 const cprs::ComputingPowerRequestStrategyBasePtr& planningComputingPowerRequestStrategy,
95 Ice::Long nodeCountDeltaForGoalConnectionTries,
100 AdaptiveDynamicDomainParameters addParams,
105 task, remoteObjectNodes,
106 initialWorkerCount, maximalWorkerCount, planningComputingPowerRequestStrategy,
107 dcdStep, maximalPlanningTimeInSeconds,
110 addParams, targetCost, batchSize, nodeCountDeltaForGoalConnectionTries
122 #pragma GCC diagnostic push
123 #pragma GCC diagnostic ignored "-Wterminate"
125 #pragma GCC diagnostic pop
144 ARMARX_VERBOSE_S <<
"armarx::addirrtstar::ManagerNode::onDisconnectComponent()";
155 return "ADDIRRTStarManagerNode";
162 void kill(
const Ice::Current& = Ice::emptyCurrent)
override
170 PathWithCost
getBestPath(
const Ice::Current& = Ice::emptyCurrent)
const override;
183 PathWithCostSeq
getAllPathsWithCost(
const Ice::Current& = Ice::emptyCurrent)
const override;
194 FullIceTree
getTree(
const Ice::Current& = Ice::emptyCurrent)
const override;
209 void updateTree(
const Update& u,
const Ice::Current& = Ice::emptyCurrent)
override;
267 Update
getRemoteUpdate(std::size_t workerId, std::size_t updateId)
const;
335 std::vector<RemoteHandle<WorkerNodeBasePrx>>
workers;
std::mutex treeMutex
protects the tree data
PathWithCost getBestPath(const Ice::Current &=Ice::emptyCurrent) const override
std::vector< std::size_t > workersPerRemoteObjectNode
How many workers are started on each remote object node.
void onInitComponent() override
Initializes the tree and sampler.
void setMaxCpus(Ice::Int maxCpus, const Ice::Current &=Ice::emptyCurrent) override
std::size_t getWorkerCount() const
Returns the number of currently available workers (both active and paused).
FullIceTree getTree(const Ice::Current &=Ice::emptyCurrent) const override
Ice::Long getNodeCount(const Ice::Current &=Ice::emptyCurrent) const override
void createNewWorkerOn(std::size_t remoteObjectNodeIndex)
Creates a new worker on the given remote object node.
Ice::Int getMaxCpus(const Ice::Current &=Ice::emptyCurrent) const override
Manages the planning of the addirrt* algorithm.
void onDisconnectComponent() override
noop.
std::string updateTopicPrefix
The update topic's prefix.
bool hasLocalUpdateRequiresUpdateMutex(std::size_t workerId, std::size_t updateId) const
Returns whether the given update is cached.
std::condition_variable managerEvent
CV used by the manager thread to wait for new updates.
Ice::FloatSeq rotationMatrix
The rotation matrix used by the informed samplers.
std::thread managerThread
The tread executing managerTask.
std::vector< std::size_t > maxWorkersPerRemoteObjectNode
How many workers are maximal allowed on each remote object node.
PathWithCostSeq getAllPathsWithCost(const Ice::Current &=Ice::emptyCurrent) const override
~ManagerNode() override
dtor.
void sendManagerNodeData() const
Sents the manager's collected test data to the task.
Update getRemoteUpdate(std::size_t workerId, std::size_t updateId) const
Returns the requested update fetched from the corresponding worker.
void updateTree(const Update &u, const Ice::Current &=Ice::emptyCurrent) override
Adds the given update to the queue of pending updates.
void setWorkersFinalUpdateId(Ice::Long workerId, Ice::Long finalUpdateId, const Ice::Current &) override
Used by workers to inform the manager about their number of updates before exiting.
void kill(const Ice::Current &=Ice::emptyCurrent) override
Sets the flag to stop planning.
Ice::Long getPathCount(const Ice::Current &=Ice::emptyCurrent) const override
std::atomic_bool killRequest
Flag to signal the manager thread to exit.
std::mutex updateMutex
Protects the update section of the tree and the update cache of the manager.
ManagerNode()=default
Ctor used by ice factories.
void onExitComponent() override
Stopps planning and joins the manager thread.
void managerTask()
The managet task.checkedCastIt checks whether new workers are required and starts them if this is the...
std::vector< Ice::Long > workersFinalUpdateId
Used when shutting down to ensure all updates were applied before destroying the nodes remote object.
std::vector< RemoteHandle< WorkerNodeBasePrx > > workers
Worker proxies.
void cleanupAllWorkers()
Shuts down and removes all workers.
std::size_t getActiveWorkerCount() const
getActiveWorkerCount returns the number of currently active workers.
void cacheAppliedUpdateRequiresUpdateMutex(Update &&u)
Stores the given applied update to the cache.
std::vector< std::deque< Update > > appliedUpdates
All applied updates.
void applyUpdatesNotThreadSafe(std::unique_lock< std::mutex > &updateLock)
Applies all pending updates.
The ManagedIceObject is the base class for all ArmarX objects.
#define ARMARX_CHECK_EXPRESSION(expression)
This macro evaluates the expression and if it turns out to be false it will throw an ExpressionExcept...
A structure holding and managing all data connected to the tree used in the ADDIRRT* algorithm.
PathWithCost getNthPathWithCost(Ice::Long n, const Ice::Current &=Ice::emptyCurrent) const override
Update getUpdate(Ice::Long workerId, Ice::Long updateId, const Ice::Current &=Ice::emptyCurrent) const override
ManagerNode(TaskBasePrx task, RemoteObjectNodePrxList remoteObjectNodes, Ice::Long initialWorkerCount, Ice::Long maximalWorkerCount, const cprs::ComputingPowerRequestStrategyBasePtr &planningComputingPowerRequestStrategy, float dcdStep, Ice::Long maximalPlanningTimeInSeconds, Ice::Long batchSize, Ice::Long nodeCountDeltaForGoalConnectionTries, CSpaceBasePtr cspace, VectorXf startCfg, VectorXf goalCfg, AdaptiveDynamicDomainParameters addParams, float targetCost)
Ctor.
void createNewWorker()
Creates a new worker.
std::mutex workerMutex
used to lock access to the vector workers
const Update & getLocalUpdateRequiresUpdateMutex(std::size_t workerId, std::size_t updateId) const
Returns the requested update from the cache.
std::string getDefaultName() const override
void onConnectComponent() override
noop.
ClockType::time_point timepointStart
Timepoint when the manager node started planning.
std::atomic_size_t activeWorkerCount
currentlyActiveWorkers the index of the newest planning process in the workers vector (is <= workers....
This file offers overloads of toIce() and fromIce() functions for STL container types.