@@ -111,7 +111,7 @@ void ExecuteTaskSolutionCapability::execCallback(
111111 }
112112
113113 plan_execution::ExecutableMotionPlan plan;
114- if (!constructMotionPlan (goal->solution , plan))
114+ if (!constructMotionPlan (goal->solution , plan, goal_handle ))
115115 result->error_code .val = moveit_msgs::msg::MoveItErrorCodes::INVALID_MOTION_PLAN;
116116 else {
117117 RCLCPP_INFO (LOGGER, " Executing TaskSolution" );
@@ -133,8 +133,9 @@ rclcpp_action::CancelResponse ExecuteTaskSolutionCapability::preemptCallback(
133133 return rclcpp_action::CancelResponse::ACCEPT;
134134}
135135
136- bool ExecuteTaskSolutionCapability::constructMotionPlan (const moveit_task_constructor_msgs::msg::Solution& solution,
137- plan_execution::ExecutableMotionPlan& plan) {
136+ bool ExecuteTaskSolutionCapability::constructMotionPlan (
137+ const moveit_task_constructor_msgs::msg::Solution& solution, plan_execution::ExecutableMotionPlan& plan,
138+ const std::shared_ptr<rclcpp_action::ServerGoalHandle<ExecuteTaskSolutionAction>>& goal_handle) {
138139 moveit::core::RobotModelConstPtr model = context_->planning_scene_monitor_ ->getRobotModel ();
139140
140141 moveit::core::RobotState state (model);
@@ -182,20 +183,26 @@ bool ExecuteTaskSolutionCapability::constructMotionPlan(const moveit_task_constr
182183 exec_traj.controller_name = sub_traj.execution_info .controller_names ;
183184
184185 /* TODO add action feedback and markers */
185- exec_traj.effect_on_success = [this ,
186- &scene_diff = const_cast <::moveit_msgs::msg::PlanningScene&>(sub_traj.scene_diff ),
187- description](const plan_execution::ExecutableMotionPlan* /* plan*/ ) {
188- // Never modify joint state directly (only via robot trajectories)
189- scene_diff.robot_state .joint_state = sensor_msgs::msg::JointState ();
190- scene_diff.robot_state .multi_dof_joint_state = sensor_msgs::msg::MultiDOFJointState ();
191- scene_diff.robot_state .is_diff = true ; // silent empty JointState msg error
192-
193- if (!moveit::core::isEmpty (scene_diff)) {
194- RCLCPP_DEBUG_STREAM (LOGGER, " apply effect of " << description);
195- return context_->planning_scene_monitor_ ->newPlanningSceneMessage (scene_diff);
196- }
197- return true ;
198- };
186+ exec_traj.effect_on_success =
187+ [this , &scene_diff = const_cast <::moveit_msgs::msg::PlanningScene&>(sub_traj.scene_diff ), description,
188+ goal_handle, i, no = solution.sub_trajectory .size ()](const plan_execution::ExecutableMotionPlan* /* plan*/ ) {
189+ // publish feedback
190+ auto feedback = std::make_shared<moveit_task_constructor_msgs::action::ExecuteTaskSolution::Feedback>();
191+ feedback->sub_id = i;
192+ feedback->sub_no = no;
193+ goal_handle->publish_feedback (feedback);
194+
195+ // Never modify joint state directly (only via robot trajectories)
196+ scene_diff.robot_state .joint_state = sensor_msgs::msg::JointState ();
197+ scene_diff.robot_state .multi_dof_joint_state = sensor_msgs::msg::MultiDOFJointState ();
198+ scene_diff.robot_state .is_diff = true ; // silent empty JointState msg error
199+
200+ if (!moveit::core::isEmpty (scene_diff)) {
201+ RCLCPP_DEBUG_STREAM (LOGGER, " apply effect of " << description);
202+ return context_->planning_scene_monitor_ ->newPlanningSceneMessage (scene_diff);
203+ }
204+ return true ;
205+ };
199206
200207 if (!moveit::core::isEmpty (sub_traj.scene_diff .robot_state ) &&
201208 !moveit::core::robotStateMsgToRobotState (sub_traj.scene_diff .robot_state , state, true )) {
0 commit comments