diff --git a/minco_ws/src/scan/plan_manage/scripts/reference_path_publisher.py b/minco_ws/src/scan/plan_manage/scripts/reference_path_publisher.py index 7f19568..68716d8 100755 --- a/minco_ws/src/scan/plan_manage/scripts/reference_path_publisher.py +++ b/minco_ws/src/scan/plan_manage/scripts/reference_path_publisher.py @@ -46,10 +46,17 @@ class ReferencePathPublisher(Node): self.declare_parameter("frame_id", "world") self.declare_parameter("waypoints", Parameter.Type.DOUBLE_ARRAY) self.declare_parameter("publish_delay_sec", 0.5) + # 实车链路上里程计的话题名是 /body_odom(body_odom 节点输出)。 + # "body_pose" 只是 run_vehicle.launch.py 里给 scan_planner_node 做的**内部 remap**, + # 总线上并不存在;本脚本单独 ros2 run 时拿不到那层 remap,用 body_pose 会永远等不到数据。 + self.declare_parameter("odom_topic", "/body_odom") + self.declare_parameter("path_topic", "initial_path") self.frame_id = self.get_parameter("frame_id").value self.waypoints = parse_waypoints(self.get_parameter("waypoints").value) self.publish_delay_sec = float(self.get_parameter("publish_delay_sec").value) + self.odom_topic = self.get_parameter("odom_topic").value + self.path_topic = self.get_parameter("path_topic").value if not self.frame_id: raise ValueError("frame_id must not be empty") if not math.isfinite(self.publish_delay_sec) or self.publish_delay_sec < 0.0: @@ -60,9 +67,9 @@ class ReferencePathPublisher(Node): reliability=ReliabilityPolicy.RELIABLE, durability=DurabilityPolicy.TRANSIENT_LOCAL, ) - self.path_publisher = self.create_publisher(Path, "initial_path", path_qos) + self.path_publisher = self.create_publisher(Path, self.path_topic, path_qos) self.odom_subscription = self.create_subscription( - Odometry, "body_pose", self.odom_callback, qos_profile_sensor_data + Odometry, self.odom_topic, self.odom_callback, qos_profile_sensor_data ) self.first_odom_time = None self.published = False @@ -76,9 +83,20 @@ class ReferencePathPublisher(Node): self.first_odom_time = self.get_clock().now() def try_publish(self): - if self.published or self.first_odom_time is None: + if self.published: + return + if self.first_odom_time is None: + self.get_logger().warn( + f"等待 {self.odom_topic} 的里程计……若该话题无发布者," + f"检查 body_odom 是否启动(实车应为 /body_odom,不是 body_pose)", + throttle_duration_sec=3.0, + ) return if self.path_publisher.get_subscription_count() == 0: + self.get_logger().warn( + f"{self.path_topic} 暂无订阅者——FSM 需以 navi_mode:=3 启动才会订阅参考路径", + throttle_duration_sec=3.0, + ) return elapsed = (self.get_clock().now() - self.first_odom_time).nanoseconds / 1e9 if elapsed < self.publish_delay_sec: