11 #include <boost/algorithm/string/predicate.hpp> 12 #include <boost/algorithm/string.hpp> 16 rcutils_uint8_array_t msg_ref;
17 msg_ref.buffer = serialized_msg.
data();
18 msg_ref.buffer_length = serialized_msg.
size();
26 timestamp = sec + (nsec * 1e-9);
30 bool header_found =
false;
37 if( boost::algorithm::ends_with(key,
"/header/stamp/sec" ) )
40 if( boost::algorithm::ends_with(key,
"/header/stamp/nanosec" ) )
43 double header_stamp =
_flat_msg.values[0].second +
46 constexpr
size_t suffix_length =
sizeof(
"/nanosec") - 1;
48 auto new_name = key.substr(0, key.size() - suffix_length );
50 series.pushBack({ timestamp, header_stamp });
55 for (
size_t i = header_found ? 2:0;
i <
_flat_msg.values.size();
i++)
63 if (!std::isnan(value) && !std::isinf(value))
65 series.pushBack({ timestamp, value });
73 series.pushBack({ timestamp,
it.second });
82 const std::string& topic_type)
84 std::shared_ptr<RosMessageParser>
parser;
85 if (_parsers.count(topic_name) > 0)
90 std::string
type = topic_type;
93 size_t str_index = type.find(
"/msg/", 0);
94 if (str_index != std::string::npos)
96 type.erase(str_index, 4);
99 if (type ==
"sensor_msgs/JointState")
103 else if (type ==
"diagnostic_msgs/DiagnosticArray")
107 else if (type ==
"tf2_msgs/TFMessage")
111 else if (type ==
"geometry_msgs/Quaternion")
115 else if (type ==
"sensor_msgs/Imu")
119 else if (type ==
"nav_msgs/Odometry")
123 else if (type ==
"geometry_msgs/Pose")
127 else if (type ==
"geometry_msgs/PoseStamped")
131 else if (type ==
"geometry_msgs/PoseWithCovariance")
135 else if (type ==
"geometry_msgs/Twist")
139 else if (type ==
"geometry_msgs/TwistStamped")
143 else if (type ==
"geometry_msgs/TwistWithCovariance")
147 else if (type ==
"plotjuggler_msgs/Dictionary")
151 else if (type ==
"plotjuggler_msgs/DataPoints")
155 else if (type ==
"plotjuggler_msgs/StatisticsNames")
159 else if (type ==
"plotjuggler_msgs/StatisticsValues")
163 else if (type ==
"pal_statistics_msgs/StatisticsNames")
167 else if (type ==
"pal_statistics_msgs/StatisticsValues")
177 _parsers.insert({ topic_name, parser });
180 const rosidl_message_type_support_t *
183 auto it = _parsers.find(topic_name);
184 if (
it == _parsers.end())
188 if(
auto parser = dynamic_cast<Ros2MessageParser*>(
it->second.get()))
190 return parser->typeSupport();
const TopicInfo & topicInfo() const
bool deserializeIntoFlatMessage(const rcutils_uint8_array_t *msg, FlatMessage *flat_container_output) const
PJ::StringSeries & getStringSeries(const std::string &key)
PlotDataMapRef & _plot_data
PJ::PlotData & getSeries(const std::string &key)
virtual bool parseMessage(MessageRef serialized_msg, double ×tamp) override
void registerMessageType(const std::string &topic_name, const std::string &topic_type)
IntrospectionParser(const std::string &topic_name, const std::string &topic_type, const std::string &definition, PJ::PlotDataMapRef &plot_data)
const rosidl_message_type_support_t * typeSupport(const std::string &topic_name) const
TfMsgParserImpl< tf::tfMessage > TfMsgParser
RosIntrospection::FlatMessage _flat_msg
Ros2Introspection::Parser _intropection_parser
const uint8_t * data() const