ROSCPP - reading HZ from code
Hi Guys,
trying to figure out a way to read a HZ data of a rostopic in my C++ code. I see that there is no API for it, so I am trying to execute the cmd by using popen and reading from the file. However since it is a constant stream it makes the process to halt. Any idea what is the right way to do it? I need only one "iteration" of the data.
this is my current method that works for other calls:
std::string MyClass::InvokeCmd(std::string command)
{
std::string result;
std::array<char, 128> buffer;
FILE *pipe = popen(command.c_str(), "r");
while (fgets(buffer.data(), 128, pipe) != NULL)
{
result += buffer.data();
}
}
pclose(pipe);
return result;
}
?
such as the avg rate, the min and the max....@gvdhoorn, do have any suggestion or tip?