diff --git a/source/RobotAPI/components/units/RobotUnit/Devices/SensorDevice.h b/source/RobotAPI/components/units/RobotUnit/Devices/SensorDevice.h index 5b9cb4e877f050e22b9d5aa7cab0a05bc3bf8b8c..5019b20033007109c26b2ac878f37e556547706e 100644 --- a/source/RobotAPI/components/units/RobotUnit/Devices/SensorDevice.h +++ b/source/RobotAPI/components/units/RobotUnit/Devices/SensorDevice.h @@ -65,6 +65,13 @@ namespace armarx /// @return The SensorDevice's sensor value virtual const SensorValueBase* getSensorValue() const = 0; + /// @return The SensorDevice's sensor value casted to the given type (may be nullptr) + template<class T> + const T* getSensorValue() const + { + return getSensorValue()->asA<const T*>(); + } + /** * @brief Returns the \ref SensorValueBase "SensorValue's" type as a string. * @param withoutNamespaceSpecifier Whether namespace specifiers should be removed from the name. diff --git a/source/RobotAPI/components/units/RobotUnit/JointControllers/JointController.h b/source/RobotAPI/components/units/RobotUnit/JointControllers/JointController.h index 1fdb7fe24cb99964f5ae9ad019154d40ce062b6d..4d12be87a3b3a9fb92b7abdf7f4fdb8f5cfc3158 100644 --- a/source/RobotAPI/components/units/RobotUnit/JointControllers/JointController.h +++ b/source/RobotAPI/components/units/RobotUnit/JointControllers/JointController.h @@ -46,6 +46,13 @@ namespace armarx virtual const ControlTargetBase* getControlTarget() const; + /// @return The \ref JointController's \ref ControlTargetBase "ControlTarget" casted to the given type (may be nullptr) + template<class T> + const T* getControlTarget() const + { + return getControlTarget()->asA<const T*>(); + } + virtual void rtResetTarget(); virtual bool rtIsTargetVaild() const;