@@ -172,6 +172,38 @@ TEST(FloatingJointTest, interpolation_test)
172172 }
173173}
174174
175+ TEST (PlanarJointTest, ComputeVariablePositionsNormalizeYaw)
176+ {
177+ // Create a simple planar joint model with some dummy parameters
178+ moveit::core::PlanarJointModel pjm (" joint" , 0 , 0 );
179+
180+ // Test various angles for normalization
181+ std::vector<double > test_angles = { 0.0 , M_PI / 2 , -M_PI / 2 , M_PI, -M_PI, 3.0 , -3.0 , 4.1 , -4.1 };
182+ for (double angle : test_angles)
183+ {
184+ // Create a transform with the given yaw angle
185+ Eigen::Isometry3d transform = Eigen::Isometry3d::Identity ();
186+ Eigen::AngleAxisd q = Eigen::AngleAxisd (angle, Eigen::Vector3d::UnitZ ());
187+ transform.linear () = q.toRotationMatrix ();
188+
189+ // Compute the variable positions from the transform
190+ double joint_values[3 ];
191+ pjm.computeVariablePositions (transform, joint_values);
192+
193+ // Check that the x and y values are zero (since we didn't set any translation)
194+ EXPECT_NEAR (joint_values[0 ], 0.0 , 1e-6 );
195+ EXPECT_NEAR (joint_values[1 ], 0.0 , 1e-6 );
196+
197+ // The yaw value should be normalized to the range [-pi, pi]
198+ double normalized_angle = angle;
199+ while (normalized_angle > M_PI)
200+ normalized_angle -= 2.0 * M_PI;
201+ while (normalized_angle < -M_PI)
202+ normalized_angle += 2.0 * M_PI;
203+ EXPECT_NEAR (joint_values[2 ], normalized_angle, 1e-6 );
204+ }
205+ }
206+
175207int main (int argc, char ** argv)
176208{
177209 testing::InitGoogleTest (&argc, argv);
0 commit comments