1 #ifndef FRAMEFAB_PARAM_HELPERS_H 2 #define FRAMEFAB_PARAM_HELPERS_H 11 template <
class T>
inline bool toFile(
const std::string& path,
const T& msg)
14 uint32_t serialize_size = ser::serializationLength(msg);
17 ser::OStream stream(buffer.get(), serialize_size);
18 ser::serialize(stream, msg);
20 std::ofstream file(path.c_str(), std::ios::out | std::ios::binary);
27 file.write((
char*)buffer.get(), serialize_size);
33 template <
class T>
inline bool fromFile(
const std::string& path, T& msg)
37 std::ifstream ifs(path.c_str(), std::ios::in | std::ios::binary);
43 ifs.seekg(0, std::ios::end);
44 std::streampos end = ifs.tellg();
45 ifs.seekg(0, std::ios::beg);
46 std::streampos begin = ifs.tellg();
48 uint32_t file_size = end - begin;
51 ifs.read((
char*)ibuffer.get(), file_size);
52 ser::IStream istream(ibuffer.get(), file_size);
53 ser::deserialize(istream, msg);
bool loadBoolParam(ros::NodeHandle &nh, const std::string &name, uint8_t &value)
bool fromFile(const std::string &path, T &msg)
bool loadParam(ros::NodeHandle &nh, const std::string &name, T &value)
bool toFile(const std::string &path, const T &msg)
const std::string & getNamespace() const
#define ROS_WARN_STREAM(args)
bool getParam(const std::string &key, std::string &s) const