定义:
bool enableRobot_cb(const std_srvs::srv::SetBool::Request::SharedPtr req, const std_srvs::srv::SetBool::Response::SharedPtr resp);
rclcpp::Service<std_srvs::srv::SetBool>::SharedPtr enable_robot_server_;
实现:
enable_robot_server_=local_nh_->create_service<std_srvs::srv::SetBool>("enable_robot",
std::bind(&ElfinBasicAPI::enableRobot_cb, this, _1,_2),
rmw_qos_profile_services_default,callback_group_service_);
bool ElfinBasicAPI::enableRobot_cb(const std_srvs::srv::SetBool::Request::SharedPtr req, const std_srvs::srv::SetBool::Response::SharedPtr resp)
{
.......
}