-
Notifications
You must be signed in to change notification settings - Fork 50
Description
I was looking for a way to transfer data between states. In particular a std::filesystem::path
and a Eigen::Isometry3d
object.
For this purpose, I came across the setGlobalSMData
and getGlobalSMData
functions that the state machine support. As the functions are templated, it looked like they would support any type.
However, when I try to store an Eigen::Isometry3d
object using setGlobalSMData
, I get the following error:
error: no match for ‘operator<<’ (operand types are ‘std::stringstream’ {aka ‘std::__cxx11::basic_stringstream<char>’} and ‘Eigen::Transform<double, 3, 1>’)
The source code for setGlobalSMData
:
SMACC/smacc/include/smacc/impl/smacc_state_machine_impl.h
Lines 208 to 224 in e5abc09
void ISmaccStateMachine::setGlobalSMData(std::string name, T value) | |
{ | |
{ | |
std::lock_guard<std::recursive_mutex> lock(m_mutex_); | |
// ROS_WARN("set SM Data lock acquire"); | |
globalData_[name] = {[this, name]() { | |
std::stringstream ss; | |
auto val = any_cast<T>(globalData_[name].second); | |
ss << val; | |
return ss.str(); | |
}, | |
value}; | |
} | |
this->updateStatusMessage(); | |
} |
The build error is due to the val
object (casted to Eigen::Isometry3d
) being inserted into the stream. As the object does not define a <<
operator, this results in the abovementioned error.
Why is globalData_
of type std::map<std::string, std::pair<std::function<std::string()>, boost::any>>
and not just std::map<std::string, boost::any>>
? The first element of the std::pair
is not used in getGlobalSMData
so I am not sure why we need the function object.