Go to the documentation of this file.
29 #include <boost/current_function.hpp>
30 #include <boost/preprocessor/seq/for_each.hpp>
31 #include <boost/preprocessor/variadic/to_seq.hpp>
33 #include <VirtualRobot/Robot.h>
38 #include <RobotAPI/interface/units/RobotUnit/RobotUnitInterface.h>
40 #include "../JointControllers/JointController.h"
42 #include "../util/JointAndNJointControllers.h"
54 template <
class Targ,
class Src>
58 Targ* ptr =
dynamic_cast<Targ*
>(src);
63 throw std::invalid_argument{
"Ptr passed to CheckedCastAndDeref is NULL"};
65 throw std::invalid_argument{
66 "Ptr of type '" + GetTypeString<Src>() +
67 "' passed to CheckedCastAndDeref is is not related to target type '" +
68 GetTypeString<Targ>()};
118 #define forward_declare(r, data, Mod) TYPEDEF_PTRS_HANDLE(Mod);
119 BOOST_PP_SEQ_FOR_EACH(
forward_declare, , BOOST_PP_VARIADIC_TO_SEQ(RobotUnitModules))
120 #undef forward_declare
186 static std::atomic<ModuleBase*> Instance_;
209 "The type has to derive ModuleBase");
211 return dynamic_cast<T&
>(*Instance_);
230 #define using_module_types(...) using_module_types_impl(__VA_ARGS__)
231 #define using_module_types_impl(r, data, Mod) using Module##Mod = Mod;
232 BOOST_PP_SEQ_FOR_EACH(
using_module_types, , BOOST_PP_VARIADIC_TO_SEQ(RobotUnitModules))
233 #undef using_module_types
234 #undef using_module_types_impl
251 return dynamic_cast<T&
>(*this);
262 return dynamic_cast<const T&
>(*this);
273 return &_module<T>();
284 return &_module<const T>();
589 const std::string& fnc,
590 bool onlyWarn =
false)
const;
606 const std::string& fnc,
607 bool onlyWarn =
false)
const;
649 return isShuttingDown_.load();
659 isShuttingDown_.store(
true);
719 static constexpr std::size_t
738 static const std::set<RobotUnitState> DevicesReadyStates;
742 std::atomic_bool isShuttingDown_{
false};
std::chrono::high_resolution_clock::time_point TimePointType
bool isShuttingDown() const
Returns whether the RobotUnit is shutting down.
void setPrefix(std::string prefix)
#define forward_declare(r, data, Mod)
void _postOnDisconnectRobotUnit()
Hook for deriving RobotUnitModules called in onDisconnectComponent (called after onDisconnectRobotUni...
virtual void onConnectRobotUnit()
called in onConnectComponent
std::recursive_timed_mutex MutexType
The type of recursive_mutex used in this class.
void _preFinishRunning()
Hook for deriving RobotUnitModules called in finishRunning (called before the state has changed)
void _postFinishComponentInitialization()
Hook for deriving RobotUnitModules called in finishComponentInitialization (called after the state ha...
void onExitComponent() final override
ModuleBasePropertyDefinitions(std::string prefix)
void setDescription(const std::string &description)
Sets the detailed description of the property user.
const T * _modulePtr() const
Returns this as ptr to the given type.
TYPEDEF_PTRS_HANDLE(NJointCartesianNaturalPositionController)
void _preFinishControlThreadInitialization()
Hook for deriving RobotUnitModules called in finishControlThreadInitialization (called before the sta...
void _preOnDisconnectRobotUnit()
Hook for deriving RobotUnitModules called in onDisconnectComponent (called before onDisconnectRobotUn...
std::string getDefaultName() const override
const T & _module() const
Returns this as ref to the given type.
#define ARMARX_CHECK_NOT_NULL(ptr)
This macro evaluates whether ptr is not null and if it turns out to be false it will throw an Express...
void throwIfStateIs(const std::set< RobotUnitState > &stateSet, const std::string &fnc, bool onlyWarn=false) const
Throws an exception if the current state is in.
std::string prefix
Prefix of the properties such as namespace, domain, component name, etc.
void _postFinishRunning()
Hook for deriving RobotUnitModules called in finishRunning (called after the state has changed)
void _preFinishComponentInitialization()
Hook for deriving RobotUnitModules called in finishComponentInitialization (called before the state h...
void _postFinishControlThreadInitialization()
Hook for deriving RobotUnitModules called in finishControlThreadInitialization (called after the stat...
RobotUnitState getRobotUnitState() const
Returns the RobotUnit's State.
virtual void onInitRobotUnit()
called in onInitComponent
void checkDerivedClasses() const
Checks whether the implementing class derives all modules.
void _preOnInitRobotUnit()
Hook for deriving RobotUnitModules called in onInitComponent (called before onInitRobotUnit was calle...
virtual void finishUnitInitialization()
Transition RobotUnitState::InitializingUnits -> RobotUnitState::WaitingForRTThreadInitialization.
bool inControlThread() const
Returns whether the current thread is the ControlThread.
void shutDown()
Requests the RobotUnit to shut down.
std::shared_ptr< Value > value()
static ModuleBase & Instance()
Returns the singleton instance of this class.
void onDisconnectComponent() final override
void componentPropertiesUpdated(const std::set< std::string > &changedProperties) override
virtual IceUtil::Time getControlThreadTargetPeriod() const =0
The ControlThread's period.
std::chrono::high_resolution_clock ClockType
static constexpr std::size_t IndexSentinel()
Returns a sentinel value for an index (std::numeric_limits<std::size_t>::max())
void _postOnExitRobotUnit()
Hook for deriving RobotUnitModules called in onExitComponent (called after onExitRobotUnit was called...
virtual void finishControlThreadInitialization()
Transition RobotUnitState::InitializingControlThread -> RobotUnitState::Running.
GuardType getGuard() const
Returns a guard to the RobotUnits mutex.
virtual void onExitRobotUnit()
called in onExitComponent before calling finishRunning
virtual void onDisconnectRobotUnit()
called in onDisconnecComponent
void _preOnExitRobotUnit()
Hook for deriving RobotUnitModules called in onExitComponent (called before onExitRobotUnit was calle...
virtual void finishRunning()
Transition RobotUnitState::Running -> RobotUnitState::Exiting.
armarx::core::time::DateTime Time
const std::string & to_string(const std::string &s)
virtual void joinControlThread()=0
Implementations have to join their ControlThread in this hook. (used by RobotUnit::finishRunning())
@ InitializingControlThread
Baseclass for all ArmarX ManagedIceObjects requiring properties.
void _icePropertiesInitialized()
Hook for deriving RobotUnitModules called in icePropertiesInitialized.
void _postFinishDeviceInitialization()
Hook for deriving RobotUnitModules called in finishDeviceInitialization (called after the state has c...
void _preFinishDeviceInitialization()
Hook for deriving RobotUnitModules called in finishDeviceInitialization (called before the state has ...
T * _modulePtr()
Returns this as ptr to the given type.
Default component property definition container.
void _postOnConnectRobotUnit()
Hook for deriving RobotUnitModules called in onConnectComponent (called after onConnectRobotUnit was ...
static T & Instance()
Returns the singleton instance of the given class.
bool areDevicesReady() const
Returns whether Devices are ready.
void icePropertiesInitialized() override
std::unique_lock< MutexType > GuardType
std::ostream & operator<<(std::ostream &os, const PythonApplicationManager::Paths &paths)
T & _module()
Returns this as ref to the given type.
void _preOnConnectRobotUnit()
Hook for deriving RobotUnitModules called in onConnectComponent (called before onConnectRobotUnit was...
void throwIfInControlThread(const std::string &fnc) const
Throws if the current thread is the ControlThread.
void _preFinishUnitInitialization()
Hook for deriving RobotUnitModules called in finishUnitInitialization (called before the state has ch...
RobotUnitState
The current state of the multi step initialization of a RobotUnit.
void throwIfDevicesNotReady(const std::string &fnc) const
Throws if the Devices are not ready.
void throwIfStateIsNot(const std::set< RobotUnitState > &stateSet, const std::string &fnc, bool onlyWarn=false) const
Throws an exception if the current state is not in.
void _postFinishUnitInitialization()
Hook for deriving RobotUnitModules called in finishUnitInitialization (called after the state has cha...
virtual void finishComponentInitialization()
Transition RobotUnitState::InitializingComponent -> RobotUnitState::InitializingDevices.
void onInitComponent() final override
void _postOnInitRobotUnit()
Hook for deriving RobotUnitModules called in onInitComponent (called after onInitRobotUnit was called...
virtual void finishDeviceInitialization()
Transition RobotUnitState::InitializingDevices -> RobotUnitState::InitializingUnits.
void _componentPropertiesUpdated(const std::set< std::string > &)
Hook for deriving RobotUnitModules called in componentPropertiesUpdated.
double s(double t, double s0, double v0, double a0, double j)
This file offers overloads of toIce() and fromIce() functions for STL container types.
#define using_module_types(...)
Base class for all RobotUnitModules.
void onConnectComponent() final override
Targ & CheckedCastAndDeref(Src *src)