ros2 action server示例、拓展、练习

news2024/10/19 8:42:45

注意:以下代码全部由ai生成,没有大问题,运用时需根据报错逐步调试

action server示例

goalresultfeedback 作为类的成员变量的 C++ 示例代码:

示例代码

#include "rclcpp/rclcpp.hpp"
#include "rclcpp_action/rclcpp_action.hpp"
#include "your_package/action/my_action.hpp"
#include "your_package/srv/my_service.hpp"

class MyActionServer : public rclcpp::Node
{
public:
    using MyAction = your_package::action::MyAction;
    using GoalHandleMyAction = rclcpp_action::ServerGoalHandle<MyAction>;

    MyActionServer()
    : Node("my_action_server"),
      feedback_(std::make_shared<MyAction::Feedback>()),
      result_(std::make_shared<MyAction::Result>())
    {
        // 创建 Action 服务器
        action_server_ = rclcpp_action::create_server<MyAction>(
            this,
            "my_action",
            std::bind(&MyActionServer::handle_goal, this, std::placeholders::_1, std::placeholders::_2),
            std::bind(&MyActionServer::handle_cancel, this, std::placeholders::_1),
            std::bind(&MyActionServer::handle_accepted, this, std::placeholders::_1)
        );

        // 创建服务
        service_ = this->create_service<your_package::srv::MyService>(
            "my_service",
            std::bind(&MyActionServer::handle_service, this, std::placeholders::_1, std::placeholders::_2)
        );
    }

private:
    rclcpp_action::Server<MyAction>::SharedPtr action_server_;
    rclcpp::Service<your_package::srv::MyService>::SharedPtr service_;

    std::shared_ptr<const MyAction::Goal> goal_;
    std::shared_ptr<MyAction::Result> result_;
    std::shared_ptr<MyAction::Feedback> feedback_;

    // 处理目标
    rclcpp_action::GoalResponse handle_goal(
        const rclcpp_action::GoalUUID & uuid,
        std::shared_ptr<const MyAction::Goal> goal)
    {
        RCLCPP_INFO(this->get_logger(), "Received goal: %f", goal->goal_value);
        goal_ = goal;  // 存储目标
        return rclcpp_action::GoalResponse::YES;
    }

    // 处理取消请求
    rclcpp_action::CancelResponse handle_cancel(const std::shared_ptr<GoalHandleMyAction> goal_handle)
    {
        RCLCPP_INFO(this->get_logger(), "Canceling goal");
        return rclcpp_action::CancelResponse::ACCEPT;
    }

    // 处理已接受的目标
    void handle_accepted(const std::shared_ptr<GoalHandleMyAction> goal_handle)
    {
        std::thread([this, goal_handle]() {
            this->execute(goal_handle);
        }).detach();
    }

    // 执行目标
    void execute(const std::shared_ptr<GoalHandleMyAction> goal_handle)
    {
        for (int i = 1; i <= 5; ++i) {
            feedback_->current_value = i * goal_->goal_value;
            goal_handle->publish_feedback(feedback_);
            RCLCPP_INFO(this->get_logger(), "Feedback: %f", feedback_->current_value);
            std::this_thread::sleep_for(std::chrono::seconds(1));
        }

        // 设置结果
        result_->result_value = goal_->goal_value * 10;
        goal_handle->succeed(result_);
        RCLCPP_INFO(this->get_logger(), "Action succeeded with result: %f", result_->result_value);
    }

    // 处理服务
    void handle_service(
        const std::shared_ptr<your_package::srv::MyService::Request> request,
        std::shared_ptr<your_package::srv::MyService::Response> response)
    {
        response->response_value = request->request_value * 2;  // 示例处理
        RCLCPP_INFO(this->get_logger(), "Service called with value: %f, response: %f",
                     request->request_value, response->response_value);
    }
};

int main(int argc, char ** argv)
{
    rclcpp::init(argc, argv);
    rclcpp::spin(std::make_shared<MyActionServer>());
    rclcpp::shutdown();
    return 0;
}

代码说明

  • 成员变量

    • goal_: 存储接收到的目标。
    • result_: 存储结果信息。
    • feedback_: 存储反馈信息。
  • handle_goal 方法中,接收到的目标被存储到 goal_ 中。

  • execute 方法中,根据 goal_ 的值生成反馈,并发布反馈和结果。

拓展1 在execute中创建一个导航action client,并发布。

要在 execute 方法中创建一个导航目标点的 Action 客户端并发布一个固定点,你需要确保在代码中添加相关的导航 Action 依赖。以下是更新后的 C++ 示例代码:

示例代码

#include "rclcpp/rclcpp.hpp"
#include "rclcpp_action/rclcpp_action.hpp"
#include "your_package/action/my_action.hpp"
#include "your_package/srv/my_service.hpp"
#include "nav2_msgs/action/navigate_to_pose.hpp" // 导航 Action

class MyActionServer : public rclcpp::Node
{
public:
    using MyAction = your_package::action::MyAction;
    using GoalHandleMyAction = rclcpp_action::ServerGoalHandle<MyAction>;
    using NavigateToPose = nav2_msgs::action::NavigateToPose;
    using NavigateToPoseClient = rclcpp_action::Client<NavigateToPose>;

    MyActionServer()
    : Node("my_action_server"),
      feedback_(std::make_shared<MyAction::Feedback>()),
      result_(std::make_shared<MyAction::Result>()),
      navigate_client_(rclcpp_action::create_client<NavigateToPose>(this, "navigate_to_pose"))
    {
        action_server_ = rclcpp_action::create_server<MyAction>(
            this,
            "my_action",
            std::bind(&MyActionServer::handle_goal, this, std::placeholders::_1, std::placeholders::_2),
            std::bind(&MyActionServer::handle_cancel, this, std::placeholders::_1),
            std::bind(&MyActionServer::handle_accepted, this, std::placeholders::_1)
        );

        service_ = this->create_service<your_package::srv::MyService>(
            "my_service",
            std::bind(&MyActionServer::handle_service, this, std::placeholders::_1, std::placeholders::_2)
        );
    }

private:
    rclcpp_action::Server<MyAction>::SharedPtr action_server_;
    rclcpp::Service<your_package::srv::MyService>::SharedPtr service_;
    std::shared_ptr<const MyAction::Goal> goal_;
    std::shared_ptr<MyAction::Result> result_;
    std::shared_ptr<MyAction::Feedback> feedback_;
    rclcpp_action::Client<NavigateToPose>::SharedPtr navigate_client_;

    rclcpp_action::GoalResponse handle_goal(
        const rclcpp_action::GoalUUID & uuid,
        std::shared_ptr<const MyAction::Goal> goal)
    {
        RCLCPP_INFO(this->get_logger(), "Received goal: %f", goal->goal_value);
        goal_ = goal;
        return rclcpp_action::GoalResponse::YES;
    }

    rclcpp_action::CancelResponse handle_cancel(const std::shared_ptr<GoalHandleMyAction> goal_handle)
    {
        RCLCPP_INFO(this->get_logger(), "Canceling goal");
        return rclcpp_action::CancelResponse::ACCEPT;
    }

    void handle_accepted(const std::shared_ptr<GoalHandleMyAction> goal_handle)
    {
        std::thread([this, goal_handle]() {
            this->execute(goal_handle);
        }).detach();
    }

    void execute(const std::shared_ptr<GoalHandleMyAction> goal_handle)
    {
        // 创建导航目标点
        auto navigation_goal = NavigateToPose::Goal();
        navigation_goal.pose.header.frame_id = "map"; // 或者其他适当的坐标框架
        navigation_goal.pose.header.stamp = this->now();
        navigation_goal.pose.pose.position.x = 1.0; // 固定点的坐标
        navigation_goal.pose.pose.position.y = 1.0;
        navigation_goal.pose.pose.orientation.w = 1.0; // 方向

        // 调用导航客户端
        if (!navigate_client_->wait_for_action_server(std::chrono::seconds(5))) {
            RCLCPP_ERROR(this->get_logger(), "Navigation action server not available");
            goal_handle->abort(result_);
            return;
        }

        auto send_goal_options = rclcpp_action::Client<NavigateToPose>::SendGoalOptions();
        send_goal_options.result_callback = [](const rclcpp_action::ClientGoalHandle<NavigateToPose>::SharedPtr &) {
            RCLCPP_INFO(rclcpp::get_logger("rclcpp"), "Navigation goal accepted");
        };

        auto goal_handle_navigation = navigate_client_->async_send_goal(navigation_goal, send_goal_options);

        // 处理导航反馈
        while (rclcpp::ok()) {
            // 这里可以添加导航反馈处理逻辑
            std::this_thread::sleep_for(std::chrono::milliseconds(500));
        }

        // 返回结果
        result_->result_value = goal_->goal_value * 10;
        goal_handle->succeed(result_);
        RCLCPP_INFO(this->get_logger(), "Action succeeded with result: %f", result_->result_value);
    }

    void handle_service(
        const std::shared_ptr<your_package::srv::MyService::Request> request,
        std::shared_ptr<your_package::srv::MyService::Response> response)
    {
        response->response_value = request->request_value * 2;
        RCLCPP_INFO(this->get_logger(), "Service called with value: %f, response: %f",
                     request->request_value, response->response_value);
    }
};

int main(int argc, char ** argv)
{
    rclcpp::init(argc, argv);
    rclcpp::spin(std::make_shared<MyActionServer>());
    rclcpp::shutdown();
    return 0;
}

代码说明

  1. 导航 Action 客户端

    • 创建 NavigateToPose 的 Action 客户端。
    • 使用 navigate_client_ 来发送导航目标。
  2. 导航目标点

    • execute 方法中定义固定的导航目标点(例如 (1.0, 1.0))。
    • 设置导航目标的坐标和方向。
  3. 异步发送目标

    • 使用 async_send_goal 方法发送导航目标,处理结果和反馈。
    • 可以在循环中添加对导航状态的反馈处理逻辑。

使用

  1. 确保导航 Action 服务器(例如 Nav2)正在运行。
  2. 启动此 Action 服务器节点。
  3. 在客户端调用 Action 和服务,观察服务器的导航行为。

拓展2 针对send_goal_options配置结构,创建一个新成员函数,替代上一段的lambda函数, 并使用send_goal_options的所有成员

好的,下面是更新后的代码示例,其中我们创建了一个新的成员函数来处理 send_goal_options 的配置,替代了之前使用的 Lambda 函数。这一新函数将使用 send_goal_options 的所有成员。

更新后的示例代码

#include "rclcpp/rclcpp.hpp"
#include "rclcpp_action/rclcpp_action.hpp"
#include "your_package/action/my_action.hpp"
#include "your_package/srv/my_service.hpp"
#include "nav2_msgs/action/navigate_to_pose.hpp" // 导航 Action

class MyActionServer : public rclcpp::Node
{
public:
    using MyAction = your_package::action::MyAction;
    using GoalHandleMyAction = rclcpp_action::ServerGoalHandle<MyAction>;
    using NavigateToPose = nav2_msgs::action::NavigateToPose;
    using NavigateToPoseClient = rclcpp_action::Client<NavigateToPose>;

    MyActionServer()
    : Node("my_action_server"),
      feedback_(std::make_shared<MyAction::Feedback>()),
      result_(std::make_shared<MyAction::Result>()),
      navigate_client_(rclcpp_action::create_client<NavigateToPose>(this, "navigate_to_pose"))
    {
        action_server_ = rclcpp_action::create_server<MyAction>(
            this,
            "my_action",
            std::bind(&MyActionServer::handle_goal, this, std::placeholders::_1, std::placeholders::_2),
            std::bind(&MyActionServer::handle_cancel, this, std::placeholders::_1),
            std::bind(&MyActionServer::handle_accepted, this, std::placeholders::_1)
        );

        service_ = this->create_service<your_package::srv::MyService>(
            "my_service",
            std::bind(&MyActionServer::handle_service, this, std::placeholders::_1, std::placeholders::_2)
        );
    }

private:
    rclcpp_action::Server<MyAction>::SharedPtr action_server_;
    rclcpp::Service<your_package::srv::MyService>::SharedPtr service_;
    std::shared_ptr<const MyAction::Goal> goal_;
    std::shared_ptr<MyAction::Result> result_;
    std::shared_ptr<MyAction::Feedback> feedback_;
    rclcpp_action::Client<NavigateToPose>::SharedPtr navigate_client_;

    rclcpp_action::GoalResponse handle_goal(
        const rclcpp_action::GoalUUID & uuid,
        std::shared_ptr<const MyAction::Goal> goal)
    {
        RCLCPP_INFO(this->get_logger(), "Received goal: %f", goal->goal_value);
        goal_ = goal;
        return rclcpp_action::GoalResponse::YES;
    }

    rclcpp_action::CancelResponse handle_cancel(const std::shared_ptr<GoalHandleMyAction> goal_handle)
    {
        RCLCPP_INFO(this->get_logger(), "Canceling goal");
        return rclcpp_action::CancelResponse::ACCEPT;
    }

    void handle_accepted(const std::shared_ptr<GoalHandleMyAction> goal_handle)
    {
        std::thread([this, goal_handle]() {
            this->execute(goal_handle);
        }).detach();
    }

    void execute(const std::shared_ptr<GoalHandleMyAction> goal_handle)
    {
        // 创建导航目标点
        auto navigation_goal = NavigateToPose::Goal();
        navigation_goal.pose.header.frame_id = "map";
        navigation_goal.pose.header.stamp = this->now();
        navigation_goal.pose.pose.position.x = 1.0;
        navigation_goal.pose.pose.position.y = 1.0;
        navigation_goal.pose.pose.orientation.w = 1.0;

        // 调用导航客户端
        if (!navigate_client_->wait_for_action_server(std::chrono::seconds(5))) {
            RCLCPP_ERROR(this->get_logger(), "Navigation action server not available");
            goal_handle->abort(result_);
            return;
        }

        // 使用新成员函数配置 send_goal_options
        configure_send_goal_options(goal_handle, navigation_goal);
    }

    void configure_send_goal_options(const std::shared_ptr<GoalHandleMyAction> goal_handle, const NavigateToPose::Goal &navigation_goal)
    {
        auto send_goal_options = rclcpp_action::Client<NavigateToPose>::SendGoalOptions();

        // 设置 result_callback
        send_goal_options.result_callback = [this](const rclcpp_action::ClientGoalHandle<NavigateToPose>::SharedPtr &goal_handle) {
            if (goal_handle->get_status() == rclcpp_action::GoalStatus::SUCCEEDED) {
                RCLCPP_INFO(this->get_logger(), "Navigation goal succeeded");
            } else {
                RCLCPP_ERROR(this->get_logger(), "Navigation goal failed");
            }
        };

        // 设置 feedback_callback
        send_goal_options.feedback_callback = [this](const rclcpp_action::ClientGoalHandle<NavigateToPose>::SharedPtr &goal_handle, const std::shared_ptr<const NavigateToPose::Feedback> feedback) {
            RCLCPP_INFO(this->get_logger(), "Navigation feedback: current position %f, %f",
                        feedback->current_pose.position.x, feedback->current_pose.position.y);
        };

        // 设置 goal_response_callback
        send_goal_options.goal_response_callback = [](const rclcpp_action::ClientGoalHandle<NavigateToPose>::SharedPtr &goal_handle) {
            if (goal_handle) {
                RCLCPP_INFO(rclcpp::get_logger("rclcpp"), "Navigation goal accepted");
            } else {
                RCLCPP_ERROR(rclcpp::get_logger("rclcpp"), "Navigation goal rejected");
            }
        };

        // 发送导航目标
        auto goal_handle_navigation = navigate_client_->async_send_goal(navigation_goal, send_goal_options);
    }

    void handle_service(
        const std::shared_ptr<your_package::srv::MyService::Request> request,
        std::shared_ptr<your_package::srv::MyService::Response> response)
    {
        response->response_value = request->request_value * 2;
        RCLCPP_INFO(this->get_logger(), "Service called with value: %f, response: %f",
                     request->request_value, response->response_value);
    }
};

int main(int argc, char ** argv)
{
    rclcpp::init(argc, argv);
    rclcpp::spin(std::make_shared<MyActionServer>());
    rclcpp::shutdown();
    return 0;
}

代码说明

  1. 新成员函数 configure_send_goal_options

    • 此函数负责配置 send_goal_options 的所有成员,包括 result_callbackfeedback_callbackgoal_response_callback
    • 通过捕获 this,可以在回调中访问类的成员函数和变量。
  2. 回调函数的实现

    • result_callback: 检查导航目标的状态,并根据成功或失败打印日志信息。
    • feedback_callback: 输出当前导航位置的反馈信息。
    • goal_response_callback: 检查目标是否被接受,并输出相应的日志信息。
  3. 调用导航目标

    • execute 方法中,调用 configure_send_goal_options 来配置并发送导航目标。

这种方式将发送目标的逻辑与配置的回调逻辑分离,使代码更清晰、可维护。如果你有其他问题或者需要进一步的解释,请随时告诉我!

注意:只要设置了 send_goal_options.feedback_callback,回调函数就会在导航服务器发送反馈时被调用,可以在函数内部获取并处理这些反馈信息。
示例:
将其改写为

send_goal_options.feedback_callback = 
[this](const rclcpp_action::ClientGoalHandle<NavigateToPose>::SharedPtr &goal_handle
, const std::shared_ptr<const NavigateToPose::Feedback> feedback) 
{};

根据定义

#goal definition
geometry_msgs/PoseStamped pose
string behavior_tree
---
#result definition
std_msgs/Empty result
---
#feedback definition
geometry_msgs/PoseStamped current_pose
builtin_interfaces/Duration navigation_time
builtin_interfaces/Duration estimated_time_remaining
int16 number_of_recoveries
float32 distance_remaining
】

action的客户端也能获取
【geometry_msgs/PoseStamped current_pose
builtin_interfaces/Duration navigation_time
builtin_interfaces/Duration estimated_time_remaining
int16 number_of_recoveries
float32 distance_remaining】
这些信息

练习1

1.实现拓展中创建的navigation的导航action与自定义的action通信
2.找到isaac_mission_client实现其中自定义action与isaac_mission_client的通信,注意参考mqtt协议。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/2218352.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

(新手入门篇)2024年10 月 Java JDK 1.8版本WIN 10 系统安装教程!!!!!!!

前言 IDEA的安装是Java课程的入门&#xff0c;对于刚入门的小白来说&#xff0c;安装jdk是必不可少的一个环节&#xff0c;当然&#xff0c;很多的老同学进入新公司装环境也是不可或缺的&#xff0c;本人也是经常会碰到类似的场景&#xff0c;为避免后续忘记&#xff0c;选择记…

SHA256算法学习

SHA-256&#xff08;Secure Hash Algorithm 256-bit&#xff09;是一种常用的哈希算法&#xff0c;是SHA-2家族中的一种。它可以将任意长度的数据转换为一个固定长度的256位&#xff08;32字节&#xff09;哈希值。 算法特点 固定长度输出&#xff1a;无论输入数据有多长&…

flutter assets配置加载本地图片报错

首选列出我在照着网上说的设置assets怎么搞都报错&#xff0c;错误如下&#xff0c;搞的我想骂娘。 flutter: uses-material-design: true assets: - assets/images 后来找到了下面这个教程&#xff0c;才终于解决&#xff0c;就是要在后面加一个"/" 。 flutter这个…

【JVM】—深入理解ZGC回收器—背景概念回收流程

深入理解ZGC回收器—背景概念&回收流程 ⭐⭐⭐⭐⭐⭐ Github主页&#x1f449;https://github.com/A-BigTree 笔记链接&#x1f449;https://github.com/A-BigTree/Code_Learning ⭐⭐⭐⭐⭐⭐ 如果可以&#xff0c;麻烦各位看官顺手点个star~&#x1f60a; 文章目录 深入…

韩信走马分油c++

韩信走马分油c 题目算法代码 题目 把油桶里还剩下的10斤油平分&#xff0c;只有一个能装3斤的油葫芦和一个能装7斤的瓦罐。如何分。 算法 油壶编号0&#xff0c;1&#xff0c;2。不同倒法有&#xff1a;把油从0倒进0&#xff08;本壶到本壶&#xff0c;无效&#xff09;&…

YoloV9改进策略:主干网络改进|DeBiFormer,可变形双级路由注意力|全网首发

摘要 在目标检测领域&#xff0c;YoloV9以其高效和准确的性能而闻名。然而&#xff0c;为了进一步提升其检测能力&#xff0c;我们引入了DeBiFormer作为YoloV9的主干网络。这个主干网络的计算量比较大&#xff0c;不过&#xff0c;上篇双级路由注意力的论文受到很大的关注&…

Centos7搭建minio对象存储服务器

Centos7搭建minio对象存储服务器 安装二进制程序配置服务文件 安装二进制程序 参考&#xff1a;https://segmentfault.com/q/1010000042181876 minio中国版&#xff1a;https://www.minio.org.cn/download.shtml#/linux # 下载二进制程序 wget https://dl.min.io/server/min…

matlab相位图

% 清空工作空间和命令窗口 clear; clc; % 模拟生成时间t&#xff0c;位移y(t)和角位移theta(t) t linspace(0, 100, 1000); % 时间从0到100&#xff0c;包含1000个点 y 1e-5 * sin(2 * pi * 0.1 * t) .* exp(-0.01 * t); % 位移y(t) 振荡衰减 theta 1e-6 * cos(2 * pi * …

第8篇:网络安全基础

目录 引言 8.1 网络安全的基本概念 8.2 网络威胁与攻击类型 8.3 密码学的基本思想与加密算法 8.4 消息认证与数字签名 8.5 网络安全技术与协议 8.6 总结 第8篇&#xff1a;网络安全基础 引言 在现代信息社会中&#xff0c;计算机网络无处不在&#xff0c;从互联网到局…

如何将 Docker 镜像的 tar 文件迁移到另一台服务器并运行容器

在 Docker 容器化的世界里&#xff0c;我们经常需要将容器从一个环境迁移到另一个环境。这可能是因为开发、测试或生产环境的需求。本文将详细介绍如何将 Docker 镜像的 tar 文件从一台服务器迁移到另一台服务器&#xff08;IP 地址为 192.168.100.10&#xff09;&#xff0c;并…

深度学习每周学习总结J3(DenseNet-121算法实战与解析 - 鸟类识别)

&#x1f368; 本文为&#x1f517;365天深度学习训练营 中的学习记录博客&#x1f356; 原作者&#xff1a;K同学啊 | 接辅导、项目定制 目录 DenseNet 与 ResNet1. 设计理念2. 网络结构3. 与CNN和ResNet的对比补充&#xff1a;一些网络结构对比的网站&#xff08;重要&#x…

【C++基础篇】——逐步了解C++

【C基础篇】——逐步了解C 文章目录 【C基础篇】——逐步了解C前言一、C的第一个程序二、命名空间1.namespace的价值2.namespace的定义3.命名空间的使用 三、C的输入&输出四、缺省参数五、函数重载六、引用1.引用的概念和定义&#xff1a;2.引用的特性3.引用的使用4.const引…

标准/开源版本,长连接无法启动

在配置长链接的时候&#xff0c;有时候会出现无法正常启动的问题&#xff0c;下面介绍几种情况&#xff0c;并给出解决办法 1、启动入下图所示&#xff0c;是因为你的php的禁用函数没有解禁&#xff0c;按照配置文档中的解禁所有禁用函数 2、检查你的反向代理是否配置正确&…

华山论剑之Rust的Trait

华山论剑&#xff0c;群雄荟萃&#xff0c;各显神通。武林中人&#xff0c;各有所长&#xff0c;或剑法飘逸&#xff0c;或掌法刚猛&#xff0c;或轻功绝顶。这就好比Rust中的trait&#xff0c;它定义了一种武功套路&#xff0c;而不同的门派、不同的人&#xff0c;可以将这套武…

shell脚本宝藏仓库(基础命令、正则表达式、shell基础、变量、逻辑判断、函数、数组)

一、shell概述 1.1 shell是什么 Shell是一种脚本语言 脚本&#xff1a;本质是一个文件&#xff0c;文件里面存放的是特定格式的指令&#xff0c;系统可以使用脚本解析器、翻译或解析指令并执行&#xff08;shell不需要编译&#xff09; Shell既是应用程序又是一种脚本语言&…

5.12 向内核传递信息(2)

首先是 设置 loard_16.c 中的 boot_info 这个变量&#xff0c; 这里最初保存的是 读取到的内存的信息。 然后是 增加跳转的函数。 然后就是 去改动 内核代码。 由于内核的代码最终 调用的是 kernel_init. 最关键的就是 这里了&#xff0c; call kernel_init 相当于 在调用一个…

阿里巴巴达摩院|Chain of Ideas: 利用大型语言模型代理革新新颖创意开发的研究

阿里巴巴集团达摩院&#xff5c;Chain of Ideas: 利用大型语言模型代理革新新颖创意开发的研究 &#x1f3af; 推荐指数&#xff1a;&#x1f31f;&#x1f31f;&#x1f31f; &#x1f4d6; title&#xff1a;Chain of Ideas: Revolutionizing Research in Novel Idea Develop…

C++ | Leetcode C++题解之第492题构造矩形

题目&#xff1a; 题解&#xff1a; class Solution { public:vector<int> constructRectangle(int area) {int w sqrt(1.0 * area);while (area % w) {--w;}return {area / w, w};} };

【十】Hyperf最简单的使用rabbitMQ

配置.env文件 AMQP_HOST192.168.86.102 AMQP_PORT5672 AMQP_USERrabbitmq AMQP_PASSWORDrabbitmq AMQP_VHOSTmy-test配置文件 生产者 消费者(注意&#xff1a;里面的num在实际使用的时候&#xff0c;至少为1&#xff0c;不然没有消费者队列来执行里面的操作) 调用&#xff0c;…

【在Linux世界中追寻伟大的One Piece】应用层自定义协议|序列化

目录 1 -> 应用层 2 -> 网络版计算器 3 -> 序列化与反序列化 4 -> 重新理解read、write、recv、send和tcp为什么支持全双工 5 -> 开始实现 5.1 -> 定制协议 5.2 -> 关于流式数据的处理 1 -> 应用层 应用层是OSI模型或TCP/IP模型中的最高层&…