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

nav2_gps_waypoint_follower_demo 不能在ros2 humble中直接使用的解决方法

GIT上的nav2_gps_waypoint_follower_demo是基于ros-iron编写的,其中followGpsWaypoints(wps) service只能在Iron上使用。

解决方法:

第一步:interactive_waypoint_follower.py修改为如下代码:

import rclpy
from rclpy.node import Node
from nav2_simple_commander.robot_navigator import BasicNavigator
from geometry_msgs.msg import PointStamped
from nav2_gps_waypoint_follower_demo.utils.gps_utils import latLonYaw2Geopose
from nav2_msgs.action import FollowWaypoints
from geometry_msgs.msg import PoseStamped
from robot_localization.srv import FromLLclass InteractiveGpsWpCommander(Node):"""ROS2 node to send gps waypoints to nav2 received from mapviz's point click publisher"""def __init__(self):super().__init__(node_name="gps_wp_commander")self.navigator = BasicNavigator("basic_navigator")self.mapviz_wp_sub = self.create_subscription(PointStamped, "/clicked_point", self.mapviz_wp_cb, 1)self.localizer = self.create_client(FromLL,  '/fromLL')while not self.localizer.wait_for_service(timeout_sec=1.0):self.get_logger().info('Service not available, waiting again...')self.client_futures = []self.get_logger().info('Ready for waypoints...')def mapviz_wp_cb(self, msg: PointStamped):"""clicked point callback, sends received point to nav2 gps waypoint follower if its a geographic point"""if msg.header.frame_id != "wgs84":self.get_logger().warning("Received point from mapviz that ist not in wgs84 frame. This is not a gps point and wont be followed")returnwps = [latLonYaw2Geopose(msg.point.y, msg.point.x)]for wp in wps:self.req = FromLL.Request()self.req.ll_point.longitude = wp.position.longitudeself.req.ll_point.latitude = wp.position.latitudeself.req.ll_point.altitude = wp.position.altitudeself.get_logger().info("Waypoint added to conversion queue...")self.client_futures.append(self.localizer.call_async(self.req))def command_send_cb(self, future):self.resp = PoseStamped()self.resp.header.frame_id = 'map'self.resp.header.stamp = self.get_clock().now().to_msg()self.resp.pose.position = future.result().map_pointself.navigator.goToPose(self.resp)def spin(self):while rclpy.ok():rclpy.spin_once(self)incomplete_futures = []for f in self.client_futures:if f.done():self.client_futures.remove(f)self.get_logger().info("Following converted waypoint...")self.command_send_cb(f)else:incomplete_futures.append(f)self.client_futures = incomplete_futuresdef main():rclpy.init()gps_wpf = InteractiveGpsWpCommander()gps_wpf.spin()if __name__ == "__main__":main()

logged_waypoint_follower.py改为如下代码:

import rclpy
from nav2_simple_commander.robot_navigator import BasicNavigator
import yaml
from ament_index_python.packages import get_package_share_directory
import os
import sys
import time
from robot_localization.srv import FromLL
from rclpy.node import Node
from nav2_gps_waypoint_follower_demo.utils.gps_utils import latLonYaw2Geopose
from nav2_msgs.action import FollowWaypoints
from geometry_msgs.msg import PoseStampedclass YamlWaypointParser:"""Parse a set of gps waypoints from a yaml file"""def __init__(self, wps_file_path: str) -> None:with open(wps_file_path, 'r') as wps_file:self.wps_dict = yaml.safe_load(wps_file)def get_wps(self):"""Get an array of geographic_msgs/msg/GeoPose objects from the yaml file"""gepose_wps = []for wp in self.wps_dict["waypoints"]:latitude, longitude, yaw = wp["latitude"], wp["longitude"], wp["yaw"]gepose_wps.append(latLonYaw2Geopose(latitude, longitude, yaw))return gepose_wpsclass GpsWpCommander(Node):"""Class to use nav2 gps waypoint follower to follow a set of waypoints logged in a yaml file"""def __init__(self, wps_file_path):super().__init__('minimal_client_async')self.navigator = BasicNavigator("basic_navigator")self.wp_parser = YamlWaypointParser(wps_file_path)self.localizer = self.create_client(FromLL,  '/fromLL')while not self.localizer.wait_for_service(timeout_sec=1.0):self.get_logger().info('service not available, waiting again...')def start_wpf(self):"""Function to start the waypoint following"""self.navigator.waitUntilNav2Active(localizer='controller_server')wps = self.wp_parser.get_wps()wpl = []for wp in wps:self.req = FromLL.Request()self.req.ll_point.longitude = wp.position.longitudeself.req.ll_point.latitude = wp.position.latitudeself.req.ll_point.altitude = wp.position.altitudelog = 'long{:f}, lat={:f}, alt={:f}'.format(self.req.ll_point.longitude, self.req.ll_point.latitude, self.req.ll_point.altitude)self.get_logger().info(log)self.future = self.localizer.call_async(self.req)rclpy.spin_until_future_complete(self, self.future)self.resp = PoseStamped()self.resp.header.frame_id = 'map'self.resp.header.stamp = self.get_clock().now().to_msg()self.resp.pose.position = self.future.result().map_pointlog = 'x={:f}, y={:f}, z={:f}'.format(self.future.result().map_point.x, self.future.result().map_point.y, self.future.result().map_point.z)self.get_logger().info(log)self.resp.pose.orientation = wp.orientationwpl += [self.resp]self.navigator.followWaypoints(wpl)print("wps completed successfully")def main():rclpy.init()# allow to pass the waypoints file as an argumentdefault_yaml_file_path = os.path.join(get_package_share_directory("node"), "config", "demo_waypoints.yaml")if len(sys.argv) > 1:yaml_file_path = sys.argv[1]else:yaml_file_path = default_yaml_file_pathgps_wpf = GpsWpCommander(yaml_file_path)gps_wpf.start_wpf()if __name__ == "__main__":main()

第二步:除了上述代码需要修改,nav2_no_map_params.yaml也需要修改,该文件中bt_navigator节点下的内容改为nav2 humble里面默认的部分,另外,建议global_costmap中的width/height改大,例如从50改到500,不然容易出现超出global_costmap范围的提示。

参考链接(tks LuukBerkel ):nav2_gps_waypoint_follower_demo does not work on ros2 humble???! · Issue #77 · ros-planning/navigation2_tutorials · GitHub

相关文章:

nav2_gps_waypoint_follower_demo 不能在ros2 humble中直接使用的解决方法

GIT上的nav2_gps_waypoint_follower_demo是基于ros-iron编写的,其中followGpsWaypoints(wps) service只能在Iron上使用。 解决方法: 第一步:将interactive_waypoint_follower.py修改为如下代码: import rclpy from rclpy.node …...

华为OD机试 - 螺旋数字矩阵

1 题目描述 疫情期间&#xff0c;小明隔离在家&#xff0c;百无聊赖&#xff0c;在纸上写数字玩。他发明了一种写法&#xff1a; 给出数字个数 n &#xff08;0 < n ≤ 999&#xff09;和行数 m&#xff08;0 < m ≤ 999&#xff09;&#xff0c;从左上角的 1 开始&…...

Vue响应式内容丢失处理

对数组和对象进行不当的修改会使Vue的对象丢失响应式&#xff0c;这时可以直接console.log丢失的对象&#xff0c;看是否有getter和setter 对于数组和对象&#xff0c;只有使用 Vue 提供的一些方法&#xff08;如 push()、pop()、splice()、set() 等&#xff09;进行修改才会触…...

Linux安装Rabbitmq

说明&#xff1a;本文章主要是rabbitmq在Linux系统上的安装&#xff0c;文章中包含了rabbitmq的下载及依赖下载 1.版本选取&#xff0c;这里的选取主要是版本的兼容问题 去这个网址查看mq和erlang版本兼容&#xff1a;RabbitMQ Erlang Version Requirements | RabbitMQ 2.相…...

在nginx 服务器部署vue项目

以人人快速开发的开源项目&#xff1a;renren-fast-vue 为例 注&#xff1a;这里开始认为各位都会使用nginx 打包vue项目 npm run build 测试打包的项目是否可以运行 serve dist 可以正常运行 编译报错请移步到&#xff1a;renren-fast-vue1.2.2 项目编译报错: build g…...

制作一个简单的HTML个人网页

制作一个简单的HTML个人网页 1.1 硬件1.1.1 一台电脑1.1.2 配置要求 1.2 系统1.3 软件 二、制作一个简单的HTML个人网页1.创建一个HTML网页1.1 新建文本文档1.2 另存文本文档1.3 命名为index.html 2.编写HTML代码2.1 打开HTML2.2 复制HTML代码2.3 粘贴HTML代码2.4 保存HTML 3.预…...

HM2019创建载荷工况

该案例中将介绍载荷、工况、约束的创建 步骤一&#xff1a;首先创建两个载荷集(Load Collector)用来存放载荷和约束 步骤二&#xff1a;在Analysis面板下创建约束(Analysis→constraints) 注意&#xff1a;Load type选择SPC表示统计过程控制(Statistical Process Control) 步…...

Effective C++ 学习笔记 条款14 在资源管理类中小心copying行为

条款13导入这样的观念&#xff1a;“资源取得时机便是初始化时机”&#xff08;Resource Acquisition Is Initialization&#xff0c;RAII&#xff09;&#xff0c;并以此作为“资源管理类”的脊柱&#xff0c;也描述了auto_ptr和tr1::shared_ptr如何将这个观念表现在heap-base…...

c++数据结构算法复习基础-- 3 --线性表-单向链表-笔试面试常见问题

1、单链表逆序 思路图 代码实现 //著: 链表结构里记得加 friend void ReverseLink(Clink& link); void ReverseLink(Clink& link) {Node* p link.head_->next_;while( p nullptr){return;}Node* q p->next_;link.head_->next_ nullptr;while(p ! nullpt…...

【踩坑专栏】追根溯源,从Linux磁盘爆满排查故障:mycat2与navicat不兼容导致日志暴增

昨天遇到了一个比较奇怪的问题&#xff0c;就是在挂起虚拟机的时候&#xff0c;虚拟机提示我XX脚本正在运行&#xff0c;很奇怪&#xff0c;我没有运行脚本&#xff0c;为什么会提示我这个呢。今天恢复虚拟机&#xff0c;也提示了一下脚本的问题&#xff0c;而且发现Linux明显异…...

DolphinScheduler——奇富科技的调度实践

目录 一、技术架构 二、业务挑战 2.1 调度任务量大 2.2 运维复杂 2.3 SLA要求高 三、调度优化实践 3.1 重复调度 3.2 漏调度 3.3 Worker服务卡死 3.4 任务重复运行 四、服务监控 4.1 方法耗时监控 4.2 任务调度链路监控 五、用户收益 原文大佬的这篇调度系统案例…...

2024年最全洗地机选购攻略盘点丨希亦、小米、云鲸、海尔洗地机哪款值得入手?

在现代家居清洁中&#xff0c;洗地机是不可或缺的得力助手&#xff0c;它融合了吸尘、拖地等多种功能。面对市场上琳琅满目的洗地机品牌和型号&#xff0c;选择一个可靠的品牌至关重要。优质的品牌能够提供高品质的产品&#xff0c;使您的清洁工作更加轻松高效。本文将向您推荐…...

HTML笔记3

21&#xff0c;label标签 <label for"...">...</label> <label>...</label> <!DOCTYPE html> <html lang"en"> <head> <meta charset"UTF-8"> <meta name"viewport" content&qu…...

利用Python副业赚钱,看完这篇你就懂了!

Python都可以做哪些副业&#xff1f; 1、兼职处理数据Excel整理数据功能虽然很强大&#xff0c;但在Python面前&#xff0c;曾经统治职场的它也的败下阵来。因为Python在搜集数据整理分析数据的过程中更加便捷&#xff0c;通过几行代码还可以实现自动化操作。 如果你学会Pyth…...

FP16(半精度浮点数)、FP32(单精度浮点数)和INT8

在深度学习和计算机视觉领域中&#xff0c;FP16&#xff08;半精度浮点数&#xff09;、FP32&#xff08;单精度浮点数&#xff09;和INT8&#xff08;8 位整数&#xff09;是常见的数据类型或精度表示方式。它们在不同的场景下有各自的优势和用途。 FP16&#xff08;半精度浮…...

MySQL数据管理二

1.数据库的完整性 数据库中的数据是从外界输入的&#xff0c;而数据的输入由于种种原因&#xff0c;会发生输入无效或错误信息。保证输入的数据符合规定&#xff0c;成为了数据库系统&#xff0c;尤其是多用户的关系数据库系统首要关注的问题。 它是应防止数据库中存在不符合语…...

sqoop-import 详解

文章目录 前言一、介绍1. sqoop简介2. sqoop import的作用3. 语法3.1 sqoop import 语法3.2 导入配置属性 二、导入参数1. 常见参数2. 验证参数3. 导入控制参数4. 用于覆盖映射的参数5. 增量导入参数6. 输出行格式参数7. 输入解析参数8. Hive 参数9. HBase 参数10. Accumulo 参…...

第二周opencv

一、边缘检测算子 边缘检测算子是用于检测图像中物体边界的工具。边缘通常表示图像中灰度值或颜色发生显著变化的地方。边缘检测有助于识别图像中的物体形状、轮廓和结构。这些算子通过分析图像的灰度或颜色梯度来确定图像中的边缘。 梯度算子 要得到一幅图像的梯度&#xff0c…...

python_读取txt文件绘制多条曲线II

从给定的列表中来匹配txt文件对应列的数据&#xff1b; import matplotlib.pyplot as plt import re from datetime import datetime from pylab import mplmpl.rcParams["font.sans-serif"] ["SimHei"] # 设置显示中文字体 mpl.rcParams["axes.un…...

java排序简单总结和推荐使用套路(数据排序,结构体排序)

了解int和Integer的区别 int是Java的基本数据类型&#xff0c;用于表示整数值。Integer是int的包装类&#xff0c;它是一个对象&#xff0c;可以包含一个int值并提供一些额外的功能。 Java集合框架中的集合类&#xff08;如List、Set、Map&#xff09;只能存储对象&#xff0c;…...

【大模型RAG】拍照搜题技术架构速览:三层管道、两级检索、兜底大模型

摘要 拍照搜题系统采用“三层管道&#xff08;多模态 OCR → 语义检索 → 答案渲染&#xff09;、两级检索&#xff08;倒排 BM25 向量 HNSW&#xff09;并以大语言模型兜底”的整体框架&#xff1a; 多模态 OCR 层 将题目图片经过超分、去噪、倾斜校正后&#xff0c;分别用…...

Golang 面试经典题:map 的 key 可以是什么类型?哪些不可以?

Golang 面试经典题&#xff1a;map 的 key 可以是什么类型&#xff1f;哪些不可以&#xff1f; 在 Golang 的面试中&#xff0c;map 类型的使用是一个常见的考点&#xff0c;其中对 key 类型的合法性 是一道常被提及的基础却很容易被忽视的问题。本文将带你深入理解 Golang 中…...

在rocky linux 9.5上在线安装 docker

前面是指南&#xff0c;后面是日志 sudo dnf config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo sudo dnf install docker-ce docker-ce-cli containerd.io -y docker version sudo systemctl start docker sudo systemctl status docker …...

Day131 | 灵神 | 回溯算法 | 子集型 子集

Day131 | 灵神 | 回溯算法 | 子集型 子集 78.子集 78. 子集 - 力扣&#xff08;LeetCode&#xff09; 思路&#xff1a; 笔者写过很多次这道题了&#xff0c;不想写题解了&#xff0c;大家看灵神讲解吧 回溯算法套路①子集型回溯【基础算法精讲 14】_哔哩哔哩_bilibili 完…...

Swift 协议扩展精进之路:解决 CoreData 托管实体子类的类型不匹配问题(下)

概述 在 Swift 开发语言中&#xff0c;各位秃头小码农们可以充分利用语法本身所带来的便利去劈荆斩棘。我们还可以恣意利用泛型、协议关联类型和协议扩展来进一步简化和优化我们复杂的代码需求。 不过&#xff0c;在涉及到多个子类派生于基类进行多态模拟的场景下&#xff0c;…...

在 Nginx Stream 层“改写”MQTT ngx_stream_mqtt_filter_module

1、为什么要修改 CONNECT 报文&#xff1f; 多租户隔离&#xff1a;自动为接入设备追加租户前缀&#xff0c;后端按 ClientID 拆分队列。零代码鉴权&#xff1a;将入站用户名替换为 OAuth Access-Token&#xff0c;后端 Broker 统一校验。灰度发布&#xff1a;根据 IP/地理位写…...

第25节 Node.js 断言测试

Node.js的assert模块主要用于编写程序的单元测试时使用&#xff0c;通过断言可以提早发现和排查出错误。 稳定性: 5 - 锁定 这个模块可用于应用的单元测试&#xff0c;通过 require(assert) 可以使用这个模块。 assert.fail(actual, expected, message, operator) 使用参数…...

涂鸦T5AI手搓语音、emoji、otto机器人从入门到实战

“&#x1f916;手搓TuyaAI语音指令 &#x1f60d;秒变表情包大师&#xff0c;让萌系Otto机器人&#x1f525;玩出智能新花样&#xff01;开整&#xff01;” &#x1f916; Otto机器人 → 直接点明主体 手搓TuyaAI语音 → 强调 自主编程/自定义 语音控制&#xff08;TuyaAI…...

windows系统MySQL安装文档

概览&#xff1a;本文讨论了MySQL的安装、使用过程中涉及的解压、配置、初始化、注册服务、启动、修改密码、登录、退出以及卸载等相关内容&#xff0c;为学习者提供全面的操作指导。关键要点包括&#xff1a; 解压 &#xff1a;下载完成后解压压缩包&#xff0c;得到MySQL 8.…...

Ubuntu系统多网卡多相机IP设置方法

目录 1、硬件情况 2、如何设置网卡和相机IP 2.1 万兆网卡连接交换机&#xff0c;交换机再连相机 2.1.1 网卡设置 2.1.2 相机设置 2.3 万兆网卡直连相机 1、硬件情况 2个网卡n个相机 电脑系统信息&#xff0c;系统版本&#xff1a;Ubuntu22.04.5 LTS&#xff1b;内核版本…...