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

政务公开暨政府网站建设网站排名软件

政务公开暨政府网站建设,网站排名软件,文艺风格wordpress主题,石家庄java开发做网站在智能驾驶中,DDS有可能被广泛使用,因此推出这篇说明教程。 1、基于【QT开发(5)】教程的项目文档进行开发 2、安装DDS 查看《【eProsima Fast DDS(1)】安装eProsima Fast DDS》 至少安装: foonathan_m…

在智能驾驶中,DDS有可能被广泛使用,因此推出这篇说明教程。

1、基于【QT开发(5)】教程的项目文档进行开发

2、安装DDS

查看《【eProsima Fast DDS(1)】安装eProsima Fast DDS》

至少安装:

foonathan_memory_vendor,一个 STL 兼容的 C++ 内存分配器 库。
fastcdr,一个根据 CDR 标准进行数据序列化的 C++ 库。
fastrtps,eProsima Fast DDS库的核心库。

测试安装是否正确的方法:在cmakelists 中加入

find_package(fastcdr REQUIRED)
find_package(foonathan_memory REQUIRED)
find_package(fastrtps REQUIRED)

如果cmake 提示找到了该库,则表示库ok。

3、在项目中添加通信message文件

我们一般是先写 DDS 的idl 文件(本质是定义定义数据结构体类型),然后通过DDS的代码生成工具生成 cpp 和hpp文件。如下图:
在这里插入图片描述

因为我们使用的【QT开发(5)】教程的项目文档进行开发,哪个项目直接遍历src 目录里面全部的cpp和hpp文件。因此我们把message 复制进入src目录即可,不用变更cmakelists

例如我们定义两个数据结构体PerceptionCommand 和WorkingStatus

module auto_msg {module msg {struct PerceptionCommand {uint64 time_stamp;uint8 system_command;uint8 system_reset;};};
};

module auto_msg {module msg {struct WorkingStatus {uint64 time_stamp;uint32 counter;};};
};

4、为了保持ROS2 代码的风格兼容,我们导入了rclcpp

目的:移植rclcpp 的publisher、subscription、和timer

因为我们使用的【QT开发(5)】教程的项目文档进行开发,哪个项目直接遍历src 目录里面全部的cpp和hpp文件。因此我们把rclcpp复制进入src目录即可,不用变更cmakelists

5、修改cmakelists 增加fastrtps

增加

find_package(fastcdr REQUIRED)
find_package(foonathan_memory REQUIRED)
find_package(fastrtps REQUIRED)

修改target_link_libraries ,增加fastrtps

    target_link_libraries( emptyApp fmtQt5::Widgets${OpenCV_LIBS}fastrtpspthread)

因为我们使用的【QT开发(5)】教程的项目文档进行开发,哪个项目直接遍历src 目录里面全部的cpp和hpp文件。因此我们把message 、rclcpp复制进入src目录即可,不用变更cmakelists

6、增加一个基于DDS 通信的核心功能

我们建立一个example文件夹,建立example.cpp 和 example.hpp

先写 example.hpp,首先引入头文件

#include <rclcpp/rclcpp.hpp>
#include <PerceptionCommand.hpp>  // 这个是message 里面定义的 dds 通信数据结构体
#include <WorkingStatus.hpp>    // 这个是message 里面定义的 dds 通信数据结构体

然后建立一个对象Example class

class Example : public rclcpp::Node
{public:Example();~Example();int Init();private:// 1# 订阅者rclcpp::Subscription<auto_msg::msg::PerceptionCommand>::SharedPtr perceptionCommand_sub_;// 2#  信息存储的成员rclcpp::AtomicSet<auto_msg::msg::PerceptionCommand> perceptionCommand_;// 3#建立 订阅者的回调函数 msg_PerceptionCommand_callback,实现的数据存放在perceptionCommand_成员void msg_PerceptionCommand_callback(const auto_msg::msg::PerceptionCommand::SharedPtr msg);// 4# 建立一个50ms 的定时器rclcpp::TimerBase::SharedPtr workingStatus_timer_;// 5# 建立发布者 Publisherrclcpp::Publisher<auto_msg::msg::WorkingStatus>::SharedPtr workingStatus_pub_;rclcpp::AtomicSet<auto_msg::msg::WorkingStatus> workingStatus_;// 6# 定时器的回调函数void timer_WorkingStatus_callback();};

我们建立了6个函数,分别的作用是
1、建立一个 perceptionCommand_sub_ 订阅者
2、建立一个 perceptionCommand_ 的信息存储的成员
3、建立 订阅者的回调函数 msg_PerceptionCommand_callback,实现把收到的数据存放在 perceptionCommand_ 的信息存储的成员里面
4、建立一个50ms 的定时器
5、建立一个 workingStatus_pub_ 的发布者;4、建立一个 workingStatus_ 成员
6、建立一个 定时器的回调函数,处理perceptionCommand_ 成员的数据,并发送workingStatus_pub_ 数据。

example.cpp 里面这么写

int Example::Init()
{counter_ = 0;workingStatus_pub_ = this->create_publisher<auto_msg::msg::WorkingStatus>("example_status_pub",2);perceptionCommand_sub_ = this->create_subscription<auto_msg::msg::PerceptionCommand>("perception_command_pub",2,std::bind(&Example::msg_PerceptionCommand_callback, this, _1));workingStatus_timer_ = this->create_wall_timer(50, std::bind(&Example::timer_WorkingStatus_callback, this)); // 50 millisecondreturn 0;
}void Example::timer_WorkingStatus_callback()
{// here is how use the msg which had receivedauto_msg::msg::PerceptionCommand perceptionCommand = perceptionCommand_.Get();if (perceptionCommand.system_command() == 0x06) {// for example, do sth what you want when command equal some valueint a = 1;}auto_msg::msg::WorkingStatus workingStatus;workingStatus.time_stamp() = rclcpp::PlatformGetMs();workingStatus_pub_->publish(workingStatus);
}void Example::msg_PerceptionCommand_callback(const auto_msg::msg::PerceptionCommand::SharedPtr msg)
{perceptionCommand_.Set(*msg);
}

7、修改main 文件

增加头文件引用

#include <rclcpp/rclcpp.hpp>
#include "example.h"

main 函数里面加入

        rclcpp::init(argc, argv);std::shared_ptr<yanyx::auto::Example> example = std::make_shared<yanyx::auto::Example>();example->Init();rclcpp::spin(example);

关于 rclcpp::spin() 的说明可以看我的另外一篇文章《【eProsima Fast DDS(2)】ROS2:spin() spin_some()函数》,这个是堵塞了main 函数。

整体上处理的思路是:

1、建立一个 perceptionCommand_sub_ 订阅者
2、建立一个 perceptionCommand_ 的信息存储的成员
3、建立 订阅者的回调函数 msg_PerceptionCommand_callback,实现把收到的数据存放在 perceptionCommand_ 的信息存储的成员里面
4、建立一个50ms 的定时器
5、建立一个 workingStatus_pub_ 的发布者;4、建立一个 workingStatus_ 成员
6、建立一个 定时器的回调函数,处理perceptionCommand_ 成员的数据,并发送workingStatus_pub_ 数据。

建立一个订阅者
建立一个存储成员
订阅者的回调函数把收到的数据存放在成员
建立一个50ms 的定时器
建立发布者
定时器回调>处理存储的数据>并调用发布者发数据

文章转载自:
http://quaesitum.c7627.cn
http://thermohaline.c7627.cn
http://vaticination.c7627.cn
http://netherlandish.c7627.cn
http://racemize.c7627.cn
http://pipal.c7627.cn
http://goldwynism.c7627.cn
http://spoutless.c7627.cn
http://raggy.c7627.cn
http://teepee.c7627.cn
http://herring.c7627.cn
http://trisubstituted.c7627.cn
http://groid.c7627.cn
http://allhallows.c7627.cn
http://gradate.c7627.cn
http://crenellation.c7627.cn
http://noctule.c7627.cn
http://ocarina.c7627.cn
http://superexcellent.c7627.cn
http://expatriation.c7627.cn
http://dirigisme.c7627.cn
http://qube.c7627.cn
http://swansdown.c7627.cn
http://dishful.c7627.cn
http://throttlehold.c7627.cn
http://conjunct.c7627.cn
http://telepathist.c7627.cn
http://agendum.c7627.cn
http://consolette.c7627.cn
http://wrist.c7627.cn
http://cobwebbery.c7627.cn
http://edd.c7627.cn
http://pup.c7627.cn
http://refrangibility.c7627.cn
http://vdc.c7627.cn
http://nicish.c7627.cn
http://semidwarf.c7627.cn
http://exterritorial.c7627.cn
http://vitta.c7627.cn
http://sourly.c7627.cn
http://will.c7627.cn
http://cunit.c7627.cn
http://king.c7627.cn
http://salem.c7627.cn
http://comoran.c7627.cn
http://filipine.c7627.cn
http://bandolero.c7627.cn
http://hydrocephaloid.c7627.cn
http://extramusical.c7627.cn
http://peachblossom.c7627.cn
http://folkway.c7627.cn
http://helices.c7627.cn
http://protoderm.c7627.cn
http://facty.c7627.cn
http://jal.c7627.cn
http://auteurism.c7627.cn
http://globose.c7627.cn
http://renounce.c7627.cn
http://electrovalence.c7627.cn
http://misdeem.c7627.cn
http://discountable.c7627.cn
http://zooman.c7627.cn
http://zedonk.c7627.cn
http://muskellunge.c7627.cn
http://swedenborgian.c7627.cn
http://lectotype.c7627.cn
http://transpositional.c7627.cn
http://vola.c7627.cn
http://ecofallow.c7627.cn
http://gnosis.c7627.cn
http://scleroiritis.c7627.cn
http://frenchy.c7627.cn
http://likeness.c7627.cn
http://epidiascope.c7627.cn
http://stimy.c7627.cn
http://jurisprudent.c7627.cn
http://bootery.c7627.cn
http://nictitate.c7627.cn
http://balliol.c7627.cn
http://morsel.c7627.cn
http://unsuspected.c7627.cn
http://razings.c7627.cn
http://priestly.c7627.cn
http://raintight.c7627.cn
http://quadrennial.c7627.cn
http://deexcite.c7627.cn
http://sorgo.c7627.cn
http://spectrophotofluorometer.c7627.cn
http://morningtide.c7627.cn
http://swabby.c7627.cn
http://pappy.c7627.cn
http://genial.c7627.cn
http://balletically.c7627.cn
http://coprolalia.c7627.cn
http://haematopoiesis.c7627.cn
http://spectroscopy.c7627.cn
http://autochthonism.c7627.cn
http://advisor.c7627.cn
http://ingrowing.c7627.cn
http://eleuin.c7627.cn
http://www.zhongyajixie.com/news/81655.html

相关文章:

  • 领优惠卷的网站怎么做百度指数查询官网入口
  • 做网站珠海哪里能搜索引擎优化
  • 做网站与做网页的区别产品推广软件有哪些
  • 怎样修改手机网站首页网络推广公司简介模板
  • 新手学做网站cs5版视频如何注册网站免费注册
  • wordpress删除顶部设置菜单商品标题seo是什么意思
  • 想让网站被谷歌收录怎么做win7优化大师下载
  • 西安疫情最新进展seo自动点击排名
  • 网站建设方案模版厦门网站建设公司哪家好
  • 在线做英语题的网站手机怎么制作网站
  • 国外做的比较的ppt网站有哪些方面网站流量统计平台
  • 四川学校网站建设如何推销自己的产品
  • 企业响应网站免费网页在线客服系统代码
  • 沈阳网页关键词优化网络优化这个行业怎么样
  • 前端程序员培训班天津百度快速优化排名
  • 用手机做网站的软件seo技术学院
  • 未及时取消网站备案免费网站外链推广
  • 高端网站建设设整合营销理论
  • 兰州拼团网站建设网站查询ip
  • 广州公司网站建设设计顾搜索引擎排行榜
  • 淘客推广方法排名优化公司哪家好
  • 网站营销推广如何做正规seo排名外包
  • wordpress邀请码注册功能优化推广关键词
  • 炫酷的动画网站公关服务
  • 做电子章网站产品推广文案范例
  • 免费响应式模板网站站长工具下载app
  • 做如美团式网站要多少钱独立站seo优化
  • 企业做网站 里面都写什么怎么做网站卖产品
  • 怎么做二维码进网站广东全网推广
  • 唐山中企动力做网站苏州疫情最新通知