@@ -642,15 +642,19 @@ void Ros_ActionServer_FJT_Goal_Complete(GOAL_END_TYPE goal_end_type)
642
642
643
643
//'parse' the JointTolerance elements from the goal. Map their 'name:tolerance'
644
644
//to the 'joint_index:tolerance' we need
645
- STATUS status = Ros_ActionServer_FJT_Parse_GoalPosTolerances (
645
+ STATUS statusParseGoalTolerance = Ros_ActionServer_FJT_Parse_GoalPosTolerances (
646
646
& g_actionServer_FJT_SendGoal_Request .goal .goal_tolerance ,
647
647
& feedback_FollowJointTrajectory .feedback .joint_names ,
648
648
posTolerance , numAxesToCheck );
649
649
650
- if (status != OK )
650
+ BOOL bToleranceParseOk = TRUE;
651
+ if (statusParseGoalTolerance != OK )
651
652
{
652
- Ros_Debug_BroadcastMsg ("%s: parsing 'goal_tolerance' field failed: %d" , __func__ , status );
653
- //TODO(gavanderhoorn): what do we do here?
653
+ Ros_Debug_BroadcastMsg ("%s: parsing 'goal_tolerance' field failed: %d" , __func__ , statusParseGoalTolerance );
654
+ //TODO(gavanderhoorn): implement tolerance parsing in Ros_ActionServer_FJT_Goal_Received(..) instead
655
+ bToleranceParseOk = FALSE;
656
+ Ros_Debug_BroadcastMsg ("%s: skipping goal tolerance check" , __func__ );
657
+ goto goal_complete_skip_tolerance_comparison ;
654
658
}
655
659
656
660
//retrieve the last traj pt from the goal traj and re-order position values such
@@ -660,17 +664,20 @@ void Ros_ActionServer_FJT_Goal_Complete(GOAL_END_TYPE goal_end_type)
660
664
bzero (lastTrajPtPositions , sizeof (lastTrajPtPositions ));
661
665
size_t finalTrajPtIdx = g_actionServer_FJT_SendGoal_Request .goal .trajectory .points .size - 1 ;
662
666
663
- status = Ros_ActionServer_FJT_Reorder_TrajPt_To_Internal_Order (
667
+ STATUS statusGoalToleranceReorder = Ros_ActionServer_FJT_Reorder_TrajPt_To_Internal_Order (
664
668
& g_actionServer_FJT_SendGoal_Request .goal .trajectory .points .data [finalTrajPtIdx ],
665
669
& g_actionServer_FJT_SendGoal_Request .goal .trajectory .joint_names ,
666
670
& feedback_FollowJointTrajectory .feedback .joint_names ,
667
671
lastTrajPtPositions ,
668
672
numAxesToCheck );
669
673
670
- if (status != OK )
674
+ if (statusGoalToleranceReorder != OK )
671
675
{
672
- Ros_Debug_BroadcastMsg ("%s: reordering final traj pt failed: %d" , __func__ , status );
673
- //TODO(gavanderhoorn): what do we do here?
676
+ Ros_Debug_BroadcastMsg ("%s: reordering final traj pt failed: %d" , __func__ , statusGoalToleranceReorder );
677
+ //TODO(gavanderhoorn): check re-ordering in Ros_ActionServer_FJT_Goal_Received(..) instead
678
+ bToleranceParseOk = FALSE;
679
+ Ros_Debug_BroadcastMsg ("%s: skipping goal tolerance check" , __func__ );
680
+ goto goal_complete_skip_tolerance_comparison ;
674
681
}
675
682
676
683
@@ -695,6 +702,7 @@ void Ros_ActionServer_FJT_Goal_Complete(GOAL_END_TYPE goal_end_type)
695
702
}
696
703
}
697
704
705
+ goal_complete_skip_tolerance_comparison : ;
698
706
//-----------------------------------------------------------------------
699
707
//check execution time
700
708
control_msgs__action__FollowJointTrajectory_SendGoal_Request * ros_goal_request = (control_msgs__action__FollowJointTrajectory_SendGoal_Request * )fjt_active_goal_handle -> ros_goal_request ;
@@ -718,7 +726,7 @@ void Ros_ActionServer_FJT_Goal_Complete(GOAL_END_TYPE goal_end_type)
718
726
BOOL timeOk = (diff <= timeTolerance );
719
727
720
728
//-----------------------------------------------------------------------
721
- if (positionOk && timeOk )
729
+ if (bToleranceParseOk && positionOk && timeOk )
722
730
{
723
731
Ros_Debug_BroadcastMsg ("FJT action successful" );
724
732
fjt_result_response .status = GOAL_STATE_SUCCEEDED ;
@@ -736,7 +744,13 @@ void Ros_ActionServer_FJT_Goal_Complete(GOAL_END_TYPE goal_end_type)
736
744
737
745
char msgBuffer [500 ] = { 0 };
738
746
739
- if (!positionOk )
747
+ if (!bToleranceParseOk )
748
+ {
749
+ sprintf (msgBuffer , "Parsing goal_tolerance failed (%d; %d). Failing trajectory execution." , statusParseGoalTolerance , statusGoalToleranceReorder );
750
+ rosidl_runtime_c__String__assign (& fjt_result_response .result .error_string , msgBuffer );
751
+ fjt_result_response .result .error_code = RESULT_REPONSE_ERROR_CODE (control_msgs__action__FollowJointTrajectory_Result__GOAL_TOLERANCE_VIOLATED , FAIL_TRAJ_TOLERANCE_PARSE );
752
+ }
753
+ else if (!positionOk )
740
754
{
741
755
sprintf (msgBuffer , "Final position was outside tolerance. Check robot safety-limits that could be inhibiting motion." );
742
756
for (int axis = 0 ; axis < numAxesToCheck ; axis += 1 )
0 commit comments