当前位置: 首页 > news >正文

idc网站是用什么语言做的网页制作与设计作业在哪搜题

idc网站是用什么语言做的,网页制作与设计作业在哪搜题,市建设与管理局网站,高端网站开发案例展示通信最后一个#xff0c;也是不太容易理解的方式action#xff0c;复杂且重要 1、创建action数据结构 创建工作空间和模块就不多说了 在模块 src/action_moudle/action/Counter.action 下创建文件 Counter.action int32 target # Goal: 目标 --- int32 current_value…通信最后一个也是不太容易理解的方式action复杂且重要 1、创建action数据结构 创建工作空间和模块就不多说了 在模块  src/action_moudle/action/Counter.action  下创建文件 Counter.action int32 target # Goal: 目标 --- int32 current_value # Result: 结果 --- int32[] sequence # Feedback: 中间状态反馈 需要注意的是 这几个值不要搞混结果和中间状态容易搞错 添加依赖src/action_moudle/package.xml dependrclcpp_action/depend dependrosidl_default_generators/dependdependrosidl_default_runtime/dependmember_of_grouprosidl_interface_packages/member_of_group src/action_moudle/CMakeLists.txt find_package(rosidl_default_generators REQUIRED) find_package(rclcpp_action REQUIRED)# 设置消息和服务文件路径 set(action_FILESaction/Counter.action )# 添加消息和服务生成目标 rosidl_generate_interfaces(${PROJECT_NAME}${action_FILES}DEPENDENCIES std_msgs )# 安装 Action 文件 install(DIRECTORY action/DESTINATION share/${PROJECT_NAME}/action ) 编译后生成install/action_moudle/include/action_moudle/action_moudle/action/counter.hpp 至此action文件生成 2、编写Count计时的Action服务端和客户端代码 AI生成的代码靠不住改了很多才编译过 src/action_moudle/src/action_server.cpp #include rclcpp/rclcpp.hpp #include action_moudle/action/counter.hpp #include rclcpp_action/rclcpp_action.hpp #include memory #include vectorusing Counter action_moudle::action::Counter; using namespace std::placeholders;class CounterActionServer : public rclcpp::Node { public:CounterActionServer() : Node(counter_action_server){action_server_ rclcpp_action::create_serverCounter(this, counter, std::bind(CounterActionServer::handle_goal, this, _1, _2),std::bind(CounterActionServer::handle_cancel, this, _1), std::bind(CounterActionServer::handle_accepted, this, _1));}private:rclcpp_action::ServerCounter::SharedPtr action_server_;rclcpp_action::GoalResponse handle_goal(const rclcpp_action::GoalUUID uuid, std::shared_ptrconst Counter::Goal goal){(void)uuid;RCLCPP_INFO(this-get_logger(), Received goal request with target: %ld, goal-target);return rclcpp_action::GoalResponse::ACCEPT_AND_EXECUTE;}rclcpp_action::CancelResponse handle_cancel(const std::shared_ptrrclcpp_action::ServerGoalHandleCounter goal_handle){RCLCPP_INFO(this-get_logger(), Received request to cancel goal);return rclcpp_action::CancelResponse::ACCEPT;}void handle_accepted(const std::shared_ptrrclcpp_action::ServerGoalHandleCounter goal_handle){using namespace std::placeholders;std::thread{std::bind(CounterActionServer::execute, this, _1), goal_handle}.detach();}void execute(const std::shared_ptrrclcpp_action::ServerGoalHandleCounter goal_handle){RCLCPP_INFO(this-get_logger(), Executing goal);rclcpp::Rate loop_rate(1);const auto goal goal_handle-get_goal();auto feedback std::make_sharedCounter::Feedback();auto result std::make_sharedCounter::Result();result-current_value 0;feedback-sequence.push_back(0);if (goal_handle-is_canceling()){goal_handle-canceled(result);RCLCPP_INFO(this-get_logger(), Goal canceled);return;}goal_handle-publish_feedback(feedback);for (int i 1; i goal-target; i){result-current_value i;feedback-sequence.push_back(i);if (goal_handle-is_canceling()){goal_handle-canceled(result);RCLCPP_INFO(this-get_logger(), Goal canceled);return;}goal_handle-publish_feedback(feedback);loop_rate.sleep();}goal_handle-succeed(result);RCLCPP_INFO(this-get_logger(), Returning result);} };int main(int argc, char* argv[]) {rclcpp::init(argc, argv);rclcpp::spin(std::make_sharedCounterActionServer());rclcpp::shutdown();return 0; }src/action_moudle/src/action_client.cpp #include rclcpp/rclcpp.hpp #include action_moudle/action/counter.hpp #include rclcpp_action/rclcpp_action.hpp #include memoryusing Counter action_moudle::action::Counter; using namespace std::placeholders;class CounterActionClient : public rclcpp::Node { public:CounterActionClient() : Node(counter_action_client){action_client_ rclcpp_action::create_clientCounter(this, counter);while (!action_client_-wait_for_action_server()){if (!rclcpp::ok()){RCLCPP_ERROR(this-get_logger(), Interrupted while waiting for the action server. Exiting.);return;}RCLCPP_INFO(this-get_logger(), Action server not available, waiting again...);}auto goal Counter::Goal();goal.target 10;auto send_goal_options rclcpp_action::ClientCounter::SendGoalOptions();send_goal_options.goal_response_callback std::bind(CounterActionClient::goal_response_callback, this, std::placeholders::_1);send_goal_options.feedback_callback std::bind(CounterActionClient::feedback_callback, this, std::placeholders::_1, std::placeholders::_2);send_goal_options.result_callback std::bind(CounterActionClient::result_callback, this, std::placeholders::_1);action_client_-async_send_goal(goal, send_goal_options);}private:rclcpp_action::ClientCounter::SharedPtr action_client_;void goal_response_callback(rclcpp_action::ClientGoalHandleCounter::SharedPtr goal_handle){if (!goal_handle){RCLCPP_INFO(this-get_logger(), Goal rejected);}else{RCLCPP_INFO(this-get_logger(), Goal accepted);}}// void goal_response_callback(std::shared_futurestd::shared_ptrrclcpp_action::ClientGoalHandleCounter future)// {// auto goal_handle future.get();// if (!goal_handle)// {// RCLCPP_INFO(this-get_logger(), Goal rejected);// }// else// {// RCLCPP_INFO(this-get_logger(), Goal accepted);// }// }void feedback_callback(std::shared_ptrrclcpp_action::ClientGoalHandleCounter, const std::shared_ptrconst Counter::Feedback feedback){// RCLCPP_INFO(this-get_logger(), Current value: %ld, feedback-current_value);RCLCPP_INFO(this-get_logger(), Sequence value: %s, print_sequence(feedback-sequence).c_str());}void result_callback(const rclcpp_action::ClientGoalHandleCounter::WrappedResult result){switch (result.code){case rclcpp_action::ResultCode::SUCCEEDED:RCLCPP_INFO(this-get_logger(), Result: %d, result.result-current_value);break;case rclcpp_action::ResultCode::ABORTED:RCLCPP_ERROR(this-get_logger(), Goal was aborted);break;case rclcpp_action::ResultCode::CANCELED:RCLCPP_ERROR(this-get_logger(), Goal was canceled);break;default:RCLCPP_ERROR(this-get_logger(), Unknown result code);break;}rclcpp::shutdown();}std::string print_sequence(const std::vectorint32_t sequence){std::stringstream ss;ss [;for (size_t i 0; i sequence.size(); i){if (i 0){ss , ;}ss sequence[i];}ss ];return ss.str();} };int main(int argc, char* argv[]) {rclcpp::init(argc, argv);rclcpp::spin(std::make_sharedCounterActionClient());rclcpp::shutdown();return 0; }src/action_moudle/CMakeLists.txt  添加 find_package(action_moudle REQUIRED) find_package(rclcpp_action REQUIRED)# 创建可执行文件 add_executable(action_server src/action_server.cpp) ament_target_dependencies(action_server rclcpp std_msgs action_moudle rclcpp_action)add_executable(action_client src/action_client.cpp) ament_target_dependencies(action_client rclcpp std_msgs action_moudle rclcpp_action)# 安装目标 install(TARGETSaction_server action_clientDESTINATION lib/${PROJECT_NAME} )3、编译后测试
http://www.hkea.cn/news/14517003/

相关文章:

  • 青岛鲁icp 网站制作 牛商网企业网站包含哪些页面
  • 文明网站的建设与管理几点思考如何优化网站 提高排名
  • 新手如何做网站开发网站如何赚钱
  • 怎么做企业网站仿站免费网站建设网站开发公司
  • 男女做视频观看网站湖南省建设厅官方网站
  • 保定网站排名搞笑幽默网站源码最新
  • 网页设计设计一个网站做北京电梯招标的网站
  • 网站建设需求分析流程黄平网站制作
  • 河南省城乡与住房建设厅网站郑州做网站设计
  • 电脑做网站做外贸网站需要多少钱
  • 湖北定制型网站建设精品源码分享免费下载
  • 网站首页上的动画是咋做的英文建站多少钱
  • 太平洋电脑网站外贸做的社交网站
  • cms做网站可以做些什么网站局域网内部如何做网站
  • 正规网站建设平台wordpress添加新的小工具
  • 自己做网站切入地图零基础网站建设教学培训班
  • 做网站的风险分析滨州做网站的
  • 邢台建网站公司网页制作模板简单
  • 社区网站设计策划书3000字安卓优化大师app
  • 消防器材网站建设背景青岛谁做网站多少钱
  • 网站建设行吗业务型网站首页
  • 网站做404不同类型的网站
  • 专题网站建设总要求my21777域名查询
  • 怎么创建图片网站重庆企业展厅设计
  • 外卖网站建设价钱建设工程信息化平台
  • 服装设计素材网站大全公司系统软件
  • 湖南众诚建设 官方网站小米手机网站建设目标
  • 做一元购网站中国做水产的有什么网站
  • 南阳百度网站推广想开个小说网站怎么做
  • 智慧团建网站入口手机版重庆 做网站