1 #include <gtest/gtest.h> 19 for (
double t = 0.1; t <= 6; t += 0.1)
22 else if (t < 2) y += 1;
23 else if (t < 3) x -= 1;
24 else if (t < 4) y -= 1;
25 else if (t < 5) z += 1;
34 tw_.header.frame_id =
"bar";
35 tw_.twist.linear.x = 1;
36 tw_.twist.linear.y = 2;
37 tw_.twist.linear.z = 3;
38 tw_.twist.angular.x = 0;
39 tw_.twist.angular.y = 0;
40 tw_.twist.angular.z = 0;
65 geometry_msgs::TwistStamped
tw_;
79 for (
double t = 0.1; t < 6; t += 0.1)
82 else if (t < 2) x -= .1;
83 else if (t < 3) y += .1;
84 else if (t < 4) y -= .1;
85 else if (t < 5) z += .1;
95 tw_x.header.frame_id =
"bar";
96 tw_x.twist.angular.x = 1;
99 tw_y.header.frame_id =
"bar";
100 tw_y.twist.angular.y = 1;
103 tw_z.header.frame_id =
"bar";
104 tw_z.twist.angular.z = 1;
127 geometry_msgs::TwistStamped tw_x, tw_y,
tw_z;
132 geometry_msgs::TwistStamped tw;
133 geometry_msgs::TwistStamped tw_in =tw_;
135 std::vector<std::string> offset_frames;
137 offset_frames.push_back(
"foo");
138 offset_frames.push_back(
"stationary_offset_child");
139 offset_frames.push_back(
"stationary_offset_parent");
142 for (std::vector<std::string>::iterator it = offset_frames.begin(); it != offset_frames.end(); ++it)
147 tf_.transformTwist(*it, tw_in, tw);
148 EXPECT_FLOAT_EQ(11.0, tw.twist.linear.x);
149 EXPECT_FLOAT_EQ(2.0 , tw.twist.linear.y);
150 EXPECT_FLOAT_EQ(3.0, tw.twist.linear.z);
151 EXPECT_FLOAT_EQ(0.0, tw.twist.angular.x);
152 EXPECT_FLOAT_EQ(0.0, tw.twist.angular.y);
153 EXPECT_FLOAT_EQ(0.0, tw.twist.angular.z);
156 tf_.transformTwist(*it, tw_in, tw);
157 EXPECT_FLOAT_EQ(1.0, tw.twist.linear.x);
158 EXPECT_FLOAT_EQ(12.0, tw.twist.linear.y);
159 EXPECT_FLOAT_EQ(3.0, tw.twist.linear.z);
160 EXPECT_FLOAT_EQ(0.0, tw.twist.angular.x);
161 EXPECT_FLOAT_EQ(0.0, tw.twist.angular.y);
162 EXPECT_FLOAT_EQ(0.0, tw.twist.angular.z);
165 tf_.transformTwist(*it, tw_in, tw);
166 EXPECT_FLOAT_EQ(-9.0, tw.twist.linear.x);
167 EXPECT_FLOAT_EQ(2.0, tw.twist.linear.y);
168 EXPECT_FLOAT_EQ(3.0, tw.twist.linear.z);
169 EXPECT_FLOAT_EQ(tw.twist.angular.x, 0.0);
170 EXPECT_FLOAT_EQ(tw.twist.angular.y, 0.0);
171 EXPECT_FLOAT_EQ(tw.twist.angular.z, 0.0);
174 tf_.transformTwist(*it, tw_in, tw);
175 EXPECT_FLOAT_EQ(tw.twist.linear.x, 1.0);
176 EXPECT_FLOAT_EQ(tw.twist.linear.y, -8.0);
177 EXPECT_FLOAT_EQ(tw.twist.linear.z, 3.0);
178 EXPECT_FLOAT_EQ(tw.twist.angular.x, 0.0);
179 EXPECT_FLOAT_EQ(tw.twist.angular.y, 0.0);
180 EXPECT_FLOAT_EQ(tw.twist.angular.z, 0.0);
183 tf_.transformTwist(*it, tw_in, tw);
184 EXPECT_FLOAT_EQ(tw.twist.linear.x, 1.0);
185 EXPECT_FLOAT_EQ(tw.twist.linear.y, 2.0);
186 EXPECT_FLOAT_EQ(tw.twist.linear.z, 13.0);
187 EXPECT_FLOAT_EQ(tw.twist.angular.x, 0.0);
188 EXPECT_FLOAT_EQ(tw.twist.angular.y, 0.0);
189 EXPECT_FLOAT_EQ(tw.twist.angular.z, 0.0);
192 tf_.transformTwist(*it, tw_in, tw);
193 EXPECT_FLOAT_EQ(tw.twist.linear.x, 1.0);
194 EXPECT_FLOAT_EQ(tw.twist.linear.y, 2.0);
195 EXPECT_FLOAT_EQ(tw.twist.linear.z, -7.0);
196 EXPECT_FLOAT_EQ(tw.twist.angular.x, 0.0);
197 EXPECT_FLOAT_EQ(tw.twist.angular.y, 0.0);
198 EXPECT_FLOAT_EQ(tw.twist.angular.z, 0.0);
202 EXPECT_STREQ(
"", ex.what());
210 geometry_msgs::TwistStamped tw;
211 geometry_msgs::TwistStamped tw_in;
218 tf_.transformTwist(
"foo", tw_in, tw);
219 EXPECT_NEAR(tw.twist.linear.x, 0.0, epsilon);
220 EXPECT_NEAR(tw.twist.linear.y, 0.0, epsilon);
221 EXPECT_NEAR(tw.twist.linear.z, 0.0, epsilon);
222 EXPECT_NEAR(tw.twist.angular.x, 2.0, epsilon);
223 EXPECT_NEAR(tw.twist.angular.y, 0.0, epsilon);
224 EXPECT_NEAR(tw.twist.angular.z, 0.0, epsilon);
229 tf_.transformTwist(
"foo", tw_in, tw);
230 EXPECT_NEAR(tw.twist.linear.x, 0.0, epsilon);
231 EXPECT_NEAR(tw.twist.linear.y, 0.0, epsilon);
232 EXPECT_NEAR(tw.twist.linear.z, 0.0, epsilon);
233 EXPECT_NEAR(tw.twist.angular.x, 0.0, epsilon);
234 EXPECT_NEAR(tw.twist.angular.y, 0.0, epsilon);
235 EXPECT_NEAR(tw.twist.angular.z, 0.0, epsilon);
240 tf_.transformTwist(
"foo", tw_in, tw);
241 EXPECT_NEAR(tw.twist.linear.x, 0.0, epsilon);
242 EXPECT_NEAR(tw.twist.linear.y, 0.0, epsilon);
243 EXPECT_NEAR(tw.twist.linear.z, 0.0, epsilon);
244 EXPECT_NEAR(tw.twist.angular.x, 0.0, epsilon);
245 EXPECT_NEAR(tw.twist.angular.y, 2.0, epsilon);
246 EXPECT_NEAR(tw.twist.angular.z, 0.0, epsilon);
251 tf_.transformTwist(
"foo", tw_in, tw);
252 EXPECT_NEAR(tw.twist.linear.x, 0.0, epsilon);
253 EXPECT_NEAR(tw.twist.linear.y, 0.0, epsilon);
254 EXPECT_NEAR(tw.twist.linear.z, 0.0, epsilon);
255 EXPECT_NEAR(tw.twist.angular.x, 0.0, epsilon);
256 EXPECT_NEAR(tw.twist.angular.y, 0.0, epsilon);
257 EXPECT_NEAR(tw.twist.angular.z, 0.0, epsilon);
262 tf_.transformTwist(
"foo", tw_in, tw);
263 EXPECT_NEAR(tw.twist.linear.x, 0.0, epsilon);
264 EXPECT_NEAR(tw.twist.linear.y, 0.0, epsilon);
265 EXPECT_NEAR(tw.twist.linear.z, 0.0, epsilon);
266 EXPECT_NEAR(tw.twist.angular.x, 0.0, epsilon);
267 EXPECT_NEAR(tw.twist.angular.y, 0.0, epsilon);
268 EXPECT_NEAR(tw.twist.angular.z, 2.0, epsilon);
273 tf_.transformTwist(
"foo", tw_in, tw);
274 EXPECT_NEAR(tw.twist.linear.x, 0.0, epsilon);
275 EXPECT_NEAR(tw.twist.linear.y, 0.0, epsilon);
276 EXPECT_NEAR(tw.twist.linear.z, 0.0, epsilon);
277 EXPECT_NEAR(tw.twist.angular.x, 0.0, epsilon);
278 EXPECT_NEAR(tw.twist.angular.y, 0.0, epsilon);
279 EXPECT_NEAR(tw.twist.angular.z, 0.0, epsilon);
283 EXPECT_STREQ(
"", ex.what());
408 int main(
int argc,
char **argv){
409 testing::InitGoogleTest(&argc, argv);
410 ros::init(argc, argv,
"testing_transform_twist");
411 return RUN_ALL_TESTS();
static tf::Quaternion createQuaternionFromRPY(double roll, double pitch, double yaw)
construct a Quaternion from Fixed angles
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
static tf::Quaternion createIdentityQuaternion()
construct an Identity Quaternion