Fixposition SDK 0.0.0-heads/main-0-g97f6014
Collection of c++ libraries and apps for use with Fixposition products on Linux
Loading...
Searching...
No Matches
fpl_ros1.hpp
Go to the documentation of this file.
1/**
2 * \verbatim
3 * ___ ___
4 * \ \ / /
5 * \ \/ / Copyright (c) Fixposition AG (www.fixposition.com) and contributors
6 * / /\ \ License: see the LICENSE file
7 * /__/ \__\
8 * \endverbatim
9 *
10 * @file
11 * @brief Fixposition SDK: to_json() helpers for some fpsdk::common::fpl::RosMsgBin
12 */
13#ifndef __FPSDK_COMMON_TO_JSON_FPL_ROS1_HPP__
14#define __FPSDK_COMMON_TO_JSON_FPL_ROS1_HPP__
15
16/* LIBC/STL */
17
18/* EXTERNAL */
19#include <nlohmann/json.hpp>
20
21/* PACKAGE */
22#include "../fpl.hpp"
23#include "../ros1.hpp"
24#include "../string.hpp"
25#include "ros1.hpp"
26
27#ifndef _DOXYGEN_ // not documenting these
28/* ****************************************************************************************************************** */
29namespace fpsdk::common::fpl {
30
31template <typename RosMsgT>
32inline bool RosMsgToJson(const RosMsgDef& def, const RosMsgBin& bin, nlohmann::json& json)
33{
34 if (def.msg_name_ == ros::message_traits::datatype<RosMsgT>()) {
35 RosMsgT msg;
36 ros1::DeserializeMessage(bin.msg_data_, msg); // This can throw!
37 json = msg;
38 return true;
39 }
40 return false;
41}
42
43} // namespace fpsdk::common::fpl
44/* ****************************************************************************************************************** */
45#endif // !_DOXYGEN_
46#endif // __FPSDK_COMMON_TO_JSON_FPL_ROS1_HPP__
Fixposition SDK: .fpl utilities.
Fixposition SDK: ROS1 types and utils.
Fixposition SDK: to_json() helpers for some ROS1 types.
.fpl utilities
Definition fpl.hpp:38
void DeserializeMessage(const std::vector< uint8_t > &buf, RosMsgT &msg)
Deserialise ROS1 message.
Definition ros1.hpp:115
Fixposition SDK: String utilities.
Helper for extracting a serialised ROS message.
Definition fpl.hpp:359
Helper for extracting ROS message definition (the relevant fields from the "connection header")
Definition fpl.hpp:336