ROS 2 Humble Hawksbill将于2022年5月发布

2023-10-28 06:20
文章标签 发布 ros 2022 humble hawksbill

本文主要是介绍ROS 2 Humble Hawksbill将于2022年5月发布,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

ROS 2 Humble Hawksbill应该是第一款走向成熟的ROS2长期支持版本(LTS)。

ROS 2目前各模块功能还在不断完善和修订,ROS 2 Humble Hawksbill是ROS2的第八个发行版。

March 21, 2022Alpha + RMW freeze
April 4, 2022Freeze
April 18, 2022Branch
April 25, 2022Beta
May 16, 2022Release Candidate
May 19, 2022Distro Freeze
May 23, 2022 General Availability
Rolling Ridley

rclcpp

标准格式转换案例:

std_msgs::msg::String 与 std::string 转换。

template<>
struct rclcpp::TypeAdapter<std::string,std_msgs::msg::String
>
{using is_specialized = std::true_type;using custom_type = std::string;using ros_message_type = std_msgs::msg::String;staticvoidconvert_to_ros_message(const custom_type & source,ros_message_type & destination){destination.data = source;}staticvoidconvert_to_custom(const ros_message_type & source,custom_type & destination){destination = source.data;}
};

使用案例:

using MyAdaptedType = TypeAdapter<std::string, std_msgs::msg::String>;// Publish a std::string
auto pub = node->create_publisher<MyAdaptedType>(...);
std::string custom_msg = "My std::string"
pub->publish(custom_msg);// Pass a std::string to a subscription's callback
auto sub = node->create_subscription<MyAdaptedType>("topic",10,[](const std::string & msg) {...});

在目前较新版本的ROS2(b83b18598b)仅pub或sub的实现方式cpp代码就有5种。以上面改进为例,pub代码如下(使用 `std::string` 代替 `std_msgs::msg::String`):

#include <chrono>
#include <functional>
#include <memory>
#include <string>#include "rclcpp/type_adapter.hpp"
#include "rclcpp/rclcpp.hpp"#include "std_msgs/msg/string.hpp"using namespace std::chrono_literals;template<>
struct rclcpp::TypeAdapter<std::string, std_msgs::msg::String>
{using is_specialized = std::true_type;using custom_type = std::string;using ros_message_type = std_msgs::msg::String;staticvoidconvert_to_ros_message(const custom_type & source,ros_message_type & destination){destination.data = source;}staticvoidconvert_to_custom(const ros_message_type & source,custom_type & destination){destination = source.data;}
};class MinimalPublisher : public rclcpp::Node
{using MyAdaptedType = rclcpp::TypeAdapter<std::string, std_msgs::msg::String>;public:MinimalPublisher(): Node("minimal_publisher"), count_(0){publisher_ = this->create_publisher<MyAdaptedType>("topic", 10);timer_ = this->create_wall_timer(500ms, std::bind(&MinimalPublisher::timer_callback, this));}private:void timer_callback(){std::string message = "Hello, world! " + std::to_string(count_++);RCLCPP_INFO(this->get_logger(), "Publishing: '%s'", message.c_str());publisher_->publish(message);}rclcpp::TimerBase::SharedPtr timer_;rclcpp::Publisher<MyAdaptedType>::SharedPtr publisher_;size_t count_;
};int main(int argc, char * argv[])
{rclcpp::init(argc, argv);rclcpp::spin(std::make_shared<MinimalPublisher>());rclcpp::shutdown();return 0;
}

sub代码如下:

#include <functional>
#include <memory>
#include <string>#include "rclcpp/type_adapter.hpp"
#include "rclcpp/rclcpp.hpp"#include "std_msgs/msg/string.hpp"using std::placeholders::_1;template<>
struct rclcpp::TypeAdapter<std::string, std_msgs::msg::String>
{using is_specialized = std::true_type;using custom_type = std::string;using ros_message_type = std_msgs::msg::String;staticvoidconvert_to_ros_message(const custom_type & source,ros_message_type & destination){destination.data = source;}staticvoidconvert_to_custom(const ros_message_type & source,custom_type & destination){destination = source.data;}
};class MinimalSubscriber : public rclcpp::Node
{using MyAdaptedType = rclcpp::TypeAdapter<std::string, std_msgs::msg::String>;public:MinimalSubscriber(): Node("minimal_subscriber"){subscription_ = this->create_subscription<MyAdaptedType>("topic", 10, std::bind(&MinimalSubscriber::topic_callback, this, _1));}private:void topic_callback(const std::string & msg) const{RCLCPP_INFO(this->get_logger(), "I heard: '%s'", msg.c_str());}rclcpp::Subscription<MyAdaptedType>::SharedPtr subscription_;
};int main(int argc, char * argv[])
{rclcpp::init(argc, argv);rclcpp::spin(std::make_shared<MinimalSubscriber>());rclcpp::shutdown();return 0;
}

这样的细节变化非常多,在dashing到foxy中,更多的是功能完善,而非bug补丁,这从侧面体现了ROS2的版本离稳定成熟还需一段时间。

ros2cli

这是命令行接口,pub和sub其实都非常常用,但是

使用标志时,将在开始发布之前等待找到一个匹配的订阅。 这避免了 ros2cli 节点在发现匹配订阅之前开始发布的问题,这会导致一些第一条消息丢失。

ros2 topic pub -1 -w 1 /chatter std_msgs/msg/String "{data: 'foo'}"

更多细节查阅官方文档。


这篇关于ROS 2 Humble Hawksbill将于2022年5月发布的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/291313

相关文章

定价129元!支持双频 Wi-Fi 5的华为AX1路由器发布

《定价129元!支持双频Wi-Fi5的华为AX1路由器发布》华为上周推出了其最新的入门级Wi-Fi5路由器——华为路由AX1,建议零售价129元,这款路由器配置如何?详细请看下文介... 华为 Wi-Fi 5 路由 AX1 已正式开售,新品支持双频 1200 兆、配有四个千兆网口、提供可视化智能诊断功能,建

五大特性引领创新! 深度操作系统 deepin 25 Preview预览版发布

《五大特性引领创新!深度操作系统deepin25Preview预览版发布》今日,深度操作系统正式推出deepin25Preview版本,该版本集成了五大核心特性:磐石系统、全新DDE、Tr... 深度操作系统今日发布了 deepin 25 Preview,新版本囊括五大特性:磐石系统、全新 DDE、Tree

Linux Mint Xia 22.1重磅发布: 重要更新一览

《LinuxMintXia22.1重磅发布:重要更新一览》Beta版LinuxMint“Xia”22.1发布,新版本基于Ubuntu24.04,内核版本为Linux6.8,这... linux Mint 22.1「Xia」正式发布啦!这次更新带来了诸多优化和改进,进一步巩固了 Mint 在 Linux 桌面

多模块的springboot项目发布指定模块的脚本方式

《多模块的springboot项目发布指定模块的脚本方式》该文章主要介绍了如何在多模块的SpringBoot项目中发布指定模块的脚本,作者原先的脚本会清理并编译所有模块,导致发布时间过长,通过简化脚本... 目录多模块的springboot项目发布指定模块的脚本1、不计成本地全部发布2、指定模块发布总结多模

高效+灵活,万博智云全球发布AWS无代理跨云容灾方案!

摘要 近日,万博智云推出了基于AWS的无代理跨云容灾解决方案,并与拉丁美洲,中东,亚洲的合作伙伴面向全球开展了联合发布。这一方案以AWS应用环境为基础,将HyperBDR平台的高效、灵活和成本效益优势与无代理功能相结合,为全球企业带来实现了更便捷、经济的数据保护。 一、全球联合发布 9月2日,万博智云CEO Michael Wong在线上平台发布AWS无代理跨云容灾解决方案的阐述视频,介绍了

Vue3项目开发——新闻发布管理系统(六)

文章目录 八、首页设计开发1、页面设计2、登录访问拦截实现3、用户基本信息显示①封装用户基本信息获取接口②用户基本信息存储③用户基本信息调用④用户基本信息动态渲染 4、退出功能实现①注册点击事件②添加退出功能③数据清理 5、代码下载 八、首页设计开发 登录成功后,系统就进入了首页。接下来,也就进行首页的开发了。 1、页面设计 系统页面主要分为三部分,左侧为系统的菜单栏,右侧

maven发布项目到私服-snapshot快照库和release发布库的区别和作用及maven常用命令

maven发布项目到私服-snapshot快照库和release发布库的区别和作用及maven常用命令 在日常的工作中由于各种原因,会出现这样一种情况,某些项目并没有打包至mvnrepository。如果采用原始直接打包放到lib目录的方式进行处理,便对项目的管理带来一些不必要的麻烦。例如版本升级后需要重新打包并,替换原有jar包等等一些额外的工作量和麻烦。为了避免这些不必要的麻烦,通常我们

禅道Docker安装包发布

禅道Docker安装包发布 大家好, 禅道Docker安装包发布。 一、下载地址 禅道开源版:   /dl/zentao/docker/docker_zentao.zip  备用下载地址:https://download.csdn.net/download/u013490585/16271485 数据库用户名: root,默认密码: 123456。运行时,可以设置 MYSQL_ROOT_P

ROS - C++实现RosBag包回放/提取

文章目录 1. 回放原理2. 回放/提取 多个话题3. 回放/提取数据包,并实时发布 1. 回放原理 #include <ros/ros.h>#include <rosbag/bag.h>#include <std_msgs/String.h>int main(int argc, char** argv){// 初始化ROS节点ros::init(argc, argv,

ROS - C++实现RosBag包录制

文章目录 1. 录制原理2. 录制多个话题3. 订阅ROS消息,实时录制 1. 录制原理 #include <ros/ros.h>#include <rosbag/bag.h>#include <std_msgs/String.h>int main(int argc, char** argv){// 初始化ROS节点ros::init(argc, argv, "reco