5 #include <nav_msgs/Odometry.h> 14 _data.emplace_back(
"/header/seq" );
15 _data.emplace_back(
"/header/stamp" );
17 _data.emplace_back(
"/pose/position/x" );
18 _data.emplace_back(
"/pose/position/y" );
19 _data.emplace_back(
"/pose/position/z" );
21 _data.emplace_back(
"/pose/orientation/quat_x" );
22 _data.emplace_back(
"/pose/orientation/quat_y" );
23 _data.emplace_back(
"/pose/orientation/quat_z" );
24 _data.emplace_back(
"/pose/orientation/quat_w" );
25 _data.emplace_back(
"/pose/orientation/yaw_degrees" );
27 _data.emplace_back(
"/twist/linear/x" );
28 _data.emplace_back(
"/twist/linear/y" );
29 _data.emplace_back(
"/twist/linear/z" );
31 _data.emplace_back(
"/twist/angular/x" );
32 _data.emplace_back(
"/twist/angular/y" );
33 _data.emplace_back(
"/twist/angular/z" );
50 double timestamp)
override 52 nav_msgs::Odometry odom;
58 timestamp = odom.header.stamp.toSec();
62 _data[0].pushBack( {timestamp,
static_cast<double>(odom.header.seq)} );
63 _data[1].pushBack( {timestamp, odom.header.stamp.toSec()} );
65 _data[2].pushBack( {timestamp, odom.pose.pose.position.x} );
66 _data[3].pushBack( {timestamp, odom.pose.pose.position.y} );
67 _data[4].pushBack( {timestamp, odom.pose.pose.position.z} );
70 const auto& q = odom.pose.pose.orientation;
71 _data[5].pushBack( {timestamp, q.x} );
72 _data[6].pushBack( {timestamp, q.y} );
73 _data[7].pushBack( {timestamp, q.z} );
74 _data[8].pushBack( {timestamp, q.w} );
77 double siny_cosp = +2.0 * (q.w * q.z + q.x * q.y);
78 double cosy_cosp = +1.0 - 2.0 * (q.y * q.y + q.z * q.z);
79 double yaw = atan2(siny_cosp, cosy_cosp) * 180 / M_PI;
87 if( prev_yaw - yaw > 355 )
89 else if( yaw - prev_yaw > 355)
95 _data[10].pushBack( {timestamp, odom.twist.twist.linear.x} );
96 _data[11].pushBack( {timestamp, odom.twist.twist.linear.y} );
97 _data[12].pushBack( {timestamp, odom.twist.twist.linear.z} );
99 _data[13].pushBack( {timestamp, odom.twist.twist.angular.x} );
100 _data[14].pushBack( {timestamp, odom.twist.twist.angular.y} );
101 _data[15].pushBack( {timestamp, odom.twist.twist.angular.z} );
107 for (
auto& it:
_data)
118 #endif // ODOMETRY_MSG_H std::vector< PlotData > _data
static const std::string & getCompatibleKey()
void extractData(PlotDataMapRef &plot_map, const std::string &prefix) override
const std::unordered_set< std::string > & getCompatibleKeys() const override
const uint8_t * data() const
static const char * value()
virtual void pushMessageRef(const std::string &, const MessageRef &msg, double timestamp) override
static void appendData(PlotDataMapRef &destination_plot_map, const std::string &field_name, PlotData &in_data)
void deserialize(Stream &stream, T &t)