mirror of
https://gitlab.com/obbart/universal_robots_ros_driver.git
synced 2026-04-10 10:00:48 +02:00
added function to get rtde data as bitset
This commit is contained in:
@@ -82,7 +82,6 @@ public:
|
|||||||
virtual bool parseWith(comm::BinParser& bp);
|
virtual bool parseWith(comm::BinParser& bp);
|
||||||
virtual std::string toString() const;
|
virtual std::string toString() const;
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Get a data field from the DataPackage.
|
* \brief Get a data field from the DataPackage.
|
||||||
*
|
*
|
||||||
@@ -93,6 +92,7 @@ public:
|
|||||||
*
|
*
|
||||||
* \returns True on success, false if the field cannot be found inside the package.
|
* \returns True on success, false if the field cannot be found inside the package.
|
||||||
*/
|
*/
|
||||||
|
template <typename T>
|
||||||
bool getData(const std::string& name, T& val)
|
bool getData(const std::string& name, T& val)
|
||||||
{
|
{
|
||||||
if (data_.find(name) != data_.end())
|
if (data_.find(name) != data_.end())
|
||||||
@@ -107,6 +107,32 @@ public:
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Get a data field from the DataPackage as bitset
|
||||||
|
*
|
||||||
|
* The data package contains a lot of different data fields, depending on the recipe.
|
||||||
|
*
|
||||||
|
* \param name The string identifier for the data field as used in the documentation.
|
||||||
|
* \param val Target variable. Make sure, it's the correct type.
|
||||||
|
*
|
||||||
|
* \returns True on success, false if the field cannot be found inside the package.
|
||||||
|
*/
|
||||||
|
template <typename T, size_t N>
|
||||||
|
bool getData(const std::string& name, std::bitset<N>& val)
|
||||||
|
{
|
||||||
|
static_assert(sizeof(T) * 8 >= N, "Bitset is too large for underlying variable");
|
||||||
|
|
||||||
|
if (data_.find(name) != data_.end())
|
||||||
|
{
|
||||||
|
val = std::bitset<N>(boost::strict_get<T>(data_[name]));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Const would be better here
|
// Const would be better here
|
||||||
static std::unordered_map<std::string, _rtde_type_variant> g_type_list;
|
static std::unordered_map<std::string, _rtde_type_variant> g_type_list;
|
||||||
|
|||||||
Reference in New Issue
Block a user