ROS中几种常用的msg

本文详细介绍了ROS中两种常用的消息格式:nav_msgs/Odometry和geometry_msgs/Pose2D。Odometry消息包含了头部信息、坐标系ID、子坐标系ID、位置与方向的协方差矩阵等;Pose2D消息则简洁地表示了二维空间中的位置和朝向。



ROS中几种常用的msg

小狼@http://blog.youkuaiyun.com/xiaolangyangyang

[nav_msgs/Odometry]:
std_msgs/Header header
  uint32 seq
  time stamp
  string frame_id
string child_frame_id
geometry_msgs/PoseWithCovariance pose
  geometry_msgs/Pose pose
    geometry_msgs/Point position
      float64 x
      float64 y
      float64 z
    geometry_msgs/Quaternion orientation
      float64 x
      float64 y
      float64 z
      float64 w
  float64[36] covariance
geometry_msgs/TwistWithCovariance twist
  geometry_msgs/Twist twist
    geometry_msgs/Vector3 linear
      float64 x
      float64 y
      float64 z
    geometry_msgs/Vector3 angular
      float64 x
      float64 y
      float64 z
  float64[36] covariance


[geometry_msgs/Pose2D]:
float64 x
float64 y
float64 theta




### ROS2 中支持的发布订阅模型类型 在ROS2中,除了基本的一对多发布/订阅模式外,还提供了多种变体来满足不同的应用场景需求。 #### 1. 基本发布/订阅 (One-to-Many) 这是最常见也是最基本的通信形式,在这种模式下,一个或多个发布者可以向同一个主题发送消息,任何数量的订阅者都可以监听该主题并接收到发布的每条消息[^1]。 ```cpp // C++ Publisher Example using rclcpp and std_msgs #include "rclcpp/rclcpp.hpp" #include "std_msgs/msg/string.hpp" int main(int argc, char * argv[]) { rclcpp::init(argc, argv); auto node = rclcpp::Node::make_shared("publisher_node"); auto publisher = node->create_publisher<std_msgs::msg::String>("topic", 10); while(rclcpp::ok()){ auto message = std_msgs::msg::String(); message.data = "Hello World"; RCLCPP_INFO(node->get_logger(), "Publishing: '%s'", message.data.c_str()); publisher->publish(message); rclcpp::spin_some(node); sleep(1); } rclcpp::shutdown(); return 0; } ``` #### 2. 可靠性QoS策略下的发布/订阅 为了适应不同场景的需求,ROS2引入了服务质量(Quality of Service,QoS)设置。通过配置适当的服务质量参数,可以在一定程度上调整发布与订阅之间的行为特性,比如可靠性(Reliability): - **最佳努力(Best Effort)**:只尝试一次传输,不保证一定能成功送达。 - **可靠(Reliable)**:确保所有已发出的消息最终都会被接收方获取到(除非连接断开)。 #### 3. 历史记录(History) QoS Policy 下 的 发布 / 订阅 历史记录政策定义了当新的订阅加入时它能获得多少先前的数据项。这同样属于QoS的一部分: - **保持最近(Keeplast)** :仅保留最新N个样本给新来的订阅者。 - **系统全量(System)** : 提供自启动以来所有的数据给后来的新订阅者。
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值