[ROS2] Error in binding a callback to action client
I'm trying to follow the C++ action tutorial here: https://docs.ros.org/en/rolling/Tutor...
I have an action server that is a member of a class, like the tutorial. Here is the initialization:
using TrajectoryAction = control_msgs::action::FollowJointTrajectory;
using TrajectoryGoalHandle = rclcpp_action::ClientGoalHandle<control_msgs::action::FollowJointTrajectory>;
.
.
auto cb_group = node->create_callback_group(rclcpp::CallbackGroupType::MutuallyExclusive);
joint_trajectory_client_ = rclcpp_action::create_client<TrajectoryAction>(node, trajectory_topic, cb_group);
I try to make a request with goal options:
auto send_goal_options = rclcpp_action::Client<TrajectoryAction>::SendGoalOptions();
send_goal_options.result_callback = std::bind(&TaskExecutionImpl::TrajectoryResultCallback, this, std::placeholders::_1); // trouble at this line -- it compiles if commented
The function which I'm trying to use as a callback is:
void TaskExecutionImpl::TrajectoryResultCallback(const TrajectoryGoalHandle::WrappedResult& result)
{
return;
}
The compiler errors:
error: no match for ‘operator=’ (operand types are ‘rclcpp_action::Client<control_msgs::action::FollowJointTrajectory>::ResultCallback’ {aka ‘std::function<void(const rclcpp_action::ClientGoalHandle<control_msgs::action::FollowJointTrajectory>::WrappedResult&)>’} and ‘std::_Bind_helper<false, void (my_robot::task_planning::TaskExecutionImpl::*)(const rclcpp_action::ClientGoalHandle<control_msgs::action::FollowJointTrajectory>::WrappedResult&), const my_robot::task_planning::TaskExecutionImpl*>::type’)
54 | send_goal_options.result_callback = std::bind(&TaskExecutionImpl::TrajectoryResultCallback, this);
. .
/workspaces/ws_ros2/src/my_robot_moveit/task_planning/src/task_execution_impl.cpp:54:99: required from here
/usr/include/c++/11/type_traits:2211:11: error: no type named ‘type’ in ‘struct std::enable_if<false, std::function<void(const rclcpp_action::ClientGoalHandle<control_msgs::action::FollowJointTrajectory>::WrappedResult&)>&>’
Unlike the tutorial, my class doesn't inherit from
rclcpp::Node
. But I don't think that matters...Maybe try as a lambda ?, I think I came across something similar when I was porting portion of my code from foxy to rolling.