中文亚洲精品无码_熟女乱子伦免费_人人超碰人人爱国产_亚洲熟妇女综合网

當前位置: 首頁 > news >正文

京東網(wǎng)站建設(shè)的意義seo信息網(wǎng)

京東網(wǎng)站建設(shè)的意義,seo信息網(wǎng),天津做網(wǎng)站美工,網(wǎng)站建設(shè)常用模板下載在智能駕駛中,DDS有可能被廣泛使用,因此推出這篇說明教程。 1、基于【QT開發(fā)(5)】教程的項目文檔進行開發(fā) 2、安裝DDS 查看《【eProsima Fast DDS(1)】安裝eProsima Fast DDS》 至少安裝: foonathan_m…

在智能駕駛中,DDS有可能被廣泛使用,因此推出這篇說明教程。

1、基于【QT開發(fā)(5)】教程的項目文檔進行開發(fā)

2、安裝DDS

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

至少安裝:

foonathan_memory_vendor,一個 STL 兼容的 C++ 內(nèi)存分配器 庫。
fastcdr,一個根據(jù) CDR 標準進行數(shù)據(jù)序列化的 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 文件(本質(zhì)是定義定義數(shù)據(jù)結(jié)構(gòu)體類型),然后通過DDS的代碼生成工具生成 cpp 和hpp文件。如下圖:
在這里插入圖片描述

因為我們使用的【QT開發(fā)(5)】教程的項目文檔進行開發(fā),哪個項目直接遍歷src 目錄里面全部的cpp和hpp文件。因此我們把message 復(fù)制進入src目錄即可,不用變更cmakelists

例如我們定義兩個數(shù)據(jù)結(jié)構(gòu)體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 代碼的風(fēng)格兼容,我們導(dǎo)入了rclcpp

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

因為我們使用的【QT開發(fā)(5)】教程的項目文檔進行開發(fā),哪個項目直接遍歷src 目錄里面全部的cpp和hpp文件。因此我們把rclcpp復(fù)制進入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開發(fā)(5)】教程的項目文檔進行開發(fā),哪個項目直接遍歷src 目錄里面全部的cpp和hpp文件。因此我們把message 、rclcpp復(fù)制進入src目錄即可,不用變更cmakelists

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

我們建立一個example文件夾,建立example.cpp 和 example.hpp

先寫 example.hpp,首先引入頭文件

#include <rclcpp/rclcpp.hpp>
#include <PerceptionCommand.hpp>  // 這個是message 里面定義的 dds 通信數(shù)據(jù)結(jié)構(gòu)體
#include <WorkingStatus.hpp>    // 這個是message 里面定義的 dds 通信數(shù)據(jù)結(jié)構(gòu)體

然后建立一個對象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#建立 訂閱者的回調(diào)函數(shù) msg_PerceptionCommand_callback,實現(xiàn)的數(shù)據(jù)存放在perceptionCommand_成員void msg_PerceptionCommand_callback(const auto_msg::msg::PerceptionCommand::SharedPtr msg);// 4# 建立一個50ms 的定時器rclcpp::TimerBase::SharedPtr workingStatus_timer_;// 5# 建立發(fā)布者 Publisherrclcpp::Publisher<auto_msg::msg::WorkingStatus>::SharedPtr workingStatus_pub_;rclcpp::AtomicSet<auto_msg::msg::WorkingStatus> workingStatus_;// 6# 定時器的回調(diào)函數(shù)void timer_WorkingStatus_callback();};

我們建立了6個函數(shù),分別的作用是
1、建立一個 perceptionCommand_sub_ 訂閱者
2、建立一個 perceptionCommand_ 的信息存儲的成員
3、建立 訂閱者的回調(diào)函數(shù) msg_PerceptionCommand_callback,實現(xiàn)把收到的數(shù)據(jù)存放在 perceptionCommand_ 的信息存儲的成員里面
4、建立一個50ms 的定時器
5、建立一個 workingStatus_pub_ 的發(fā)布者;4、建立一個 workingStatus_ 成員
6、建立一個 定時器的回調(diào)函數(shù),處理perceptionCommand_ 成員的數(shù)據(jù),并發(fā)送workingStatus_pub_ 數(shù)據(jù)。

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 函數(shù)里面加入

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

關(guān)于 rclcpp::spin() 的說明可以看我的另外一篇文章《【eProsima Fast DDS(2)】ROS2:spin() spin_some()函數(shù)》,這個是堵塞了main 函數(shù)。

整體上處理的思路是:

1、建立一個 perceptionCommand_sub_ 訂閱者
2、建立一個 perceptionCommand_ 的信息存儲的成員
3、建立 訂閱者的回調(diào)函數(shù) msg_PerceptionCommand_callback,實現(xiàn)把收到的數(shù)據(jù)存放在 perceptionCommand_ 的信息存儲的成員里面
4、建立一個50ms 的定時器
5、建立一個 workingStatus_pub_ 的發(fā)布者;4、建立一個 workingStatus_ 成員
6、建立一個 定時器的回調(diào)函數(shù),處理perceptionCommand_ 成員的數(shù)據(jù),并發(fā)送workingStatus_pub_ 數(shù)據(jù)。

建立一個訂閱者
建立一個存儲成員
訂閱者的回調(diào)函數(shù)把收到的數(shù)據(jù)存放在成員
建立一個50ms 的定時器
建立發(fā)布者
定時器回調(diào)>處理存儲的數(shù)據(jù)>并調(diào)用發(fā)布者發(fā)數(shù)據(jù)
http://www.risenshineclean.com/news/3902.html

相關(guān)文章:

  • 如何做介紹監(jiān)控公司的網(wǎng)站怎么做網(wǎng)站推廣
  • 保定市做網(wǎng)站百度seo優(yōu)化及推廣
  • 廣州網(wǎng)站建設(shè)設(shè)計公司信息網(wǎng)頁設(shè)計效果圖及代碼
  • net做網(wǎng)站軟文推廣代表平臺
  • 怎樣做seo網(wǎng)站鏈接?xùn)|莞疫情最新情況
  • 在哪個網(wǎng)站有兼職做免費發(fā)布推廣信息的b2b
  • 哈爾濱網(wǎng)站推廣公司有創(chuàng)意的網(wǎng)絡(luò)廣告案例
  • 私人精品貨源網(wǎng)站有哪些360收錄提交入口網(wǎng)址
  • 美術(shù)教育機構(gòu)網(wǎng)站建設(shè)方案萬網(wǎng)域名注冊
  • 網(wǎng)站建設(shè)注意哪些內(nèi)容如何百度收錄自己的網(wǎng)站
  • 網(wǎng)站域名空間費用windows優(yōu)化大師好用嗎
  • 怎么做優(yōu)惠券網(wǎng)站電子商務(wù)主要干什么
  • 口紅機網(wǎng)站怎么做免費的編程自學(xué)網(wǎng)站
  • 網(wǎng)站建站知識惠州seo外包平臺
  • 有哪些制作網(wǎng)站的公司嗎優(yōu)質(zhì)外鏈
  • 幼兒園主題活動設(shè)計網(wǎng)絡(luò)圖優(yōu)化網(wǎng)站平臺
  • 做的好的中醫(yī)網(wǎng)站網(wǎng)絡(luò)游戲推廣公司
  • 網(wǎng)站應(yīng)用開發(fā)微博營銷案例
  • wordpress文章可見隱藏內(nèi)容全網(wǎng)seo優(yōu)化電話
  • 廣州網(wǎng)站建設(shè)開發(fā)團隊查看百度關(guān)鍵詞價格
  • 建設(shè)小說網(wǎng)站的系統(tǒng)有哪些目前主流搜索引擎是哪種
  • 私人做網(wǎng)站費用如何注冊域名及網(wǎng)站
  • 做網(wǎng)站1g網(wǎng)頁空間夠嗎百度推廣退款電話
  • 萬戶網(wǎng)站建設(shè)拉新app推廣接單平臺
  • 上海建筑建材業(yè)網(wǎng)招標seo營銷推廣
  • 做家電家具回收用哪個網(wǎng)站好網(wǎng)絡(luò)營銷服務(wù)商
  • wordpress整合ldap重慶網(wǎng)站優(yōu)化公司
  • 怎么使用服務(wù)器做網(wǎng)站哪里可以引流到精準客戶呢
  • 南山制作網(wǎng)站公司b站推廣網(wǎng)站2024
  • 在線客服系統(tǒng)功能百度禁止seo推廣