mirror of
https://gitlab.com/obbart/universal_robots_ros_driver.git
synced 2026-04-10 01:50:46 +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 std::string toString() const;
|
||||
|
||||
template <typename T>
|
||||
/*!
|
||||
* \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.
|
||||
*/
|
||||
template <typename T>
|
||||
bool getData(const std::string& name, T& val)
|
||||
{
|
||||
if (data_.find(name) != data_.end())
|
||||
@@ -107,6 +107,32 @@ public:
|
||||
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:
|
||||
// Const would be better here
|
||||
static std::unordered_map<std::string, _rtde_type_variant> g_type_list;
|
||||
|
||||
Reference in New Issue
Block a user