Skip to content

Can't get action feedback data in BTaction node based on bt_action_node in Galactic #2839

@shoufei403

Description

@shoufei403

Bug report

Required Info:

  • Operating System:
  • ROS2 Version:
    • Galactic binary
  • Version or commit hash:
    • 1.0.8
  • DDS implementation:
    • Fast-RTPS

Steps to reproduce issue

//from nav2_behavior_tree/include/nav2_behavior_tree/bt_action_node.hpp
void send_new_goal()
  {
    goal_result_available_ = false;
    auto send_goal_options = typename rclcpp_action::Client<ActionT>::SendGoalOptions();
    send_goal_options.goal_response_callback =
      [this](typename rclcpp_action::ClientGoalHandle<ActionT>::SharedPtr goal_handle) {
        if (!goal_handle) {
          RCLCPP_ERROR(node_->get_logger(), "Goal was rejected by server");
        } else {
          RCLCPP_INFO(node_->get_logger(), "Goal accepted by server, waiting for result");
        }
      };
    send_goal_options.feedback_callback =
      [this](typename rclcpp_action::ClientGoalHandle<ActionT>::SharedPtr,
        const std::shared_ptr<const typename ActionT::Feedback> feedback) {
 
        //TODO: Want to get feedback data in BTaction node

        (void)(feedback);
        // feedback_ptr_ = feedback->get();

      };
    send_goal_options.result_callback =
      [this](const typename rclcpp_action::ClientGoalHandle<ActionT>::WrappedResult & result) {
        if (future_goal_handle_) {
          RCLCPP_DEBUG(
            node_->get_logger(),
            "Goal result for %s available, but it hasn't received the goal response yet. "
            "It's probably a goal result for the last goal request", action_name_.c_str());
          return;
        }

        // TODO(#1652): a work around until rcl_action interface is updated
        // if goal ids are not matched, the older goal call this callback so ignore the result
        // if matched, it must be processed (including aborted)
        if (this->goal_handle_->get_goal_id() == result.goal_id) {
          goal_result_available_ = true;
          result_ = result;
        }
      };

    future_goal_handle_ = std::make_shared<
      std::shared_future<typename rclcpp_action::ClientGoalHandle<ActionT>::SharedPtr>>(
      action_client_->async_send_goal(goal_, send_goal_options));
    time_goal_sent_ = node_->now();
  }

Feature request

Can get BTaction node feedback data

Feature description

I try to add a feedback callback. But the shared pointer of feedback can't be assigned for another member pointer or shared pointer.
I wonder if there is a way to reach that.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions