@@ -560,7 +560,7 @@ bool testutils::toTCPPose(const moveit::core::RobotModelConstPtr& robot_model, c
560
560
561
561
bool testutils::checkOriginalTrajectoryAfterBlending (const pilz_industrial_motion_planner::TrajectoryBlendRequest& req,
562
562
const pilz_industrial_motion_planner::TrajectoryBlendResponse& res,
563
- const double time_tolerance)
563
+ const double /* time_tolerance */ )
564
564
{
565
565
for (std::size_t i = 0 ; i < res.first_trajectory ->getWayPointCount (); ++i)
566
566
{
@@ -679,6 +679,7 @@ bool testutils::checkBlendingJointSpaceContinuity(const pilz_industrial_motion_p
679
679
680
680
// check the continuity between first trajectory and blend trajectory
681
681
trajectory_msgs::msg::JointTrajectoryPoint first_end, blend_start;
682
+ auto first_pend = first_traj.joint_trajectory .points [first_traj.joint_trajectory .points .size () - 2 ];
682
683
first_end = first_traj.joint_trajectory .points .back ();
683
684
blend_start = blend_traj.joint_trajectory .points .front ();
684
685
@@ -709,13 +710,16 @@ bool testutils::checkBlendingJointSpaceContinuity(const pilz_industrial_motion_p
709
710
return false ;
710
711
}
711
712
712
- double blend_start_acc =
713
- (blend_start_velo - first_end.velocities .at (i)) / rclcpp::Duration (blend_start.time_from_start ).seconds ();
714
- if (fabs (blend_start_acc - blend_start.accelerations .at (i)) > joint_velocity_tolerance)
713
+ double blend_start_acc = 2 * (blend_start_velo - first_end.velocities .at (i)) /
714
+ (rclcpp::Duration (blend_start.time_from_start ).seconds () +
715
+ rclcpp::Duration (first_end.time_from_start ).seconds () -
716
+ rclcpp::Duration (first_pend.time_from_start ).seconds ());
717
+ if (fabs (blend_start_acc - blend_start.accelerations .at (i)) > joint_accleration_tolerance)
715
718
{
716
719
std::cout << " Acceleration computed from positions/velocities are "
717
720
" different from the value in trajectory."
718
721
<< ' \n '
722
+ << " position: " << blend_start.positions .at (i) << " ; " << first_end.positions .at (i)
719
723
<< " computed: " << blend_start_acc << " ; "
720
724
<< " in trajectory: " << blend_start.accelerations .at (i) << ' \n ' ;
721
725
return false ;
@@ -724,6 +728,7 @@ bool testutils::checkBlendingJointSpaceContinuity(const pilz_industrial_motion_p
724
728
725
729
// check the continuity between blend trajectory and second trajectory
726
730
trajectory_msgs::msg::JointTrajectoryPoint blend_end, second_start;
731
+ auto blend_pend = blend_traj.joint_trajectory .points [blend_traj.joint_trajectory .points .size () - 2 ];
727
732
blend_end = blend_traj.joint_trajectory .points .back ();
728
733
second_start = second_traj.joint_trajectory .points .front ();
729
734
@@ -746,7 +751,7 @@ bool testutils::checkBlendingJointSpaceContinuity(const pilz_industrial_motion_p
746
751
{
747
752
double second_start_velo = (second_start.positions .at (i) - blend_end.positions .at (i)) /
748
753
rclcpp::Duration (second_start.time_from_start ).seconds ();
749
- if (fabs (second_start_velo - second_start.velocities .at (i)) > joint_accleration_tolerance )
754
+ if (fabs (second_start_velo - second_start.velocities .at (i)) > joint_velocity_tolerance )
750
755
{
751
756
std::cout << " Velocity computed from positions are different from the "
752
757
" value in trajectory."
@@ -756,8 +761,10 @@ bool testutils::checkBlendingJointSpaceContinuity(const pilz_industrial_motion_p
756
761
return false ;
757
762
}
758
763
759
- double second_start_acc =
760
- (second_start_velo - blend_end.velocities .at (i)) / rclcpp::Duration (second_start.time_from_start ).seconds ();
764
+ double second_start_acc = 2 * (second_start_velo - blend_end.velocities .at (i)) /
765
+ (rclcpp::Duration (second_start.time_from_start ).seconds () +
766
+ rclcpp::Duration (blend_end.time_from_start ).seconds () -
767
+ rclcpp::Duration (blend_pend.time_from_start ).seconds ());
761
768
if (fabs (second_start_acc - second_start.accelerations .at (i)) > joint_accleration_tolerance)
762
769
{
763
770
std::cout << " Acceleration computed from positions/velocities are "
@@ -843,9 +850,13 @@ bool testutils::checkBlendingCartSpaceContinuity(const pilz_industrial_motion_pl
843
850
844
851
// check the connection points between first trajectory and blend trajectory
845
852
Eigen::Vector3d v_1, w_1, v_2, w_2, v_3, w_3;
846
- computeCartVelocity (pose_first_end_1, pose_first_end, duration, v_1, w_1);
847
- computeCartVelocity (pose_first_end, pose_blend_start, duration, v_2, w_2);
848
- computeCartVelocity (pose_blend_start, pose_blend_start_1, duration, v_3, w_3);
853
+ double duration_first_end =
854
+ res.first_trajectory ->getWayPointDurationFromPrevious (res.first_trajectory ->getWayPointCount () - 1 );
855
+ double duration_blend_start = res.blend_trajectory ->getWayPointDurationFromPrevious (0 );
856
+ double duration_blend_start_1 = res.blend_trajectory ->getWayPointDurationFromPrevious (1 );
857
+ computeCartVelocity (pose_first_end_1, pose_first_end, duration_first_end, v_1, w_1);
858
+ computeCartVelocity (pose_first_end, pose_blend_start, duration_blend_start, v_2, w_2);
859
+ computeCartVelocity (pose_blend_start, pose_blend_start_1, duration_blend_start_1, v_3, w_3);
849
860
850
861
// translational velocity
851
862
if (v_2.norm () > max_trans_velo)
@@ -854,6 +865,7 @@ bool testutils::checkBlendingCartSpaceContinuity(const pilz_industrial_motion_pl
854
865
" trajectory exceeds the limit."
855
866
<< " Actual velocity (norm): " << v_2.norm () << " ; "
856
867
<< " Limits: " << max_trans_velo << ' \n ' ;
868
+ return false ;
857
869
}
858
870
// rotational velocity
859
871
if (w_2.norm () > max_rot_velo)
@@ -862,65 +874,76 @@ bool testutils::checkBlendingCartSpaceContinuity(const pilz_industrial_motion_pl
862
874
" trajectory exceeds the limit."
863
875
<< " Actual velocity (norm): " << w_2.norm () << " ; "
864
876
<< " Limits: " << max_rot_velo << ' \n ' ;
877
+ return false ;
865
878
}
866
879
// translational acceleration
867
- Eigen::Vector3d a_1 = (v_2 - v_1) / duration ;
868
- Eigen::Vector3d a_2 = (v_3 - v_2) / duration ;
880
+ Eigen::Vector3d a_1 = (v_2 - v_1) / duration_blend_start ;
881
+ Eigen::Vector3d a_2 = (v_3 - v_2) / duration_blend_start_1 ;
869
882
if (a_1.norm () > max_trans_acc || a_2.norm () > max_trans_acc)
870
883
{
871
884
std::cout << " Translational acceleration between first trajectory and "
872
885
" blend trajectory exceeds the limit."
873
- << " Actual acceleration (norm): " << a_1.norm () << " , " << a_1 .norm () << " ; "
886
+ << " Actual acceleration (norm): " << a_1.norm () << " , " << a_2 .norm () << " ; "
874
887
<< " Limits: " << max_trans_acc << ' \n ' ;
888
+ return false ;
875
889
}
876
890
877
891
// rotational acceleration
878
- a_1 = (w_2 - w_1) / duration ;
879
- a_2 = (w_3 - w_2) / duration ;
892
+ a_1 = (w_2 - w_1) / duration_blend_start ;
893
+ a_2 = (w_3 - w_2) / duration_blend_start_1 ;
880
894
if (a_1.norm () > max_rot_acc || a_2.norm () > max_rot_acc)
881
895
{
882
896
std::cout << " Rotational acceleration between first trajectory and blend "
883
897
" trajectory exceeds the limit."
884
- << " Actual acceleration (norm): " << a_1.norm () << " , " << a_1 .norm () << " ; "
898
+ << " Actual acceleration (norm): " << a_1.norm () << " , " << a_2 .norm () << " ; "
885
899
<< " Limits: " << max_rot_acc << ' \n ' ;
900
+ return false ;
886
901
}
887
902
888
- computeCartVelocity (pose_blend_end_1, pose_blend_end, duration, v_1, w_1);
889
- computeCartVelocity (pose_blend_end, pose_second_start, duration, v_2, w_2);
890
- computeCartVelocity (pose_second_start, pose_second_start_1, duration, v_3, w_3);
903
+ double duration_blend_end =
904
+ res.blend_trajectory ->getWayPointDurationFromPrevious (res.blend_trajectory ->getWayPointCount () - 1 );
905
+ double duration_second_start = res.second_trajectory ->getWayPointDurationFromPrevious (0 );
906
+ double duration_second_start_1 = res.second_trajectory ->getWayPointDurationFromPrevious (1 );
907
+ computeCartVelocity (pose_blend_end_1, pose_blend_end, duration_blend_end, v_1, w_1);
908
+ computeCartVelocity (pose_blend_end, pose_second_start, duration_second_start, v_2, w_2);
909
+ computeCartVelocity (pose_second_start, pose_second_start_1, duration_second_start_1, v_3, w_3);
891
910
892
911
if (v_2.norm () > max_trans_velo)
893
912
{
894
913
std::cout << " Translational velocity between blend trajectory and second "
895
914
" trajectory exceeds the limit."
896
915
<< " Actual velocity (norm): " << v_2.norm () << " ; "
897
916
<< " Limits: " << max_trans_velo << ' \n ' ;
917
+ return false ;
898
918
}
899
919
if (w_2.norm () > max_rot_velo)
900
920
{
901
921
std::cout << " Rotational velocity between blend trajectory and second "
902
922
" trajectory exceeds the limit."
903
923
<< " Actual velocity (norm): " << w_2.norm () << " ; "
904
924
<< " Limits: " << max_rot_velo << ' \n ' ;
925
+ return false ;
905
926
}
906
- a_1 = (v_2 - v_1) / duration ;
907
- a_2 = (v_3 - v_2) / duration ;
927
+ a_1 = (v_2 - v_1) / duration_second_start ;
928
+ a_2 = (v_3 - v_2) / duration_second_start_1 ;
908
929
if (a_1.norm () > max_trans_acc || a_2.norm () > max_trans_acc)
909
930
{
910
931
std::cout << " Translational acceleration between blend trajectory and "
911
932
" second trajectory exceeds the limit."
912
- << " Actual acceleration (norm): " << a_1.norm () << " , " << a_1 .norm () << " ; "
933
+ << " Actual acceleration (norm): " << a_1.norm () << " , " << a_2 .norm () << " ; "
913
934
<< " Limits: " << max_trans_acc << ' \n ' ;
935
+ return false ;
914
936
}
915
937
// check rotational acceleration
916
- a_1 = (w_2 - w_1) / duration ;
917
- a_2 = (w_3 - w_2) / duration ;
938
+ a_1 = (w_2 - w_1) / duration_second_start ;
939
+ a_2 = (w_3 - w_2) / duration_second_start_1 ;
918
940
if (a_1.norm () > max_rot_acc || a_2.norm () > max_rot_acc)
919
941
{
920
942
std::cout << " Rotational acceleration between blend trajectory and second "
921
943
" trajectory exceeds the limit."
922
- << " Actual acceleration (norm): " << a_1.norm () << " , " << a_1 .norm () << " ; "
944
+ << " Actual acceleration (norm): " << a_1.norm () << " , " << a_2 .norm () << " ; "
923
945
<< " Limits: " << max_rot_acc << ' \n ' ;
946
+ return false ;
924
947
}
925
948
926
949
return true ;
0 commit comments