39#include <tf2_geometry_msgs/tf2_geometry_msgs.h>
58 const geometry_msgs::msg::PoseWithCovariance::_covariance_type & cov_in,
59 const tf2::Transform & transform)
79 const tf2::Matrix3x3 R = transform.getBasis();
80 const tf2::Matrix3x3 R_transpose = R.transpose();
84 const tf2::Matrix3x3 cov_11(cov_in[0], cov_in[1], cov_in[2],
85 cov_in[6], cov_in[7], cov_in[8],
86 cov_in[12], cov_in[13], cov_in[14]);
87 const tf2::Matrix3x3 cov_12(cov_in[3], cov_in[4], cov_in[5],
88 cov_in[9], cov_in[10], cov_in[11],
89 cov_in[15], cov_in[16], cov_in[17]);
90 const tf2::Matrix3x3 cov_21(cov_in[18], cov_in[19], cov_in[20],
91 cov_in[24], cov_in[25], cov_in[26],
92 cov_in[30], cov_in[31], cov_in[32]);
93 const tf2::Matrix3x3 cov_22(cov_in[21], cov_in[22], cov_in[23],
94 cov_in[27], cov_in[28], cov_in[29],
95 cov_in[33], cov_in[34], cov_in[35]);
99 const tf2::Matrix3x3 result_11 = R * cov_11 * R_transpose;
100 const tf2::Matrix3x3 result_12 = R * cov_12 * R_transpose;
101 const tf2::Matrix3x3 result_21 = R * cov_21 * R_transpose;
102 const tf2::Matrix3x3 result_22 = R * cov_22 * R_transpose;
105 geometry_msgs::msg::PoseWithCovariance::_covariance_type cov_out;
106 cov_out[0] = result_11[0][0];
107 cov_out[1] = result_11[0][1];
108 cov_out[2] = result_11[0][2];
109 cov_out[6] = result_11[1][0];
110 cov_out[7] = result_11[1][1];
111 cov_out[8] = result_11[1][2];
112 cov_out[12] = result_11[2][0];
113 cov_out[13] = result_11[2][1];
114 cov_out[14] = result_11[2][2];
116 cov_out[3] = result_12[0][0];
117 cov_out[4] = result_12[0][1];
118 cov_out[5] = result_12[0][2];
119 cov_out[9] = result_12[1][0];
120 cov_out[10] = result_12[1][1];
121 cov_out[11] = result_12[1][2];
122 cov_out[15] = result_12[2][0];
123 cov_out[16] = result_12[2][1];
124 cov_out[17] = result_12[2][2];
126 cov_out[18] = result_21[0][0];
127 cov_out[19] = result_21[0][1];
128 cov_out[20] = result_21[0][2];
129 cov_out[24] = result_21[1][0];
130 cov_out[25] = result_21[1][1];
131 cov_out[26] = result_21[1][2];
132 cov_out[30] = result_21[2][0];
133 cov_out[31] = result_21[2][1];
134 cov_out[32] = result_21[2][2];
136 cov_out[21] = result_22[0][0];
137 cov_out[22] = result_22[0][1];
138 cov_out[23] = result_22[0][2];
139 cov_out[27] = result_22[1][0];
140 cov_out[28] = result_22[1][1];
141 cov_out[29] = result_22[1][2];
142 cov_out[33] = result_22[2][0];
143 cov_out[34] = result_22[2][1];
144 cov_out[35] = result_22[2][2];
geometry_msgs::msg::PoseWithCovariance::_covariance_type transformCovariance(const geometry_msgs::msg::PoseWithCovariance::_covariance_type &cov_in, const tf2::Transform &transform)
Transform the covariance matrix of a PoseWithCovariance message to a new frame.