27#include <condition_variable>
34#include <RobotComponents/interface/components/MotionPlanning/Tasks/AdaptiveDynamicDomainInformedRRTStar/ManagerNode.h>
35#include <RobotComponents/interface/components/MotionPlanning/Tasks/AdaptiveDynamicDomainInformedRRTStar/WorkerNode.h>
42 template <
class IceBaseClass,
class DerivedClass>
63 using ClockType = std::chrono::system_clock;
85 RemoteObjectNodePrxList remoteObjectNodes,
87 Ice::Long initialWorkerCount,
88 Ice::Long maximalWorkerCount,
89 const cprs::ComputingPowerRequestStrategyBasePtr& planningComputingPowerRequestStrategy,
92 Ice::Long maximalPlanningTimeInSeconds,
94 Ice::Long nodeCountDeltaForGoalConnectionTries,
99 AdaptiveDynamicDomainParameters addParams,
101 ManagerNodeBase(task,
105 planningComputingPowerRequestStrategy,
107 maximalPlanningTimeInSeconds,
114 nodeCountDeltaForGoalConnectionTries)
125#pragma GCC diagnostic push
126#pragma GCC diagnostic ignored "-Wterminate"
128#pragma GCC diagnostic pop
148 ARMARX_VERBOSE_S <<
"armarx::addirrtstar::ManagerNode::onDisconnectComponent()";
162 return "ADDIRRTStarManagerNode";
170 kill(
const Ice::Current& = Ice::emptyCurrent)
override
178 PathWithCost
getBestPath(
const Ice::Current& = Ice::emptyCurrent)
const override;
182 Ice::Long
getPathCount(
const Ice::Current& = Ice::emptyCurrent)
const override;
188 const Ice::Current& = Ice::emptyCurrent)
const override;
192 PathWithCostSeq
getAllPathsWithCost(
const Ice::Current& = Ice::emptyCurrent)
const override;
201 const Ice::Current& = Ice::emptyCurrent)
const override;
205 FullIceTree
getTree(
const Ice::Current& = Ice::emptyCurrent)
const override;
214 Ice::Long finalUpdateId,
215 const Ice::Current&)
override;
222 void updateTree(
const Update& u,
const Ice::Current& = Ice::emptyCurrent)
override;
231 Ice::Long
getNodeCount(
const Ice::Current& = Ice::emptyCurrent)
const override;
234 void setMaxCpus(Ice::Int maxCpus,
const Ice::Current& = Ice::emptyCurrent)
override;
236 Ice::Int
getMaxCpus(
const Ice::Current& = Ice::emptyCurrent)
const override;
273 std::size_t updateId)
const;
281 Update
getRemoteUpdate(std::size_t workerId, std::size_t updateId)
const;
350 std::vector<RemoteHandle<WorkerNodeBasePrx>>
workers;
Manages the planning of the addirrt* algorithm.
std::vector< std::size_t > maxWorkersPerRemoteObjectNode
How many workers are maximal allowed on each remote object node.
void updateTree(const Update &u, const Ice::Current &=Ice::emptyCurrent) override
Adds the given update to the queue of pending updates.
void onInitComponent() override
Initializes the tree and sampler.
std::size_t getActiveWorkerCount() const
getActiveWorkerCount returns the number of currently active workers.
Update getRemoteUpdate(std::size_t workerId, std::size_t updateId) const
Returns the requested update fetched from the corresponding worker.
~ManagerNode() override
dtor.
std::vector< RemoteHandle< WorkerNodeBasePrx > > workers
Worker proxies.
PathWithCostSeq getAllPathsWithCost(const Ice::Current &=Ice::emptyCurrent) const override
Ice::Long getPathCount(const Ice::Current &=Ice::emptyCurrent) const override
bool hasLocalUpdateRequiresUpdateMutex(std::size_t workerId, std::size_t updateId) const
Returns whether the given update is cached.
std::vector< std::size_t > workersPerRemoteObjectNode
How many workers are started on each remote object node.
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 onDisconnectComponent() override
noop.
std::mutex workerMutex
used to lock access to the vector workers
void createNewWorkerOn(std::size_t remoteObjectNodeIndex)
Creates a new worker on the given remote object node.
std::atomic_bool killRequest
Flag to signal the manager thread to exit.
std::vector< Ice::Long > workersFinalUpdateId
Used when shutting down to ensure all updates were applied before destroying the nodes remote object.
std::string updateTopicPrefix
The update topic's prefix.
std::vector< std::deque< Update > > appliedUpdates
All applied updates.
Update getUpdate(Ice::Long workerId, Ice::Long updateId, const Ice::Current &=Ice::emptyCurrent) const override
friend class ManagedIceObject
required for static factory methode create
std::mutex updateMutex
Protects the update section of the tree and the update cache of the manager.
std::thread managerThread
The tread executing managerTask.
PathWithCost getNthPathWithCost(Ice::Long n, const Ice::Current &=Ice::emptyCurrent) const override
void cleanupAllWorkers()
Shuts down and removes all workers.
Ice::FloatSeq rotationMatrix
The rotation matrix used by the informed samplers.
void sendManagerNodeData() const
Sents the manager's collected test data to the task.
PathWithCost getBestPath(const Ice::Current &=Ice::emptyCurrent) const override
void cacheAppliedUpdateRequiresUpdateMutex(Update &&u)
Stores the given applied update to the cache.
void onConnectComponent() override
noop.
void setMaxCpus(Ice::Int maxCpus, const Ice::Current &=Ice::emptyCurrent) override
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.
FullIceTree getTree(const Ice::Current &=Ice::emptyCurrent) const override
ManagerNode()=default
Ctor used by ice factories.
std::atomic_size_t activeWorkerCount
currentlyActiveWorkers the index of the newest planning process in the workers vector (is <= workers....
const Update & getLocalUpdateRequiresUpdateMutex(std::size_t workerId, std::size_t updateId) const
Returns the requested update from the cache.
ClockType::time_point timepointStart
Timepoint when the manager node started planning.
void managerTask()
The managet task.checkedCastIt checks whether new workers are required and starts them if this is the...
std::size_t getWorkerCount() const
Returns the number of currently available workers (both active and paused).
void createNewWorker()
Creates a new worker.
void onExitComponent() override
Stopps planning and joins the manager thread.
Ice::Long getNodeCount(const Ice::Current &=Ice::emptyCurrent) const override
std::condition_variable managerEvent
CV used by the manager thread to wait for new updates.
Ice::Int getMaxCpus(const Ice::Current &=Ice::emptyCurrent) const override
std::mutex treeMutex
protects the tree data
void kill(const Ice::Current &=Ice::emptyCurrent) override
Sets the flag to stop planning.
std::string getDefaultName() const override
void applyUpdatesNotThreadSafe(std::unique_lock< std::mutex > &updateLock)
Applies all pending updates.
A structure holding and managing all data connected to the tree used in the ADDIRRT* algorithm.
#define ARMARX_CHECK_EXPRESSION(expression)
This macro evaluates the expression and if it turns out to be false it will throw an ExpressionExcept...
IceInternal::Handle< ManagerNode > ManagerNodePtr
An ice handle for a ManagerNode.
This file offers overloads of toIce() and fromIce() functions for STL container types.