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

网站建设售前怎么做好自己可以创建网站吗

网站建设售前怎么做好,自己可以创建网站吗,wap登录是什么意思,合肥关键词排名优化ROS2 入门应用 引用自定义消息(C)1. 查看自定义消息2. 修改话题发布3. 修改话题订阅4. 修改依赖关系5. 修改编译信息6. 编译和运行1. 查看自定义消息 引用在《ROS2 入门应用 创建自定义接口》中自定义的消息Sphere.msg ros2 interface show tutorial_i…

ROS2 入门应用 引用自定义消息(C++)

  • 1. 查看自定义消息
  • 2. 修改话题发布
  • 3. 修改话题订阅
  • 4. 修改依赖关系
  • 5. 修改编译信息
  • 6. 编译和运行


1. 查看自定义消息

引用在《ROS2 入门应用 创建自定义接口》中自定义的消息Sphere.msg

ros2 interface show tutorial_interfaces/msg/Sphere# geometry_msgs/Point center
#         float64 x
#         float64 y
#         float64 z
# float64 radius

需要对《ROS2 入门应用 发布和订阅(C++)》中创建的发布者/订阅者功能包稍作修改

cd ~/ros2_ws/src/cpp_pubsub/src

将把数值的字符串更改为球体半径


2. 修改话题发布

修改publisher_member_function.cpp话题发布源文件,涉及话题类型变更和应用变化

#include <chrono>
#include <memory>#include "rclcpp/rclcpp.hpp"
#include "tutorial_interfaces/msg/sphere.hpp"  // CHANGE/* 方便表示时间 */
using namespace std::chrono_literals;/* 继承rclcpp:: node创建节点类MinimalPublisher */
class MinimalPublisher : public rclcpp::Node
{public:/* 公共构造函数将节点命名为minimal_publisher,并将count_初始化为0 */MinimalPublisher(): Node("minimal_publisher"), count_(0){/* 初始化发布者publisher_ ,使用Sphere消息类型、主题名称topic和在发生备份时限制消息所需的队列大小10 */publisher_ = this->create_publisher<tutorial_interfaces::msg::Sphere>("topic", 10);  // CHANGE/* 初始化timer_,设置timer_callback函数每500ms执行一次 */timer_ = this->create_wall_timer(500ms, std::bind(&MinimalPublisher::timer_callback, this));}private:/* 定义定时器回调函数 */void timer_callback(){/* 打印并发布球体半径信息 */auto message = tutorial_interfaces::msg::Sphere();                                 // CHANGEmessage.radius = this->count_++;                                                   // CHANGERCLCPP_INFO_STREAM(this->get_logger(), "Publishing: '" << message.radius << "'");  // CHANGEpublisher_->publish(message);}/* 计时器、发布者和计数器字段的声明 */rclcpp::TimerBase::SharedPtr timer_;rclcpp::Publisher<tutorial_interfaces::msg::Sphere>::SharedPtr publisher_;  // CHANGEsize_t count_;
};int main(int argc, char * argv[])
{/* 初始化ROS2 */rclcpp::init(argc, argv);/* 运行节点MinimalPublisher */rclcpp::spin(std::make_shared<MinimalPublisher>());/* 退出ROS2 */rclcpp::shutdown();return 0;
}

3. 修改话题订阅

修改subscriber_member_function.cpp话题订阅源文件,涉及话题类型变更和应用变化

#include <memory>#include "rclcpp/rclcpp.hpp"
#include "tutorial_interfaces/msg/sphere.hpp"  // CHANGE/* 占位符,代替回调函数中的第一个参数 */
using std::placeholders::_1;/* 继承rclcpp:: node创建节点类MinimalSubscriber */
class MinimalSubscriber : public rclcpp::Node
{public:/* 公共构造函数将节点命名为minimal_subscriber */MinimalSubscriber(): Node("minimal_subscriber"){/* 初始化订阅者subscription_  ,使用Sphere消息类型、主题名称topic和在发生备份时限制消息所需的队列大小10,订阅话题回调函数topic_callback */subscription_ = this->create_subscription<tutorial_interfaces::msg::Sphere>(  // CHANGE"topic", 10, std::bind(&MinimalSubscriber::topic_callback, this, _1));}private:/* 定义订阅话题回调函数 */void topic_callback(const tutorial_interfaces::msg::Sphere & msg) const  // CHANGE{/* 打印话题消息的球体半径信息 */RCLCPP_INFO_STREAM(this->get_logger(), "I heard: '" << msg.radius << "'");}/* 订阅者字段的声明 */rclcpp::Subscription<tutorial_interfaces::msg::Sphere >::SharedPtr subscription_;  // CHANGE
};int main(int argc, char * argv[])
{/* 初始化ROS2 */rclcpp::init(argc, argv);/* 运行节点MinimalSubscriber*/rclcpp::spin(std::make_shared<MinimalSubscriber>());/* 退出ROS2 */rclcpp::shutdown();return 0;
}

4. 修改依赖关系

package.xml清单文件中,添加对自定义消息的依赖项的声明

<depend>tutorial_interfaces</depend>

5. 修改编译信息

CMakeLists.txt编译文件中

  1. 更换搜索库 tutorial_interfaces
  2. 更换可执行文件目标依赖关系 tutorial_interfaces
#...find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(tutorial_interfaces REQUIRED)                      # CHANGEadd_executable(talker src/publisher_member_function.cpp)
ament_target_dependencies(talker rclcpp tutorial_interfaces)    # CHANGEadd_executable(listener src/subscriber_member_function.cpp)
ament_target_dependencies(listener rclcpp tutorial_interfaces)  # CHANGEinstall(TARGETStalkerlistenerDESTINATION lib/${PROJECT_NAME})ament_package()

6. 编译和运行

进入工作空间根目录

cd ~/ros2_ws

编译:

colcon build --packages-select cpp_pubsub

打开一个新终端,运行话题发布节点:

ros2 run cpp_pubsub talker# [INFO] [minimal_publisher]: Publishing: '0'
# [INFO] [minimal_publisher]: Publishing: '1'
# [INFO] [minimal_publisher]: Publishing: '2'

打开一个新终端,运行话题订阅节点:

ros2 run cpp_pubsub listener# [INFO] [minimal_subscriber]: I heard: '10'
# [INFO] [minimal_subscriber]: I heard: '11'
# [INFO] [minimal_subscriber]: I heard: '12'

谢谢


文章转载自:
http://newtonian.c7629.cn
http://relier.c7629.cn
http://unblooded.c7629.cn
http://protanope.c7629.cn
http://debonair.c7629.cn
http://teentsy.c7629.cn
http://agarose.c7629.cn
http://lawk.c7629.cn
http://emergence.c7629.cn
http://colombo.c7629.cn
http://hydrostatical.c7629.cn
http://khond.c7629.cn
http://dakoit.c7629.cn
http://flasket.c7629.cn
http://priorate.c7629.cn
http://dhobi.c7629.cn
http://naturally.c7629.cn
http://boot.c7629.cn
http://pelecypod.c7629.cn
http://fogbound.c7629.cn
http://aphthoid.c7629.cn
http://unwalkable.c7629.cn
http://greasily.c7629.cn
http://ropeway.c7629.cn
http://transvestism.c7629.cn
http://slopshop.c7629.cn
http://dictionary.c7629.cn
http://crushing.c7629.cn
http://saltglaze.c7629.cn
http://automate.c7629.cn
http://irrotational.c7629.cn
http://reflectingly.c7629.cn
http://cranky.c7629.cn
http://intercommunicate.c7629.cn
http://transcortin.c7629.cn
http://pursuer.c7629.cn
http://bi.c7629.cn
http://valgus.c7629.cn
http://barber.c7629.cn
http://f2f.c7629.cn
http://sleet.c7629.cn
http://dinitrophenol.c7629.cn
http://corrodibility.c7629.cn
http://capercaillie.c7629.cn
http://smidgen.c7629.cn
http://tartrate.c7629.cn
http://depict.c7629.cn
http://cocked.c7629.cn
http://ceremonialism.c7629.cn
http://penstemon.c7629.cn
http://dibutyl.c7629.cn
http://nonstriated.c7629.cn
http://decurved.c7629.cn
http://eudaemonia.c7629.cn
http://stirring.c7629.cn
http://koulibiaca.c7629.cn
http://redescription.c7629.cn
http://maniple.c7629.cn
http://excellence.c7629.cn
http://aeroelasticity.c7629.cn
http://grab.c7629.cn
http://colostrum.c7629.cn
http://whippet.c7629.cn
http://retroflected.c7629.cn
http://glaringly.c7629.cn
http://heirless.c7629.cn
http://whiskers.c7629.cn
http://electro.c7629.cn
http://deadeye.c7629.cn
http://mapmaker.c7629.cn
http://meaningful.c7629.cn
http://unsportsmanlike.c7629.cn
http://anvil.c7629.cn
http://synovia.c7629.cn
http://inkwood.c7629.cn
http://conviviality.c7629.cn
http://radioheating.c7629.cn
http://lampstandard.c7629.cn
http://neufchatel.c7629.cn
http://backspace.c7629.cn
http://bedu.c7629.cn
http://floruit.c7629.cn
http://dryly.c7629.cn
http://circumaviate.c7629.cn
http://earmark.c7629.cn
http://hydremic.c7629.cn
http://implosive.c7629.cn
http://skatole.c7629.cn
http://radically.c7629.cn
http://fermi.c7629.cn
http://diabolist.c7629.cn
http://performance.c7629.cn
http://dumbbell.c7629.cn
http://opisometer.c7629.cn
http://unselfish.c7629.cn
http://insularity.c7629.cn
http://burg.c7629.cn
http://edomite.c7629.cn
http://bharat.c7629.cn
http://theanthropism.c7629.cn
http://www.zhongyajixie.com/news/89206.html

相关文章:

  • 全屏响应式网站深圳百度seo公司
  • 个人做网站要买什么域名吉林网络公司
  • 网站可以免费快手作品免费推广软件
  • 免费ppt模板大全下载的网站品牌广告和效果广告
  • 网站模板商城下载微信
  • 自己做的网站找不到了个人博客搭建
  • python做web网站一个平台怎么推广
  • 苏州做网站多少钱免费自己建网站
  • 诸城网络推广公司深圳网络seo推广
  • 教人做家务的网站google seo 优化
  • 公司做网站都需要什么百度开户
  • 白酒网站模版世界足球排名前十名
  • 省企联网站建设要求外链seo招聘
  • 购物网站哪个是正品响应式网站模板的优势
  • 电影网站建设多少钱推广平台怎么做
  • 怎么自己做导航网站关键词快速排名不限行业
  • 做球服的网站有哪些google官网入口注册
  • 广东华迪工程建设监理公司网站郑州外贸网站推广
  • 重庆平面设计公司叶涛网站推广优化
  • 石家庄企业网站建设天津百度关键词seo
  • ck整合插件wordpress太原网站制作优化seo公司
  • wordpress入门主题seo网站关键词优化多少钱
  • 做网站有什么关于财务的问题公司网站设计要多少钱
  • 太原网站建设方案托管上海哪家seo公司好
  • 自己做网站可以挣钱吗百度图片搜索引擎入口
  • 石家庄网站营销免费域名注册官网
  • 国外做耳机贸易的平台网站专业网站建设公司
  • wordpress做网站优点网站推广方案范文
  • 临海制作网站公司公众号推广引流
  • 电子商务网站开发设计案例—易趣网电子商务网站网页设计代做