diff options
-rw-r--r-- | src/platforms/px4_parameter.h | 40 |
1 files changed, 37 insertions, 3 deletions
diff --git a/src/platforms/px4_parameter.h b/src/platforms/px4_parameter.h index 464a84f51..6b5453d77 100644 --- a/src/platforms/px4_parameter.h +++ b/src/platforms/px4_parameter.h @@ -43,6 +43,7 @@ #include <string> #else /* includes when building for NuttX */ +#include <systemlib/param/param.h> #endif namespace px4 @@ -96,7 +97,6 @@ public: /** * Update the parameter value - * Nothing to do for ROS */ T update() { @@ -113,11 +113,45 @@ public: } }; +#else +template <typename T> +class Parameter : + public ParameterBase<T> +{ +public: + Parameter(const char *name, T value) : + ParameterBase<T>(name, value), + _handle(param_find(name)) + { + } + ~Parameter() {}; -#else + /** + * Update the parameter value + */ + T update() + { + if (_handle != PARAM_INVALID) { + param_get(_handle, &(this->_value)); + } + return get(); + } + + /** + * Get the current parameter value + */ + T get() + { + return this->_value; + } + +protected: + param_t _handle; + +}; #endif -typedef Parameter<double> ParameterFloat; +typedef Parameter<float> ParameterFloat; typedef Parameter<int> ParameterInt; } |