27#include <condition_variable>
30#include <unordered_map>
38#include <RobotComponents/interface/components/MotionPlanning/MotionPlanningServer.h>
69 "RemoteObjectNodes",
"",
"CSV of RemoteObjectNode names");
73 "start a local remote object node if the CSV RemoteObjectNodes is empty");
77 "Local remote object node core count percentage. (has to be >0; 0.5 => 50%");
90 virtual public MotionPlanningServerInterface,
104#pragma GCC diagnostic push
105#pragma GCC diagnostic ignored "-Wterminate"
109#pragma GCC diagnostic pop
120 return "MotionPlanningServer";
165 const Ice::Current& = Ice::emptyCurrent)
override;
172 armarx::ClientSideRemoteHandleControlBlockBasePtr
174 const Ice::Current& = Ice::emptyCurrent)
override;
180 Ice::Long
getNumberOfTasks(
const Ice::Current& = Ice::emptyCurrent)
const override;
191 TaskInfoSeq
getAllTaskInfo(
const Ice::Current& = Ice::emptyCurrent)
const override;
193 ClientSideRemoteHandleControlBlockBasePtr
197 const Ice::Current& = Ice::emptyCurrent)
override;
199 const std::string& lib,
200 const Ice::Current& = Ice::emptyCurrent)
override;
212 std::atomic<Ice::Long>
nextTaskId{std::numeric_limits<Ice::Long>::min()};
253 using TaskMap = std::unordered_map<Ice::Long, TaskAndRemoteHandle>;
302 bool loadLibFromAbsolutePath(
const std::string& path);
Default component property definition container.
ComponentPropertyDefinitions(std::string prefix, bool hasObjectNameParameter=true)
Baseclass for all ArmarX ManagedIceObjects requiring properties.
std::string getConfigIdentifier()
Retrieve config identifier for this component as set in constructor.
The DynamicLibrary class provides a mechanism to load libraries at runtime.
Properties for a MotionPlanningServerComponent.
MotionPlanningServerPropertyDefinitions(std::string prefix)
ctor
TaskAndRemoteHandle currentTask
currentTask stores a handle to the currently dispatched planning task.
std::thread dispatcherThread
The dispatcher's thread.
ClientSideRemoteHandleControlBlockBasePtr getCurrentTaskHandle(const Ice::Current &) override
void onInitComponent() override
Initializes the server and starts the dispatcher thread.
std::vector< armarx::RemoteObjectNodeInterfacePrx > remoteObjectNodes
The used remote object nodes.
std::recursive_mutex queueMutex
mutex protecting the task queue
bool startLocalNode
Whether a local node should be started, if no rons were provided.
Ice::Long getNumberOfTasks(const Ice::Current &=Ice::emptyCurrent) const override
Returns the number of tasks.
float localNodePercent
Percentage of cores used by the local ron (if started).
std::atomic< Ice::Long > nextTaskId
the next task id.
bool loadLibFromPackage(const std::string &package, const std::string &lib, const Ice::Current &=Ice::emptyCurrent) override
void onDisconnectComponent() override
noop
armarx::ClientSideRemoteHandleControlBlockBasePtr enqueueTask(const MotionPlanningTaskBasePtr &task, const Ice::Current &=Ice::emptyCurrent) override
Enqueues a task.
std::vector< std::string > remoteObjectNodeNames
The used remote object nodes' names.
TaskMap tasks
The map of tasks.
MotionPlanningServer()=default
ctor
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
TaskInfoSeq getAllTaskInfo(const Ice::Current &=Ice::emptyCurrent) const override
Returns information about all tasks.
std::condition_variable_any waitForTaskOrDispatcherKill
The dispatcher's cv.
std::map< std::string, DynamicLibraryPtr > loadedLibs
std::unordered_map< Ice::Long, TaskAndRemoteHandle > TaskMap
The type of the map of tasks.
std::set< Ice::Long > taskQueue
Contains the queue of task ids to execute.
std::atomic_bool dispatcherKillRequest
Whether the dispatcher should shut down.
void dispatcherTask()
the dispatcher task.
bool loadLibFromPath(const std::string &path, const Ice::Current &=Ice::emptyCurrent) override
void onConnectComponent() override
Connects to the used RemoteObjectNodes.
SimoxCSpacePtr cacheCSpace
void onExitComponent() override
cleans up and joins the dispatcher
Ice::Long getNewTaskId()
Returns a new task id.
CSpaceAndPaths getTaskCSpaceAndPathsById(Ice::Long id, const Ice::Current &=Ice::emptyCurrent) override
Returns a task's cspace and all found paths.
RemoteObjectNodePtr localNode
~MotionPlanningServer() override
dtor
Ice::Long getNumberOfQueuedTasks(const Ice::Current &) const override
Returns the number of queued tasks.
std::string getDefaultName() const override
Returns the server's default name.
bool deleteTaskById(Ice::Long id)
std::string prefix
Prefix of the properties such as namespace, domain, component name, etc.
PropertyDefinition< PropertyType > & defineOptionalProperty(const std::string &name, PropertyType defaultValue, const std::string &description="", PropertyDefinitionBase::PropertyConstness constness=PropertyDefinitionBase::eConstant)
#define ARMARX_CHECK_EXPRESSION(expression)
This macro evaluates the expression and if it turns out to be false it will throw an ExpressionExcept...
This file offers overloads of toIce() and fromIce() functions for STL container types.
IceInternal::Handle< RemoteHandleControlBlock > RemoteHandleControlBlockPtr
IceInternal::Handle< MotionPlanningServer > MotionPlanningServerComponentPtr
A ice handle for a MotionPlanningServerComponent.
IceInternal::Handle< MotionPlanningTask > MotionPlanningTaskPtr
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.
IceInternal::Handle< SimoxCSpace > SimoxCSpacePtr
An ice handle for a SimoxCSpace.
std::shared_ptr< DynamicLibrary > DynamicLibraryPtr
IceInternal::Handle< RemoteObjectNode > RemoteObjectNodePtr
An ice handle for a RemoteObjectNodeComponent.
MotionPlanningTaskPtr task
armarx::RemoteHandleControlBlockPtr rh