feat(sim): integrate Gazebo Classic with Point-LIO and SCAN navigation
Import the complete field and a simplified omnidirectional robot in sim_ws. Reuse original Point-LIO, SCAN and controller implementations with isolated simulation profiles, timed MID360/IMU data, readiness and command guards. Support known-corridor terrain paths, optional sensor stress profiles and separate physics/algorithm launch processes. Remove retired Fortress resources and operating instructions; add build, usage, scope and durable validation documentation. Validation: full build script; 8 adapter tests and 4 SCAN CTest targets; 8 continuous mild-noise routes; red/blue terrain 4 cases each; noise 9/9; visibility characterization 9/9; default sensors 16/16; loss-stop and post-build straight navigation. Real wheels/network remain unverified.
This commit is contained in:
+2
-1
@@ -1,9 +1,10 @@
|
||||
# =====================================================================
|
||||
# RoboCon 2027 · BR 机器人代码仓库 —— 根目录 .gitignore
|
||||
# 现仓库保留三个平级工作区(各自独立构建,不共享包、不共享参数文件):
|
||||
# 三个算法工作区独立构建;sim_ws 在独立前缀复用 minco_ws 的原算法:
|
||||
# minco_ws/ —— 方案 A/B:MID360 + Point-LIO + SCAN/MINCO(20 个包)
|
||||
# sru_ws/ —— 方案 C:Odin1 + 深度 RL 导航(3 个包)
|
||||
# nav2_ws/ —— 方案 D:先验地图 + Nav2 + 动作原语 + 行为树(8 个包)
|
||||
# sim_ws/ —— Gazebo Classic:完整场地、简化全向车、MID360/IMU、SCAN 联调
|
||||
# 规则:只收录「构建产物 / 运行期数据 / 本地环境 / 私人工具状态」,
|
||||
# 源码、配置、文档、模型一律保留。
|
||||
# =====================================================================
|
||||
|
||||
@@ -18,6 +18,25 @@ RoboCon 2027 赛季 BR 机器人的上位机代码。仓库里有**四套**定
|
||||
> **四套互斥**:都占用 `/cmd_vel` 与传感器,同一时间只能启动一套。
|
||||
> 下位机固件(STM32 底盘控制)不在本仓库,速度指令经串口下发。
|
||||
|
||||
## Gazebo 仿真
|
||||
|
||||
[`sim_ws/README.md`](sim_ws/README.md) 提供 **Ubuntu 22.04 + ROS 2 Humble + Gazebo Classic 11** 的完整场地仿真。
|
||||
复用方案 A 的原 Point-LIO、SCAN 和闭环控制器,支持全向横移;不是新增一套导航算法。
|
||||
已有真值导航、MID360/IMU 估计导航和两侧指定坡道入口,含仿真时间、失效停车与独立物理验收。
|
||||
|
||||
```bash
|
||||
# 仓库根目录,首次构建;不安装真实雷达 SDK
|
||||
bash sim_ws/tools/build_sim.sh
|
||||
source /opt/ros/humble/setup.bash
|
||||
source sim_ws/install/classic/setup.bash
|
||||
export ROS_DOMAIN_ID=77 ROS_LOCALHOST_ONLY=1
|
||||
export GAZEBO_MASTER_URI=http://127.0.0.1:11355
|
||||
ros2 launch br_sim_bringup scan_lio.launch.py
|
||||
```
|
||||
|
||||
目标下发、噪声配置、两机拆分方式及已验收/未验收边界见仿真 README。
|
||||
真值仅用于独立评分;估计导航使用固定已知起点先验。仿真不要与实车串口控制同时运行。
|
||||
|
||||
## 按目的找文档
|
||||
|
||||
| 我想… | 去哪 |
|
||||
@@ -29,6 +48,7 @@ RoboCon 2027 赛季 BR 机器人的上位机代码。仓库里有**四套**定
|
||||
| 用只读脚本分析录包(不改状态、可离线复算) | [`docs/diagnostics/`](minco_ws/docs/diagnostics) |
|
||||
| 跑方案 C,或看它的评估现状 | [`sru_ws/docs/USAGE.md`](sru_ws/docs/USAGE.md)、[`SOLUTION_C_ASSESSMENT.md`](sru_ws/docs/SOLUTION_C_ASSESSMENT.md) |
|
||||
| 跑方案 D(建图 / 定位导航 / 行为树) | [`nav2_ws/README.md`](nav2_ws/README.md) |
|
||||
| 在笔记本测试原导航程序 | [`sim_ws/README.md`](sim_ws/README.md) |
|
||||
| 知道哪些东西不入库 | [`.gitignore`](.gitignore) |
|
||||
|
||||
## 各工作区自带 README
|
||||
@@ -38,10 +58,11 @@ RoboCon 2027 赛季 BR 机器人的上位机代码。仓库里有**四套**定
|
||||
- [`minco_ws/docs/README.md`](minco_ws/docs/README.md) —— 20 个包,两套互斥子方案
|
||||
- [`sru_ws/docs/README.md`](sru_ws/docs/README.md) —— 3 个包,端到端策略
|
||||
- [`nav2_ws/README.md`](nav2_ws/README.md) —— 8 个包,先验地图导航
|
||||
- [`sim_ws/README.md`](sim_ws/README.md) —— 3 个仿真包,复用方案 A,算法包不依赖 Gazebo
|
||||
|
||||
## 环境与约定
|
||||
|
||||
- Ubuntu 22.04 + **ROS 2 Humble** + Python 3.10(系统默认的 3.13 不能 `import rclpy`)
|
||||
- Ubuntu 22.04 + **ROS 2 Humble** + Python 3.10(使用 `/usr/bin/python3`,避免 PATH 中其他 Python 前缀覆盖)
|
||||
- 构建产物、运行数据、脚本产物都不入库;模型(两个 ONNX,合计约 27 MB)随仓库分发,
|
||||
若显著变大建议改用 Git LFS
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ find_package(geometry_msgs REQUIRED)
|
||||
find_package(nav_msgs REQUIRED)
|
||||
find_package(sensor_msgs REQUIRED)
|
||||
find_package(visualization_msgs REQUIRED)
|
||||
find_package(pcl_ros REQUIRED)
|
||||
find_package(PCL REQUIRED COMPONENTS common filters io)
|
||||
find_package(pcl_conversions REQUIRED)
|
||||
find_package(tf2_ros REQUIRED)
|
||||
find_package(livox_ros_driver2 REQUIRED)
|
||||
@@ -108,13 +108,12 @@ ament_target_dependencies(point_lio_component
|
||||
nav_msgs
|
||||
sensor_msgs
|
||||
visualization_msgs
|
||||
pcl_ros
|
||||
pcl_conversions
|
||||
tf2_ros
|
||||
livox_ros_driver2
|
||||
)
|
||||
|
||||
target_link_libraries(point_lio_component ${PCL_LIBRARIES} ${PYTHON_LIBRARIES})
|
||||
target_link_libraries(point_lio_component ${PCL_LIBRARIES} ${PYTHON_LIBRARIES} glog::glog)
|
||||
target_include_directories(point_lio_component PRIVATE ${PYTHON_INCLUDE_DIRS})
|
||||
rclcpp_components_register_nodes(point_lio_component "point_lio::LaserMappingNode")
|
||||
|
||||
@@ -133,13 +132,12 @@ ament_target_dependencies(pointlio_mapping
|
||||
nav_msgs
|
||||
sensor_msgs
|
||||
visualization_msgs
|
||||
pcl_ros
|
||||
pcl_conversions
|
||||
tf2_ros
|
||||
livox_ros_driver2
|
||||
)
|
||||
|
||||
target_link_libraries(pointlio_mapping ${PCL_LIBRARIES} ${PYTHON_LIBRARIES})
|
||||
target_link_libraries(pointlio_mapping ${PCL_LIBRARIES} ${PYTHON_LIBRARIES} glog::glog)
|
||||
target_include_directories(pointlio_mapping PRIVATE ${PYTHON_INCLUDE_DIRS})
|
||||
|
||||
# Install the executable
|
||||
@@ -165,7 +163,6 @@ ament_export_dependencies(
|
||||
geometry_msgs
|
||||
nav_msgs
|
||||
sensor_msgs
|
||||
pcl_ros
|
||||
pcl_conversions
|
||||
tf2_ros
|
||||
livox_ros_driver2
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
<depend>visualization_msgs</depend>
|
||||
<depend>nav_msgs</depend>
|
||||
<depend>tf2_ros</depend>
|
||||
<depend>pcl_ros</depend>
|
||||
<depend>libpcl-all-dev</depend>
|
||||
<depend>pcl_conversions</depend>
|
||||
<depend>livox_ros_driver2</depend>
|
||||
<depend>libunwind-dev</depend>
|
||||
|
||||
@@ -3,6 +3,23 @@
|
||||
cmake_minimum_required(VERSION 3.14)
|
||||
project(livox_ros_driver2)
|
||||
|
||||
# Simulation/offline consumers need the original wire types, not a hardware SDK.
|
||||
# Keep the hardware build as the default and reuse the same .msg sources.
|
||||
option(LIVOX_INTERFACES_ONLY "Build Livox messages without the device driver" OFF)
|
||||
if(LIVOX_INTERFACES_ONLY)
|
||||
find_package(ament_cmake REQUIRED)
|
||||
find_package(rosidl_default_generators REQUIRED)
|
||||
find_package(std_msgs REQUIRED)
|
||||
find_package(builtin_interfaces REQUIRED)
|
||||
rosidl_generate_interfaces(${PROJECT_NAME}
|
||||
"msg/CustomPoint.msg"
|
||||
"msg/CustomMsg.msg"
|
||||
DEPENDENCIES builtin_interfaces std_msgs)
|
||||
ament_export_dependencies(rosidl_default_runtime)
|
||||
ament_package()
|
||||
return()
|
||||
endif()
|
||||
|
||||
# Default to C99
|
||||
if(NOT CMAKE_C_STANDARD)
|
||||
set(CMAKE_C_STANDARD 99)
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
<license>MIT</license>
|
||||
|
||||
<buildtool_depend>ament_cmake_auto</buildtool_depend>
|
||||
<buildtool_depend>ament_cmake</buildtool_depend>
|
||||
<depend>builtin_interfaces</depend>
|
||||
<build_depend>rosidl_default_generators</build_depend>
|
||||
<member_of_group>rosidl_interface_packages</member_of_group>
|
||||
|
||||
|
||||
@@ -64,6 +64,9 @@ if(BUILD_TESTING)
|
||||
find_package(ament_cmake_pytest REQUIRED)
|
||||
find_package(launch_testing_ament_cmake REQUIRED)
|
||||
ament_add_gtest(test_rectangle_footprint test/test_rectangle_footprint.cpp)
|
||||
ament_add_gtest(test_terrain_velocity test/test_terrain_velocity.cpp)
|
||||
target_include_directories(test_terrain_velocity PRIVATE include)
|
||||
target_link_libraries(test_terrain_velocity Eigen3::Eigen)
|
||||
ament_target_dependencies(test_rectangle_footprint plan_env rclcpp)
|
||||
ament_add_gtest(test_goal_execution_utils test/test_goal_execution_utils.cpp)
|
||||
target_include_directories(test_goal_execution_utils PRIVATE include)
|
||||
|
||||
@@ -43,6 +43,7 @@ namespace scan_planner
|
||||
|
||||
private:
|
||||
rclcpp::Node *node_{nullptr};
|
||||
double min_replan_distance_{0.2};
|
||||
/* main planning algorithms & modules */
|
||||
PlanningVisualization::Ptr visualization_;
|
||||
|
||||
|
||||
@@ -90,6 +90,7 @@ namespace scan_planner
|
||||
double goal_tolerance_{0.08}, blocked_timeout_{10.0}, blocked_retry_period_{0.5};
|
||||
bool require_perception_ready_{false}, perception_ready_{false};
|
||||
bool require_controller_feedback_{false};
|
||||
bool terrain_motion_{false};
|
||||
bool last_trajectory_final_{false};
|
||||
bool target_yaw_valid_{false};
|
||||
double target_yaw_{0.0};
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
#pragma once
|
||||
|
||||
#include <cmath>
|
||||
#include <Eigen/Eigen>
|
||||
|
||||
namespace scan_planner
|
||||
{
|
||||
// Odometry twist is expressed in child_frame_id, including on a slope.
|
||||
inline Eigen::Vector3d terrainBodyVelocityToWorld(
|
||||
const Eigen::Quaterniond &body_orientation, const Eigen::Vector3d &body_velocity)
|
||||
{
|
||||
return body_orientation.normalized() * body_velocity;
|
||||
}
|
||||
|
||||
// A surface vehicle actuates body X/Y. Invert their horizontal projection,
|
||||
// instead of pretending a pitched body X axis is a horizontal unit vector.
|
||||
inline bool terrainWorldXYToBodyXY(const Eigen::Quaterniond &body_orientation,
|
||||
const Eigen::Vector2d &world_xy,
|
||||
Eigen::Vector2d &body_xy)
|
||||
{
|
||||
if (!body_orientation.coeffs().allFinite() || body_orientation.norm() < 1e-6 ||
|
||||
!world_xy.allFinite()) return false;
|
||||
const Eigen::Matrix2d horizontal = body_orientation.normalized().toRotationMatrix().topLeftCorner<2,2>();
|
||||
if (horizontal.determinant() < 0.5) return false; // Tipped or nearly singular.
|
||||
body_xy = horizontal.inverse() * world_xy;
|
||||
return body_xy.allFinite();
|
||||
}
|
||||
} // namespace scan_planner
|
||||
@@ -17,6 +17,7 @@
|
||||
#include <tf2/utils.hpp>
|
||||
|
||||
#include "bspline_opt/uniform_bspline.h"
|
||||
#include "plan_manage/terrain_velocity_utils.h"
|
||||
|
||||
namespace scan_planner
|
||||
{
|
||||
@@ -63,6 +64,9 @@ public:
|
||||
require_trajectory_status_ = declare_parameter<bool>("require_trajectory_status", false);
|
||||
require_perception_ready_ = declare_parameter<bool>("require_perception_ready", false);
|
||||
require_locked_heading_ = declare_parameter<bool>("require_locked_heading", false);
|
||||
terrain_motion_ = declare_parameter<bool>("terrain_motion", false);
|
||||
if (terrain_motion_ && !require_locked_heading_)
|
||||
throw std::runtime_error("Terrain motion requires locked-heading safety grants");
|
||||
|
||||
bspline_sub_ = create_subscription<scan_planner_msgs::msg::Bspline>(
|
||||
"planning/bspline", 10,
|
||||
@@ -207,6 +211,12 @@ private:
|
||||
const double bvx = msg->twist.twist.linear.x;
|
||||
const double bvy = msg->twist.twist.linear.y;
|
||||
odom_vel_world_ << c * bvx - s * bvy, s * bvx + c * bvy;
|
||||
if (terrain_motion_) {
|
||||
const auto &q = msg->pose.pose.orientation;
|
||||
odom_orientation_ = Eigen::Quaterniond(q.w,q.x,q.y,q.z).normalized();
|
||||
odom_vel_world_ = terrainBodyVelocityToWorld(odom_orientation_, Eigen::Vector3d(
|
||||
bvx, bvy, msg->twist.twist.linear.z)).head<2>();
|
||||
}
|
||||
odom_update_ = now();
|
||||
have_odom_ = true;
|
||||
}
|
||||
@@ -330,6 +340,16 @@ private:
|
||||
geometry_msgs::msg::Twist command;
|
||||
command.linear.x = std::clamp(c * vel_world.x() + s * vel_world.y(), -max_vx_, max_vx_);
|
||||
command.linear.y = std::clamp(-s * vel_world.x() + c * vel_world.y(), -max_vy_, max_vy_);
|
||||
if (terrain_motion_) {
|
||||
Eigen::Vector2d body_command;
|
||||
if (!terrainWorldXYToBodyXY(odom_orientation_, vel_world, body_command)) {
|
||||
publishExecutionFrozen(true);
|
||||
publishStop();
|
||||
return;
|
||||
}
|
||||
command.linear.x = std::clamp(body_command.x(), -max_vx_, max_vx_);
|
||||
command.linear.y = std::clamp(body_command.y(), -max_vy_, max_vy_);
|
||||
}
|
||||
command.angular.z = yaw_command;
|
||||
// 到达判定用**到轨迹终点的距离**(上面已算),而不是"到当前参考点的距离 + 时间走完"。
|
||||
//
|
||||
@@ -398,6 +418,8 @@ private:
|
||||
rclcpp::Subscription<geometry_msgs::msg::PoseStamped>::SharedPtr goal_sub_;
|
||||
rclcpp::TimerBase::SharedPtr cmd_timer_;
|
||||
bool require_locked_heading_{false};
|
||||
bool terrain_motion_{false};
|
||||
Eigen::Quaterniond odom_orientation_{Eigen::Quaterniond::Identity()};
|
||||
rclcpp::Time odom_update_{0, 0, RCL_ROS_TIME};
|
||||
bool receive_traj_{false};
|
||||
bool have_odom_{false};
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
#include <plan_manage/polyline_trajectory_utils.h>
|
||||
#include <chrono>
|
||||
#include <thread>
|
||||
#include <cmath>
|
||||
#include <stdexcept>
|
||||
|
||||
namespace scan_planner
|
||||
{
|
||||
@@ -62,6 +64,9 @@ namespace scan_planner
|
||||
pp_.feasibility_tolerance_ = get_double("manager.feasibility_tolerance", 0.0);
|
||||
pp_.ctrl_pt_dist = get_double("manager.control_points_distance", -1.0);
|
||||
pp_.planning_horizon_ = get_double("manager.planning_horizon", 5.0);
|
||||
min_replan_distance_ = get_double("manager.min_replan_distance", 0.2);
|
||||
if (!std::isfinite(min_replan_distance_) || min_replan_distance_ <= 0)
|
||||
throw std::invalid_argument("manager.min_replan_distance must be finite and positive");
|
||||
|
||||
local_data_.traj_id_ = 0;
|
||||
grid_map_.reset(new GridMap);
|
||||
@@ -92,7 +97,7 @@ namespace scan_planner
|
||||
cout << "start: " << start_pt.transpose() << ", " << start_vel.transpose() << "\ngoal:" << local_target_pt.transpose() << ", " << local_target_vel.transpose()
|
||||
<< endl;
|
||||
|
||||
if ((start_pt - local_target_pt).norm() < 0.2)
|
||||
if ((start_pt - local_target_pt).norm() < min_replan_distance_)
|
||||
{
|
||||
cout << "Close to goal" << endl;
|
||||
continuous_failures_count_++;
|
||||
|
||||
@@ -49,6 +49,7 @@ namespace scan_planner
|
||||
blocked_retry_period_ = load_parameter<double>(node_, "fsm.blocked_retry_period", 0.5);
|
||||
require_perception_ready_ = load_parameter<bool>(node_, "fsm.require_perception_ready", false);
|
||||
require_controller_feedback_ = load_parameter<bool>(node_, "fsm.require_controller_feedback", false);
|
||||
terrain_motion_ = load_parameter<bool>(node_, "fsm.terrain_motion", false);
|
||||
if (goal_tolerance_ <= 0 || blocked_timeout_ <= 0 || blocked_retry_period_ <= 0)
|
||||
throw std::runtime_error("goal tolerance and blocked retry/timeout must be positive");
|
||||
self_inflation_z_up_ = load_parameter<double>(node_, "grid_map.obstacles_inflation_z_up", 0.0);
|
||||
@@ -81,8 +82,10 @@ namespace scan_planner
|
||||
planner_manager_.reset(new SCANPlannerManager);
|
||||
planner_manager_->initPlanModules(node_, visualization_);
|
||||
if (planner_manager_->grid_map_->usesRectangleFootprint() &&
|
||||
(navi_mode_ != NAVI_MODE::MANUAL_TARGET || !require_controller_feedback_ || !require_perception_ready_))
|
||||
throw std::runtime_error("Rectangle mode requires manual goals, controller feedback and perception readiness");
|
||||
((navi_mode_ != NAVI_MODE::MANUAL_TARGET &&
|
||||
!(terrain_motion_ && navi_mode_ == NAVI_MODE::REFERENCE_PATH)) ||
|
||||
!require_controller_feedback_ || !require_perception_ready_))
|
||||
throw std::runtime_error("Rectangle mode requires manual goals (or explicit terrain reference paths), controller feedback and perception readiness");
|
||||
|
||||
/* callback */
|
||||
exec_timer_ = node_->create_wall_timer(std::chrono::milliseconds(10),
|
||||
@@ -519,6 +522,11 @@ namespace scan_planner
|
||||
const double vx = odom_vel_.x(), vy = odom_vel_.y();
|
||||
odom_vel_.x() = std::cos(yaw)*vx - std::sin(yaw)*vy;
|
||||
odom_vel_.y() = std::sin(yaw)*vx + std::cos(yaw)*vy;
|
||||
if (terrain_motion_) {
|
||||
// Preserve the vertical velocity and pitched body-axis projection.
|
||||
odom_vel_ = odom_orient_ * Eigen::Vector3d(
|
||||
msg->twist.twist.linear.x, msg->twist.twist.linear.y, msg->twist.twist.linear.z);
|
||||
}
|
||||
if (!have_odom_) {
|
||||
planner_manager_->grid_map_->setFootprintHeading(getOdomYaw());
|
||||
publishTrajectoryStatus(scan_planner_msgs::msg::TrajectoryStatus::HOLD, "waiting_for_target");
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
#include <gtest/gtest.h>
|
||||
#include <plan_manage/terrain_velocity_utils.h>
|
||||
|
||||
using namespace scan_planner;
|
||||
|
||||
TEST(TerrainVelocity, PreservesFullOdometryRotation)
|
||||
{
|
||||
const Eigen::Quaterniond q(Eigen::AngleAxisd(0.4,Eigen::Vector3d::UnitZ()) *
|
||||
Eigen::AngleAxisd(0.17,Eigen::Vector3d::UnitY()) *
|
||||
Eigen::AngleAxisd(-0.06,Eigen::Vector3d::UnitX()));
|
||||
const Eigen::Vector3d body(0.3,-0.1,0.02);
|
||||
const auto world = terrainBodyVelocityToWorld(q,body);
|
||||
EXPECT_NEAR((q.inverse()*world-body).norm(),0,1e-12);
|
||||
EXPECT_GT(std::abs(world.z()-body.z()),0.02);
|
||||
}
|
||||
|
||||
TEST(TerrainVelocity, HorizontalCommandSurvivesPitchAndYaw)
|
||||
{
|
||||
const Eigen::Quaterniond q(Eigen::AngleAxisd(1.2,Eigen::Vector3d::UnitZ()) *
|
||||
Eigen::AngleAxisd(0.17,Eigen::Vector3d::UnitY()));
|
||||
const Eigen::Vector2d wanted(0.2,-0.1);
|
||||
Eigen::Vector2d command;
|
||||
ASSERT_TRUE(terrainWorldXYToBodyXY(q,wanted,command));
|
||||
const Eigen::Vector3d result=q*Eigen::Vector3d(command.x(),command.y(),0);
|
||||
EXPECT_LT((result.head<2>()-wanted).norm(),1e-12);
|
||||
}
|
||||
|
||||
TEST(TerrainVelocity, RejectsTippingAndInvalidQuaternions)
|
||||
{
|
||||
Eigen::Vector2d command;
|
||||
EXPECT_FALSE(terrainWorldXYToBodyXY(Eigen::Quaterniond(0,0,0,0),{0.2,0},command));
|
||||
EXPECT_FALSE(terrainWorldXYToBodyXY(Eigen::Quaterniond(
|
||||
Eigen::AngleAxisd(1.4,Eigen::Vector3d::UnitY())),{0.2,0},command));
|
||||
}
|
||||
@@ -0,0 +1,149 @@
|
||||
# RC2027 Gazebo Classic 仿真
|
||||
|
||||
当前使用 Ubuntu 22.04、ROS 2 Humble、Gazebo Classic 11.10.2。
|
||||
完整场地以 `src/robocon_gazebo` 为准,复用仓库现有 SCAN 规划器和闭环控制器。
|
||||
Gazebo、导航与可选 RViz 均可在笔记本运行;双机预备入口另见下文。
|
||||
|
||||
```mermaid
|
||||
flowchart LR
|
||||
G[Gazebo 物理] --> S[MID360 与 IMU]
|
||||
S --> L[原 Point-LIO]
|
||||
L --> A[坐标与参考点适配]
|
||||
A --> P[原 SCAN 与闭环控制]
|
||||
P --> W[命令保护]
|
||||
W --> G
|
||||
G -. 独立真值评分 .-> T[验收工具]
|
||||
```
|
||||
|
||||
## 当前状态
|
||||
|
||||
- P1 场地:完整地图已导入;8 个接触抽样跨轮次通过。
|
||||
- P2 底盘:Codex 全量复测 9/9 通过,包含前进、横移、转向、停止、里程计与 TF。
|
||||
- P3 雷达:两个朝向下的三维点云坐标检查通过。
|
||||
- P4 导航:直达、横移、到点转向、绕障 4/4 通过;数据中断后 0.24 s 内停车。
|
||||
- P5 子阶段:1.20 m 通道两朝向通过;0.95 m 通道及所测台阶/坡道入口目标按预期拒绝,5/5 通过。
|
||||
- P5 坡道:红、蓝侧上坡/下坡四条路线通过,两侧已知台阶禁行通过;独立入口使用接触驱动与参考路径。
|
||||
- P6 定位:MID360 兼容近似扫描与物理 IMU 已接入原 Point-LIO;平地、上下坡独立真值对照通过。
|
||||
- P6 平地闭环:新增 `scan_lio.launch.py`,MID360 → 原 Point-LIO → SCAN → 闭环控制,四条路线通过。
|
||||
原真值入口保留;真实噪声、真实轮组和双机联调尚未验收。
|
||||
- P6 指定坡道:LIO 红、蓝侧上下坡 4/4、两侧台阶拒绝、坡上箱体拒绝通过;下游断流后 0.41 s 停车并恢复任务。
|
||||
- 收尾验收:轻度噪声下同一定位/地图连续八段导航通过;红侧带噪声、蓝侧理想模式各四项坡道用例通过,包含台阶与坡边目标拒绝。
|
||||
噪声注入九项、低障碍视场九组测量和默认传感器十六项回归通过。详见最终验收摘要。
|
||||
|
||||
## 启动
|
||||
|
||||
工作目录为仓库根目录。本机已具备 Ubuntu 22.04 / ROS 2 Humble、Gazebo Classic 11、
|
||||
`gazebo_ros_pkgs`、xacro、PCL/pcl_conversions、Eigen、glog、colcon、系统 Python 3.10 与 numpy/yaml。
|
||||
构建脚本只构建源码,不安装系统依赖,不安装真实雷达 SDK。首次运行
|
||||
`bash sim_ws/tools/build_sim.sh`,默认两路编译,可用 `BR_SIM_BUILD_JOBS` 调整。
|
||||
推荐估计导航入口:
|
||||
|
||||
```bash
|
||||
source /opt/ros/humble/setup.bash
|
||||
source sim_ws/install/classic/setup.bash
|
||||
export ROS_DOMAIN_ID=77 ROS_LOCALHOST_ONLY=1
|
||||
export GAZEBO_MASTER_URI=http://127.0.0.1:11355
|
||||
ros2 launch br_sim_bringup scan_lio.launch.py
|
||||
```
|
||||
|
||||
`gui:=false` 可无界面运行。与实车节点、其他仿真互斥运行;一个入口只起一个 server。
|
||||
另开终端时,重复 source 和上述环境设置。
|
||||
目标下发、RViz 配置、从源码构建与验收命令见 [导航说明](docs/P3_P4_NAVIGATION.md)。
|
||||
推荐入口使用 MID360/IMU 与原 Point-LIO,只接受固定已知起点先验;等待感知就绪后发目标。
|
||||
另一终端重复上面的 source/export,观察 `ros2 topic echo /planning/perception_ready` 输出为 `data: true`,
|
||||
再发默认起点附近已验收的直达目标:
|
||||
|
||||
```bash
|
||||
ros2 topic pub --once /move_base_simple/goal geometry_msgs/msg/PoseStamped \
|
||||
"{header: {frame_id: world}, pose: {position: {x: -3.8, y: 4.5, z: 0.15}, orientation: {w: 1.0}}}"
|
||||
```
|
||||
|
||||
固定起点、故障锁停后的重启和点云接口见 [P6 导航说明](docs/P6_NAVIGATION.md)。
|
||||
本入口用于平地。LIO 坡道使用 `ros2 launch br_sim_bringup scan_lio_terrain.launch.py`,
|
||||
等感知就绪后下发三维参考路径;路径命令、4 cm 专用裕度和物理边界见 [LIO 坡道说明](docs/P6_LIO_TERRAIN.md)。
|
||||
原真值平地/坡道入口 `scan_sim.launch.py`、`scan_terrain.launch.py` 保留作对照。
|
||||
|
||||
其他入口:
|
||||
|
||||
```bash
|
||||
# 场地单独运行
|
||||
ros2 launch robocon_gazebo robocon_gazebo.launch.py
|
||||
# 机器人与雷达,不启动导航
|
||||
ros2 launch r2027_robot_description robocon_robot.launch.py lidar:=true
|
||||
# MID360 兼容传感器 + 原 Point-LIO(暂不启动 SCAN)
|
||||
ros2 launch br_sim_bringup mid360_sim.launch.py with_lio:=true
|
||||
# MID360 + 原 Point-LIO + SCAN 平地闭环(已知起点先验,独立于真值入口)
|
||||
ros2 launch br_sim_bringup scan_lio.launch.py
|
||||
# MID360 + Point-LIO + SCAN 指定坡道三维参考路径(独立低速配置)
|
||||
ros2 launch br_sim_bringup scan_lio_terrain.launch.py
|
||||
```
|
||||
|
||||
原导航入口使用真值和通用瞬时三维雷达;独立 P6 入口按物理步采样并带真实批次时间,包含 200 Hz IMU。
|
||||
P6 扫描图案是近似,默认 ideal 无注入噪声,可选 mild/stress 工程压力参数;IMU 不提供绝对姿态。
|
||||
接口、构建与误差见 [P6 定位说明](docs/P6_LOCALIZATION.md)。
|
||||
估计导航的坐标转换、已知起点、失效停车和实测证据见 [P6 导航说明](docs/P6_NAVIGATION.md)。
|
||||
LIO 坡道路径下发、专用过滤和适用边界见 [P6 坡道说明](docs/P6_LIO_TERRAIN.md)。
|
||||
所有节点使用仿真时间;机器人/导航入口配置 /clock 100 Hz,场地单独入口保留其基线配置。
|
||||
Classic 暂停时不发布新的 /clock,暂停判据和证据见对应验收说明。
|
||||
|
||||
## 压力、连续任务与双机入口
|
||||
|
||||
- `sensor_profile:=ideal|mild|stress` 选择可关闭的噪声、IMU 偏置与丢点;数值为工程压力参数,非实车标定。
|
||||
- 连续导航和感知盲区见 [ROBUSTNESS.md](docs/ROBUSTNESS.md),最终验收摘要见 [RELEASE_VALIDATION.md](docs/RELEASE_VALIDATION.md)。
|
||||
- 双进程/双机拆分命令见 [DEPLOY_SPLIT.md](docs/DEPLOY_SPLIT.md);本机拆分测试不代替真实跨机网络验收。
|
||||
- 当前单 MID360 对部分近处低障碍没有回波,不能承诺任意低障碍避让;真实轮组、完整比赛任务和硬件网络仍需现场验证。
|
||||
|
||||
## 目录与文档
|
||||
|
||||
| 路径 | 用途 |
|
||||
|---|---|
|
||||
| `src/robocon_gazebo` | 完整场地、world、来源哈希与场地入口 |
|
||||
| `src/r2027_robot_description` | 简化全向车体、雷达、命令超时保护、真值数据适配 |
|
||||
| `src/br_sim_bringup` | SCAN 仿真参数、导航入口、点云过滤和就绪门控 |
|
||||
| `tools/check_classic_baseline.py` | 场地资源、时钟、接触抽样验收 |
|
||||
| `tools/check_omni_robot.py` | 底盘 9 项验收 |
|
||||
| `tools/check_sim_lidar.py` | 点云坐标和场地几何检查 |
|
||||
| `tools/check_scan_navigation.py` | 平地导航与数据中断停车 |
|
||||
| `tools/check_narrow_navigation.py` | 窄通道与未支持地形的拒绝测试 |
|
||||
| `tools/check_slope_drive.py` | 重力、坡中停车、接触与倾斜点云检查 |
|
||||
| `tools/check_slope_navigation.py` | 两侧坡道 SCAN 上下坡与台阶禁行 |
|
||||
| `tools/repair_ramp_winding.py` | 固定来源坡道网格的面朝向修复 |
|
||||
| `tools/build_sim.sh` | 在独立前缀构建原接口、Point-LIO、SCAN 和仿真包 |
|
||||
| `tools/check_sensor_noise.py` | 白噪声/偏置/丢点及真实时间语义 |
|
||||
| `tools/check_low_obstacles.py` | 静止实际回波的近地视场边界,不代表避障通过 |
|
||||
| `tools/check_mid360.py` | 实际采样时刻、独立几何求交、IMU 比力和连续性 |
|
||||
| `tools/check_point_lio.py` | 现有 Point-LIO 的平地/上下坡独立定位评估 |
|
||||
| `tools/check_lio_navigation.py` | LIO 平地闭环、近目标短断流恢复与定位失效锁停 |
|
||||
| `tools/check_lio_terrain.py` | LIO 两侧坡道、台阶/箱体拒绝和下游断流停车 |
|
||||
| `docs/HANDOFF.md` | 当前交接与约定 |
|
||||
| `docs/CLASSIC_BASELINE.md` | 场地基线证据 |
|
||||
| `docs/P2_OMNI.md` | 底盘参数与复测结果 |
|
||||
| `docs/P3_P4_NAVIGATION.md` | 导航构建、运行、接口和验收 |
|
||||
| `docs/P5_NARROW.md` | 窄通道配置、地形拒绝测试与清理记录 |
|
||||
| `docs/P5_SLOPE.md` | 坡道驱动、参考路径、地图修复与验收 |
|
||||
| `docs/P6_LOCALIZATION.md` | MID360 兼容模型、IMU 与独立定位误差 |
|
||||
| `docs/P6_NAVIGATION.md` | Point-LIO 平地导航入口、接口约定与验收 |
|
||||
| `docs/P6_LIO_TERRAIN.md` | LIO 指定坡道的定位预算、过滤与物理验收 |
|
||||
| `docs/archive/fortress` | 旧方案退役说明;过期操作文档已移出源码树 |
|
||||
| `log/` | 原始证据与构建日志,Git 忽略 |
|
||||
| `build/classic`、`install/classic` | 三个仿真包的构建/安装前缀 |
|
||||
| `build/navigation`、`install/navigation` | 现有 SCAN 算法的独立构建/安装前缀 |
|
||||
| `build/localization`、`install/localization` | 原 Livox 消息与 Point-LIO;不构建硬件 SDK/驱动 |
|
||||
|
||||
## 地图与坐标
|
||||
|
||||
单位米、秒、弧度,右手系 Z 向上;场地原点保持源模型不变。
|
||||
红方 +Y、蓝方 −Y;坡道下降方向 +X。外部源模型和 Blender/GLB/FBX 原文件不改动。
|
||||
包内坡道碰撞 OBJ 仅反转朝内的面索引,顶点坐标不变;来源差异与哈希见模型包的 SOURCE_PROVENANCE.md。
|
||||
机器人 base_link 为箱体中心;0.80×0.80 m 外包络,平地落稳 z≈0.148987 m。
|
||||
世界→odom 是单位静态变换;odom→base_link 由运动插件唯一发布;雷达在 base_link 上方 0.30 m。
|
||||
详细话题类型、参考点、点云过滤和仿真限制见导航说明。
|
||||
|
||||
## 旧方案清理
|
||||
|
||||
2026-11-08 按用户要求删除旧 Fortress 包、导出配置与专用工具、旧安装入口,以及
|
||||
不再使用的 Blender 下载/解压副本,释放约 1.63 GB。过期调查说明移出源码树,测试日志保留。
|
||||
当前 Classic 地图、算法源码与外部原始资源未删除。清单见 `log/codex_p5_20261108/cleanup_manifest.json`。
|
||||
|
||||
最终复核又移除了过期操作文档、旧顶层构建标记和链接;原始证据备份保留在本机忽略的 log/。
|
||||
源码、配置、场地模型和精简验收摘要入库,build/install/log、缓存与下载包不入库。
|
||||
@@ -0,0 +1,401 @@
|
||||
# Classic 基线验收(SIM-P1-004-C / -R1 / -R2)
|
||||
|
||||
把 `/home/kevin/r2027_gazebo_model` 的完整场地正式纳入本项目,改用 **Gazebo Classic 11.10.2**
|
||||
启动并验证。此前基于 Fortress 的候选地图方案(`br_gazebo`)退役。
|
||||
|
||||
> **后续更正(2026-11-08,P5 坡道)**:当前坡道碰撞 OBJ 只反转了全部面的索引顺序,
|
||||
> 修复朝内法线;顶点、尺寸和位姿不变,外部源文件未修改。其余三份模型文件仍与源一致。
|
||||
> 下文“四文件一致、未改模型”的描述是原 P1 基线历史状态,不代表修复后的当前版本。
|
||||
> 详见 `src/robocon_gazebo/SOURCE_PROVENANCE.md` 与 `docs/P5_SLOPE.md`。
|
||||
> 修复后已重跑 K05/K06 两侧坡道球体接触,2/2 PASS;另完成实际车体上下坡与真值导航。
|
||||
> 新接触证据:`log/codex_p5_slope_20261108/contact_regression_r3/contacts/contacts.json`。
|
||||
> 本轮没有把其他六个历史接触用例写成重新运行。
|
||||
|
||||
> **结论(R2 收尾后)**:
|
||||
> - 资源、构建、自包含、时钟/暂停/恢复:**有证据**(`log/p1_004_c/`)。
|
||||
> - 8 个抽样接触点:最终 **8/8 PASS**。K02、K08 由 R1 复测,其余 6 个沿用旧轮次证据;
|
||||
> **不是 8 个全重测**,逐项来源见 §4.2 与 R2 报告 §6。
|
||||
> - 进程隔离(收尾不误伤别人的 gzserver):**已验证**(§4.6)。
|
||||
> - GUI 画面:沿用**实机目视记录**,按负责人意见不要求截图。
|
||||
> - R2 只修报告判定与退出码,**未启动仿真**、未重跑接触、未改模型/launch/依赖(§4.7)。
|
||||
> - 未改模型几何、未改格式、未加依赖、未换物理引擎,无阻断项。
|
||||
>
|
||||
> 机读汇总与原始数据:`log/p1_004_c_r2/BASELINE_REPORT.md`(最终判定)→
|
||||
> `log/p1_004_c_r1/`(R1)→ `log/p1_004_c/`(旧轮次)。本文件讲方法与判断依据。
|
||||
|
||||
---
|
||||
|
||||
## 1. 纳入的到底是什么
|
||||
|
||||
| 项 | 内容 |
|
||||
|---|---|
|
||||
| 源 | `/home/kevin/r2027_gazebo_model/src/robocon_gazebo/` |
|
||||
| 目标 | `sim_ws/src/robocon_gazebo/`(包名不变) |
|
||||
| 导入 | `launch/`、`worlds/robocon_track_full.world`、`models/robocon_ground_full/` |
|
||||
| 未导入 | `src/r2027_robot_description/`、`gazebo_models/` 克隆目录、`urdf/`、`scripts/`、`build/`、`install/`、`log/`、缓存、MuJoCo、机器人包 |
|
||||
|
||||
来源、逐文件哈希与清点见 `src/robocon_gazebo/SOURCE_PROVENANCE.md`。
|
||||
|
||||
**新地图是几何基准**,不再按旧 Blender 场地修正尺寸。基线验收时旧 `br_gazebo` 以
|
||||
`COLCON_IGNORE` 停用;2026-11-08 后续按用户要求删除旧包与工具,调查说明归档到
|
||||
`docs/archive/fortress`,测量与测试日志保留。当前场地几何和本节基线证据未改动。
|
||||
|
||||
### 1.1 四个模型文件字节一致
|
||||
|
||||
| 文件 | SHA256(包内 = 源) |
|
||||
|---|---|
|
||||
| `model.sdf` | `f7bb3481…44cc4a` |
|
||||
| `model.config` | `9a6e197f…e5990864` |
|
||||
| `meshes/Untitled.dae` | `f69ef7a0…5b9d007bb` |
|
||||
| `meshes/ramp.obj` | `5344932e…ee331f13` |
|
||||
|
||||
不改几何、不改材质、不改格式、不改比例。碰撞体清点:**50 = 46 box + 2 cylinder + 2 mesh**,
|
||||
与任务给出的数字一致(1 个 `static=true` 的 link,共用一张视觉 DAE)。
|
||||
|
||||
### 1.2 world 只删了两行
|
||||
|
||||
源 world 把两个 ROS 插件写成了 world 级 `<plugin>`:
|
||||
|
||||
```xml
|
||||
<plugin name="gazebo_ros_init" filename="libgazebo_ros_init.so"/>
|
||||
<plugin name="gazebo_ros_factory" filename="libgazebo_ros_factory.so"/>
|
||||
```
|
||||
|
||||
本机头文件确认这两个库都是 `gazebo::SystemPlugin`,**不能**作为 world plugin 加载。
|
||||
包内 world 删掉这两行(原位置只留一段说明注释),其余内容与源**逐字节一致**——
|
||||
这一条不是靠肉眼保证的,工具会把注释去掉、把两行加回去,再与源做全字节比较
|
||||
(`assets` 阶段「world 仅移除两行插件声明」)。
|
||||
|
||||
---
|
||||
|
||||
## 2. 构建与启动
|
||||
|
||||
### 2.1 CMake 去掉了外部依赖
|
||||
|
||||
原 `CMakeLists.txt` 会去找仓库克隆目录 `../../gazebo_models`,并 `FATAL_ERROR` 强制
|
||||
`${ROBOCON_MODELS_DIR}/robocon_track.world` 存在,再把外部 `robocon_ground` 整个目录装进
|
||||
`install/share`。这会让安装产物指回外部工作区。
|
||||
|
||||
现在只安装**包内** `launch` / `worlds` / `models`,没有任何外部路径。
|
||||
|
||||
### 2.2 插件加载方式
|
||||
|
||||
用官方 `gazebo_ros/gzserver.launch.py`,参数 `init:=true`、`factory:=true`,
|
||||
各自落到 gzserver 的 `-s libgazebo_ros_init.so` / `-s libgazebo_ros_factory.so`,**各一次**。
|
||||
再设 `force_system:=false`,避免多加载第三个系统插件(默认是 `true`)。
|
||||
|
||||
证据不是"日志里看起来有",而是直接读 **gzserver 进程的 `/proc/<pid>/cmdline`** 计数:
|
||||
`libgazebo_ros_init.so` = 1、`libgazebo_ros_factory.so` = 1、`libgazebo_ros_force_system.so` = 0。
|
||||
再加运行时旁证:`/clock` 有发布者(init 起作用)、`/clock` 单发布者。
|
||||
|
||||
### 2.3 从别处启动也成立
|
||||
|
||||
检查工具启动 `ros2 launch` 时把 `cwd` 固定为 `/`,并且只 source
|
||||
`/opt/ros/humble/setup.bash` + 本工作区 `install/classic/setup.bash`。
|
||||
另外做结构核对:`share/robocon_gazebo/{launch,worlds,models}` 下 6 个文件实体
|
||||
(`--symlink-install` 是符号链接)**全部**回溯到 `sim_ws/src/robocon_gazebo`,
|
||||
且 `share` 内没有任何文件内容含 `r2027_gazebo_model`。
|
||||
|
||||
### 2.4 运行隔离
|
||||
|
||||
`GAZEBO_MASTER_URI=http://127.0.0.1:11355`(与默认 11345 隔离)、`ROS_DOMAIN_ID=77`、
|
||||
`ROS_LOCALHOST_ONLY=1`。launch 内固定,server / client / 采集工具共用同一 master。
|
||||
本机版本记录见 `log/p1_004_c/versions.txt`(Classic 11.10.2、gazebo_ros 3.9.0、
|
||||
gazebo_plugins 3.9.0、gazebo_msgs 3.9.0)。
|
||||
|
||||
---
|
||||
|
||||
## 3. 时钟、暂停、恢复
|
||||
|
||||
### 3.1 结果
|
||||
|
||||
| 项 | 实测 |
|
||||
|---|---|
|
||||
| `/clock` 发布者数 | **1** |
|
||||
| 连续运行仿真时间 | span = **10.000 s**,100 个采样,倒退 **0** 次 |
|
||||
| 暂停接口 | ROS 服务 **`/pause_physics`** |
|
||||
| 暂停 3.0 s 墙钟 | 仿真 10.700000 → 10.700000,**推进 0.000000000 s**,期间收到 **0** 条 clock |
|
||||
| 二次恢复接口 | ROS 服务 **`/unpause_physics`** |
|
||||
| 恢复后 | span = **1.000 s**,10 个采样 |
|
||||
|
||||
### 3.2 Classic 与 Fortress 的两个行为差异(关键,容易踩)
|
||||
|
||||
1. **暂停时世界不步进,`/clock` 一条都不发。** Fortress 是"继续发但数值冻结",
|
||||
Classic 是"直接不发"。所以:
|
||||
- 「暂停下收不到 clock」是**正确现象**,不是采集失败;
|
||||
- **不能**用「收到 clock」当就绪判据。本轮第一次跑 clock 阶段就因为这条卡了 90 s
|
||||
超时——以 `paused:=true` 启动的 server 永远不会发 clock,正确判据是
|
||||
**`/clock` 有没有发布者**(发布者存在即证明 init 已加载建好 publisher)。
|
||||
2. **本轮配置下实测 `/clock` 为 10 Hz。** 采样值严格是 0.1 / 0.2 / 0.3 …,间隔恒为 0.1 s。
|
||||
这是**本轮 world 与插件配置下的实测结果**,不是 Classic 固定属性;换配置要重测。
|
||||
所以时间分辨率是 0.1 s,不能拿它做亚采样级时序推断。
|
||||
|
||||
### 3.3 暂停接口是"发现"出来的,不是假定的
|
||||
|
||||
任务要求"使用本机实际支持的 Classic 接口,不要假定 ROS 1 的暂停服务存在"。
|
||||
工具的做法:查 `get_service_names_and_types()`,找 `*pause_physics` / `*unpause_physics`
|
||||
(`std_srvs/srv/Empty`),调不通再回落到 Classic 传输层 `gz world -p 1|0`,
|
||||
并把**实际用了哪一个**写进证据。本轮两次都是 ROS 服务直连成功,没走兜底。
|
||||
|
||||
---
|
||||
|
||||
## 4. 8 个抽样接触用例
|
||||
|
||||
### 4.1 方法
|
||||
|
||||
球 `r=0.020 m`、`m=0.10 kg`、`I=2/5·m·r²=1.6e-05 kg·m²`,从预期表面上方 **0.20 m**
|
||||
自由落下(球心 = 表面 + 0.220 m)。
|
||||
|
||||
每个用例:
|
||||
|
||||
1. 用**包内 world + 测试球**生成测试副本(`contacts/cases/<id>/world_ball.sdf`),
|
||||
**生产 world 不动**。测试球带 `<sensor type="contact">` + 官方 `libgazebo_ros_bumper.so`,
|
||||
发布 `gazebo_msgs/msg/ContactsState`。
|
||||
2. `paused:=true` 启动 → 确认暂停 → 发现 `ContactsState` 话题且发布者 ≥ 1 →
|
||||
`gz model -m test_ball -p` **实测**释放前位姿(漂移须 ≤ 2 mm)→ 判定采集就绪。
|
||||
3. `unpause` 释放,连续采集到释放后 **2 s 仿真时间**。
|
||||
4. 判定(排除球自身后):
|
||||
|
||||
| 类型 | 判据 |
|
||||
|---|---|
|
||||
| 水平目标 | 目标碰撞体出现,接触点 `|Δz| ≤ 3 mm` |
|
||||
| 坡道 | 接触点**到实际斜面的垂直距离** ≤ 3 mm,且落在坡面范围内;**允许沿坡滚动** |
|
||||
| 场地外 | 零接触,且球跌至 `z < −0.10` |
|
||||
|
||||
坡道斜面来自 `ramp.obj` 楔形(局部 `x∈[-0.8,2.7]`、`y∈[0,1]`、`z∈[0,0.597]`):
|
||||
|
||||
```
|
||||
d = |0.597·x + 3.5·z − 1.6119| / sqrt(0.597² + 3.5²) = |…| / 3.55055
|
||||
```
|
||||
|
||||
`ramp_north` pose=(0,3,0) → 世界 `y∈[3,4]`;`ramp_south` pose=(0,−4,0) → 世界 `y∈[−4,−3]`。
|
||||
|
||||
### 4.2 结果与证据来源(本轮只复测 2 个)
|
||||
|
||||
| 用例 | 目标 | 释放位姿 (x,y,z) | 首接触 t(s) | 接触对象 | 世界接触点 | 判定 | 证据来源 |
|
||||
|---|---|---|---|---|---|---|---|
|
||||
| K01 | 地面 | (−4.800, 4.800, 0.220) | 0.2000† | `ground` | (−4.8000, 4.8000, 0.0000) | PASS | 旧轮次 |
|
||||
| **K02** | **L1** | **(−2.000, 2.000, 0.820)** | **0.2040‡** | **`Cube`** | **(−2.0000, 2.0000, 0.6000)** | **PASS** | **本轮复测** |
|
||||
| K03 | L2 | (−1.000, 1.000, 1.120) | 0.2000† | `Cube.017` | (−1.0000, 1.0000, 0.9000) | PASS | 旧轮次 |
|
||||
| K04 | 第一踏步 | (−2.550, 3.500, 0.370) | 0.2000† | `Cube.002` | (−2.5500, 3.5000, 0.1500) | PASS | 旧轮次 |
|
||||
| K05 | 红侧坡道 | (1.000, 3.500, 0.510) | 0.2000† | `ramp_north` | (0.9984, 3.5066, 0.2903) | PASS | 旧轮次 |
|
||||
| K06 | 蓝侧坡道 | (1.000, −3.500, 0.510) | 0.2000† | `ramp_south` | (0.9984, −3.4934, 0.2903) | PASS | 旧轮次 |
|
||||
| K07 | 红侧围栏开口 | (−1.300, 2.975, 0.820) | 0.2000† | `Cube` | (−1.3000, 2.9750, 0.6000) | PASS | 旧轮次 |
|
||||
| **K08** | **场地外** | **(−6.000, 0.000, 0.220)** | — | — | — | **PASS** | **本轮复测** |
|
||||
|
||||
† 旧轮次记录:接触时刻用的是 `clock_at_recv`,受当年 10 Hz 采样限制,只能标到 0.2000。
|
||||
‡ 本轮用消息自带的 `header_stamp`(接触传感器 500 Hz,分辨率 2 ms)。
|
||||
两者**不可直接比精度**,所以旧轮次那 6 个时刻不要拿来当高精度证据。
|
||||
|
||||
**本轮实际只跑了 K02、K08 两个用例,不是 8 个全重测。** 其余 6 个沿用旧轮次证据,
|
||||
旧轮次这 6 个的采集门控与位姿都是有效的。
|
||||
|
||||
### 4.3 旧轮次的重测结果:K02 原本是「采集无效」,不是「碰撞失败」
|
||||
|
||||
旧轮次 8 个用例实际是 **7 PASS + 1 采集无效**,无效的就是 K02:
|
||||
`ball_initial_pose_observed = null`,即释放前位姿根本没取到,用例停在门控之前,
|
||||
既不能判通过也不能判碰撞失败。本轮复测 K02 已通过(上表)。
|
||||
|
||||
根因不是位姿查询本身,而是**两个重叠运行互相打断**:旧版收尾按进程名扫描**全部**
|
||||
gzserver 逐个发信号,于是同一台机器上两个并行实例会把对方的 server 杀掉,
|
||||
查询随之落空。详见 §4.4 第 1 条。
|
||||
|
||||
### 4.4 三个已经踩过的坑
|
||||
|
||||
1. **不能按进程名批量收尾。** 旧版 `stop()` 扫描所有名为 `gzserver` 的进程并杀,
|
||||
两次并行运行会互杀(K02 采集无效就是这么来的)。现在的做法:
|
||||
- 启动时 `start_new_session`,记录自己的 pgid;
|
||||
- **只**用 `/proc/<pid>/stat` 的 PPID 关系从自己的根 PID 往下找子进程,
|
||||
并把启动阶段确认过的这批 PID 记下来(`known_pids`);
|
||||
- 收尾先 SIGTERM 自己的进程组,再对这批已知 PID 精确 SIGTERM / SIGKILL;
|
||||
- 启动前用 TCP 探测 master 端口;**被占就报错退出,绝不去杀占用者**。
|
||||
为什么不能只靠 killpg:实测 `ros2 launch` 会把 gzserver 放进它自己的会话,
|
||||
`killpg(launch)` 打不到它;launch 先退出后 gzserver 被挂到 PID 1,
|
||||
PPID 树也就看不见它了。所以必须以「启动阶段确认过的 PID」为准。
|
||||
2. **bumper 会发空消息。** `libgazebo_ros_bumper.so` 按自己的更新率周期性发
|
||||
`states=[]` 的 `ContactsState`,**暂停期间也照发**。所以「收到几条消息」≠「发生几次接触」。
|
||||
曾把空消息计入,K08(场地外)被误判成"收到上万条接触消息"而失败;
|
||||
改成只统计 `states` 非空的之后正确。
|
||||
3. **释放时刻的仿真时间不能用第一个 clock 采样当基准。** 本轮实测 clock 是 10 Hz 网格,
|
||||
首个采样可能已经晚到 0.1 s,会把首接触时刻整体算偏。世界是以 `paused:=true` 启动、
|
||||
释放前从未步进(释放前 clock 消息数 = 0 为证),所以释放瞬间 `sim = 0.0`,
|
||||
直接取 0.0 才是对的。
|
||||
|
||||
### 4.5 判定口径:三态,且数据不足不算结论
|
||||
|
||||
`PASS` 必须**同时**满足:释放前位姿有效(偏差 ≤ 2 mm)、订阅就绪(接触话题发布者 ≥1、
|
||||
`/clock` 单发布者)、暂停确认、释放成功、采集覆盖 ≥ 2.0 s 仿真时间、物理判据成立。
|
||||
|
||||
任一门控不满足 → **`INVALID`(采集无效)**,既不写通过也不写碰撞失败。
|
||||
跨轮次怎么合计成最终结论、退出码怎么取,见 §4.7。
|
||||
|
||||
位姿查询走有界重试(8 次、间隔 0.4 s),每次失败原因、尝试次数、耗时都写进证据;
|
||||
全部失败仍取不到就判 `INVALID`,**绝不拿 `None` 当「球没动」或「没有接触」**。
|
||||
|
||||
---
|
||||
|
||||
### 4.6 进程隔离验证(本轮)
|
||||
|
||||
要求是「检查工具退出后,别人/别的实例的 gzserver 仍存活」。做法与结果:
|
||||
|
||||
- 本阶段自己用**裸 gzserver** 在另一个空闲端口(11355+100=11455)起一个空世界 server;
|
||||
- 再让工具实例在 11355 上完整跑一遍 `start` + `stop`;
|
||||
- 然后检查隔离 server 的 PID 是否还在、端口是否还能连通、该 PID 是否曾进入工具实例的
|
||||
进程树/已知 PID 集合;
|
||||
- 最后**按记录 PID** 收掉隔离 server。
|
||||
|
||||
| 项 | 结果 |
|
||||
|---|---|
|
||||
| 隔离 server 端口 / PID | 11455 / 70(0.90 s 起来) |
|
||||
| 工具实例端口 | 11355(其 gzserver=164) |
|
||||
| 工具实例收尾后隔离 server 仍存活 | **是** |
|
||||
| 隔离 server 端口仍可连通 | 是 |
|
||||
| 隔离 PID 是否出现在工具实例树 | **否** |
|
||||
| 按记录 PID 清理 | 完成 |
|
||||
| 工具实例收尾耗时 | 0.2 s,端口立即释放 |
|
||||
|
||||
两个 server 都是本阶段自己起的,**没有拿任何已有进程做实验**。
|
||||
|
||||
> 踩坑记录:`gzserver -v` 是「打印版本」而不是 verbose,verbose 要用 `--verbose`。
|
||||
> 第一版隔离阶段就因为这个一直 exit 255。
|
||||
|
||||
---
|
||||
|
||||
### 4.7 最终判定与退出码(R2)
|
||||
|
||||
R2 只动「怎么合计结论」,不动任何采集。要解决的是三个具体问题:旧状态字符串没归一、
|
||||
跨轮次来源可能被读成「本轮重测」、`--stage all` 的退出码只看阶段局部结果。
|
||||
|
||||
**证据源优先级**:本轮目录 → 旧轮次(`--prev` 可给多个,逗号分隔,从近到远)。
|
||||
同一用例**逐项**解析:本轮有就用本轮(**本轮 INVALID/FAIL 不被旧 PASS 覆盖**);
|
||||
本轮没有才按优先级取旧证据;都没有记 `MISSING`(缺失)。
|
||||
|
||||
**状态归一**:`PASS` / `FAIL` / `INVALID` 之外,旧轮次里出现过 `FAILD`——那是旧版字符串
|
||||
拼接的产物,其记录的 `reason` 是「采集/暂停前置条件不满足」,语义属于**采集无效**,
|
||||
映射为 `INVALID`(不映射成 PASS,也不映射成碰撞失败)。识别不了的字符串一律按 `INVALID`:
|
||||
「不认识」不能当通过,也不能当有效失败。原始字符串始终在报告里保留一列。
|
||||
|
||||
**退出码**(报告与命令同源,都由 `compute_outcome()` 算):
|
||||
|
||||
| 码 | 含义 | 触发条件 |
|
||||
|---|---|---|
|
||||
| 0 | 全部满足 | 8 例全 PASS,且资源/时钟/隔离三段证据齐备且通过 |
|
||||
| 30 | 有效测试失败 | 结果集有效,但有 `FAIL`(或某阶段检查未通过) |
|
||||
| 40 | 缺失 / 无效 / 不完整 | 有 `MISSING` 或 `INVALID`,或某阶段证据缺失 |
|
||||
|
||||
**40 优先于 30**:结果集里只要含无效/缺失项,结论本身不可用,不能报成「有效测试失败」。
|
||||
|
||||
**`--stage all` 的退出码取最终报告**,不取阶段局部结果——四条 `ok: True` 也可能因为
|
||||
8 例汇总里缺一项而必须是 40。单阶段运行(`--stage contacts` 等)不声称完成完整基线,
|
||||
其退出码只反映该阶段,码值仍用同一套 0/30/40。
|
||||
|
||||
**两个哈希分开列**:报告头部给「当前报告工具 sha256」,另表单列每份被采用数据的
|
||||
「采集工具 sha256」。工具版本不同**不触发重跑物理测试**,原数据哈希与原始消息原样引用。
|
||||
|
||||
验证(`log/p1_004_c_r2/tests/`,全部是真实命令行调用 + 退出码,**不启动仿真**):
|
||||
|
||||
| 验证 | 构造 | 期望 | 实得 |
|
||||
|---|---|---|---|
|
||||
| V0 空目录 | 无任何证据 | 40 | 40 |
|
||||
| V1 本轮+R1+旧证据 | 真实组合 | 0 | 0(8 例来源正确) |
|
||||
| V2 沿用旧用例改 FAIL | 副本里 K05→FAIL | 30 | 30(点名 K05) |
|
||||
| V3a 用例缺失 | 副本里删掉 K06 | 40 | 40(点名 K06 缺失) |
|
||||
| V3b 本轮 INVALID 覆盖旧 PASS | 副本里 K03→INVALID | 40 | 40(K03 保持 INVALID) |
|
||||
| V4a `all` 阶段全成功但报告不完整 | 桩替代阶段执行 | 40 | 40 |
|
||||
| V4b `all` 证据齐备 | 桩替代阶段执行 | 0 | 0 |
|
||||
|
||||
V4 用桩替代阶段执行(`tests/stub_all_driver.py`,导入模块后替换 `stage_*`,不碰仿真),
|
||||
日志里同时打印「各阶段局部结果」与「最终退出码取报告判定」,两者可以不一致。
|
||||
明细见 `log/p1_004_c_r2/tests/RESULTS.md`。
|
||||
|
||||
---
|
||||
|
||||
## 5. GUI 画面:**已通过(实机目视)**
|
||||
|
||||
**确认人 kevin,2026-11-07,宿主桌面会话**(`gzclient` 直连
|
||||
`GAZEBO_MASTER_URI=http://127.0.0.1:11355`):GUI 正常出图,场地画面可用。
|
||||
该判定**来自实机目视**,不是从像素数值或日志推断的。
|
||||
|
||||
需确认的画面项:红蓝分区、L1 平台、L2 平台、北侧(红方)坡道、南侧(蓝方)坡道、
|
||||
三级踏步、围栏开口。本轮是**整体目视确认,未逐项单独记录**。
|
||||
|
||||
**截图不作为验收要求**(负责人 2026-11-07 明确)。判定依据就是实机目视;
|
||||
`log/p1_004_c/gui/status.json` 里 `screenshots_required=false` 即此意。
|
||||
如后续要留图,放截图进该目录并在 `status.json` 的 `screenshots` 登记文件名即可,
|
||||
报告会自动引用。
|
||||
|
||||
### 5.1 为什么这一步只能由人来做
|
||||
|
||||
本执行环境没有 `DISPLAY`、没有 `/dev/dri`。在这个环境里跑 `gzserver` 会打出:
|
||||
|
||||
```
|
||||
[Err] [RenderEngine.cc:749] Can't open display:
|
||||
[Wrn] [RenderEngine.cc:89] Unable to create X window. Rendering will be disabled
|
||||
libGL error: glx: failed to create dri3 screen
|
||||
libGL error: failed to load driver: iris
|
||||
```
|
||||
|
||||
这些是**渲染不可用**,不是资源或插件错误——检查工具把这类日志单列记录、**不判失败**
|
||||
(否则会把 headless 环境误判成资源缺陷)。`gzclient` 因此无法在本环境启动,
|
||||
所以画面证据只能在宿主桌面取得。
|
||||
|
||||
### 5.2 GUI 状态怎么进报告
|
||||
|
||||
GUI 结论不在检查工具里硬写,而是读 `log/p1_004_c/gui/status.json`:
|
||||
|
||||
| 字段 | 含义 |
|
||||
|---|---|
|
||||
| `result` | `passed` / `unverified` |
|
||||
| `basis` | 判定依据(本轮 = 实机目视确认) |
|
||||
| `confirmed_by` / `confirmed_at` | 确认人 / 日期 |
|
||||
| `criteria` / `criteria_checked_individually` | 需确认项、是否逐项记录 |
|
||||
| `screenshots` / `screenshots_required` / `screenshots_note` | 截图文件名 / 是否要求 / 说明 |
|
||||
|
||||
没有这个文件时报告按「未验证」输出,避免把没人看过的画面写成通过。
|
||||
这样"谁在什么环境看的"写在数据里,不写在代码里。
|
||||
|
||||
> 注意:Gazebo 11 用 Ogre1,Fortress 用 Ogre2,是两条不同渲染链路。
|
||||
> 旧 Fortress 的 GLX/EGL 结论**不能**套用到 Classic 的 `gzclient`。
|
||||
|
||||
---
|
||||
|
||||
## 6. 边界与不宣称的东西
|
||||
|
||||
- 只做了 **8 个抽样点**,**不宣称**覆盖全部 50 个碰撞体。
|
||||
- 不宣称机器人可通行、整车爬坡、平台转向——本轮不接机器人。
|
||||
- 不接 TF、里程计、点云、`/cmd_vel`;不用 `ros_gz_bridge`;不加载 Fortress。
|
||||
- 旧 Fortress 的 P0/P1 结果**不作为**本基线证据,两套引擎的接触求解与时序不同。
|
||||
- 未改模型几何、未改格式、未加依赖、未换物理引擎。
|
||||
|
||||
---
|
||||
|
||||
## 7. 复现
|
||||
|
||||
```bash
|
||||
# 构建
|
||||
source /opt/ros/humble/setup.bash
|
||||
cd /home/kevin/RC2027_BR_code/sim_ws
|
||||
PATH=/usr/bin:$PATH colcon build \
|
||||
--build-base build/classic --install-base install/classic \
|
||||
--packages-select robocon_gazebo --symlink-install \
|
||||
--cmake-args -DPython3_EXECUTABLE=/usr/bin/python3
|
||||
source install/classic/setup.bash
|
||||
|
||||
# 全量检查(自己起停 gzserver,约 3 分钟)
|
||||
export GAZEBO_MASTER_URI=http://127.0.0.1:11355 ROS_DOMAIN_ID=77 ROS_LOCALHOST_ONLY=1
|
||||
/usr/bin/python3 /home/kevin/RC2027_BR_code/sim_ws/tools/check_classic_baseline.py --stage all
|
||||
|
||||
# 分阶段 / 单用例
|
||||
/usr/bin/python3 /home/kevin/RC2027_BR_code/sim_ws/tools/check_classic_baseline.py --stage assets
|
||||
/usr/bin/python3 /home/kevin/RC2027_BR_code/sim_ws/tools/check_classic_baseline.py \
|
||||
--stage contacts --only K02,K08 --out /home/kevin/RC2027_BR_code/sim_ws/log/p1_004_c_r1
|
||||
|
||||
# 进程隔离验证
|
||||
/usr/bin/python3 /home/kevin/RC2027_BR_code/sim_ws/tools/check_classic_baseline.py \
|
||||
--stage isolation --out /home/kevin/RC2027_BR_code/sim_ws/log/p1_004_c_r1
|
||||
|
||||
# 只重建报告(读磁盘上的结果;缺数据/有 INVALID 会返回非零)
|
||||
/usr/bin/python3 /home/kevin/RC2027_BR_code/sim_ws/tools/check_classic_baseline.py \
|
||||
--stage report --out /home/kevin/RC2027_BR_code/sim_ws/log/p1_004_c_r1 \
|
||||
--prev /home/kevin/RC2027_BR_code/sim_ws/log/p1_004_c
|
||||
```
|
||||
@@ -0,0 +1,67 @@
|
||||
# Gazebo 与导航分开启动
|
||||
|
||||
本机两个独立 launch 进程的连线回归使用 `scan_lio_split.launch.py`。
|
||||
它验证进程边界、消息接口和停车;**不等于真实两台电脑的网络验收**。
|
||||
真正跨机仍需机器人电脑在线,现场验证发现、带宽、延迟和断网停车。
|
||||
|
||||
ROS 域设置遵循 [ROS 2 Humble 环境说明](https://docs.ros.org/en/humble/Tutorials/Beginner-CLI-Tools/Configuring-ROS2-Environment.html)。
|
||||
两端 ROS 2 Humble、相同消息定义,ROS_DOMAIN_ID 相同;跨机时显式 ROS_LOCALHOST_ONLY=0。
|
||||
当前 robot launch 尊重上述环境变量,默认仍为本机域 77 和 localhost=1,不再覆盖用户的跨机设置。
|
||||
|
||||
## 笔记本:物理与传感器
|
||||
|
||||
在仓库根目录构建后,终端执行:
|
||||
|
||||
```bash
|
||||
source /opt/ros/humble/setup.bash
|
||||
source sim_ws/install/classic/setup.bash
|
||||
export ROS_DOMAIN_ID=77 ROS_LOCALHOST_ONLY=0
|
||||
export GAZEBO_MASTER_URI=http://127.0.0.1:11355
|
||||
ros2 launch r2027_robot_description robocon_robot.launch.py \
|
||||
lidar:=true sensor_model:=mid360 drive:=contact \
|
||||
x:=-4.5 y:=4.5 z:=0.15 yaw:=0.0 sensor_profile:=ideal
|
||||
```
|
||||
|
||||
这里只运行场地、机器人、物理雷达/IMU、命令保护与真值观测接口,不运行 Point-LIO/SCAN。
|
||||
|
||||
## 算法电脑:原定位、规划与控制
|
||||
|
||||
复制同一版本源码,按 P6_LOCALIZATION.md 构建 Livox 接口和 Point-LIO,
|
||||
按 P3_P4_NAVIGATION.md 构建 SCAN/step_blocker,再只构建 br_sim_bringup:
|
||||
|
||||
```bash
|
||||
source /opt/ros/humble/setup.bash
|
||||
source sim_ws/install/localization/setup.bash
|
||||
source sim_ws/install/navigation/setup.bash
|
||||
PATH=/usr/bin:$PATH colcon build --base-paths sim_ws/src/br_sim_bringup \
|
||||
--packages-select br_sim_bringup --build-base sim_ws/build/classic \
|
||||
--install-base sim_ws/install/classic --symlink-install
|
||||
source sim_ws/install/classic/setup.bash
|
||||
export ROS_DOMAIN_ID=77 ROS_LOCALHOST_ONLY=0
|
||||
ros2 launch br_sim_bringup scan_lio.launch.py start_sim:=false \
|
||||
x:=-4.5 y:=4.5 z:=0.15 yaw:=0.0
|
||||
```
|
||||
|
||||
`start_sim:=false` 不查找机器人描述包、不加载 Gazebo、不创建第二个 server。
|
||||
算法只需要 ROS 消息、Point-LIO、SCAN 与 br_sim_bringup 的 launch/脚本资源。
|
||||
此端不需要 Gazebo master 地址,通信通过 ROS 2 DDS。
|
||||
实车算法包没有新增 Gazebo 依赖,仿真与实车安装前缀应分别使用。
|
||||
|
||||
两端已知起点参数必须相同,且实际从该平地起点静止开始。
|
||||
坡道模式分别改起点为 (3.5,±3.5125,0.15,0),算法入口换 `scan_lio_terrain.launch.py start_sim:=false`。
|
||||
噪声只在物理端用 sensor_profile 选择,不能在算法端假装已经改变物理观测。
|
||||
|
||||
## 现场验收
|
||||
|
||||
- 算法端可接收 /clock、/sim/mid360/lidar、/sim/mid360/imu,时间戳持续增加。
|
||||
- /planning/perception_ready 为 true 后,按已验收目标/路径测试;独立真值不能作为算法输入。
|
||||
- 只允许一个 /sim/cmd_vel 发布者(物理端命令保护),不要启动真实雷达/串口桥。
|
||||
- 分别检查传感器掉流和网络中断时的停车;本机暂停 Point-LIO 不代替跨机断网验收。
|
||||
- 若 DDS 无法发现,检查两端域、网卡、多播和防火墙;不要为本教程自动修改系统网络。
|
||||
|
||||
本机复现(自动起停,不能与手动仿真同时运行):
|
||||
|
||||
```bash
|
||||
/usr/bin/python3 sim_ws/tools/check_lio_navigation.py --split --laps 2 \
|
||||
--sensor-profile mild --out sim_ws/log/split_continuous_manual
|
||||
```
|
||||
@@ -0,0 +1,141 @@
|
||||
# 当前交接(2026-11-08)
|
||||
|
||||
用户已授权 Codex 直接调查、修改、构建、运行和验收;当前未安排 DeepSeek 并行修改。
|
||||
同日新增授权清理旧方案,覆盖旧交接中“旧源码与工具一律不得删除”的限制。
|
||||
本轮用户明确授权更新 README 并 git commit;push 由用户执行。
|
||||
|
||||
## 已完成
|
||||
|
||||
| 阶段 | 当前证据 | 结论 |
|
||||
|---|---|---|
|
||||
| P1 Classic 地图 | `log/p1_004_c_r2/`,结合旧轮次及 R1 补测 | 8/8 接触抽样通过,非全部 50 碰撞体覆盖 |
|
||||
| P2 底盘 | `log/codex_p2_20261108/run/p2_001.json` | 9/9 全部重新实测通过 |
|
||||
| P3 三维点云 | `log/codex_p3_20261108/run/result.json` | yaw=0、π/2 各 13 项检查通过 |
|
||||
| P4 导航 | `log/codex_p4_20261108/arrival_r3/result.json` | 直达、横移、返回转向、绕障 4/4 通过 |
|
||||
| 数据中断停车 | `log/codex_p4_20261108/data_loss/result.json` | 0.240 s 内停车,独立真值验证 |
|
||||
| P5 平地扩展 | `log/codex_p5_20261108/summary.json` | 两朝向窄通道通过、三个不可通行目标按预期拒绝,5/5 |
|
||||
| P5 参数下 P4 回归 | `log/codex_p5_20261108/p4_regression/result.json` | 四条路线全部重新运行,4/4 通过 |
|
||||
| P5 两侧坡道导航 | `log/codex_p5_slope_20261108/{red_round_trip,blue_round_trip}/result.json` | 两侧各上、下坡通过,4/4;到点误差约 5.9 cm |
|
||||
| P5 两侧已知台阶 | `log/codex_p5_slope_20261108/{red_stairs,blue_stairs}/result.json` | 目标在地图内时拒绝且静止,2/2 |
|
||||
| P5 接触驱动物理 | `log/codex_p5_slope_20261108/physical_production/result.json` | 重力、上下坡、坡中停车、真实接触、倾斜点云,13 项通过 |
|
||||
| P5 驱动与平地回归 | `log/codex_p5_slope_20261108/{flat_r2,planar_regression}/p2_001.json`;`flat_regression/result.json` | contact 9/9、planar 9/9、平地导航 4/4 新实测通过 |
|
||||
| P6 MID360 兼容传感器 | `log/codex_p6_20261108/{sensors_flat_r3,sensors_slope_r2}/result.json` | 平地 16 项、坡上 14 项通过;真实批次采样时间、SI 比力和 IMU 连续性 |
|
||||
| P6 原 Point-LIO 定位 | `log/codex_p6_20261108/{lio_flat_r2,lio_slope_r1}/result.json` | 平地最大 0.010802 m、坡道最大 0.084729 m;仅起点固定对齐,未输入真值 |
|
||||
| P6 默认雷达回归 | `log/codex_p6_20261108/generic_regression_r1/result.json` | 两朝向各 13 项新实测通过 |
|
||||
| P6 LIO 平地导航 | `log/codex_p6_navigation_20261108/navigation_r5/result.json` | 直达、横移、返回转向、绕障完整新实测 4/4;最大到点误差 7.17 cm |
|
||||
| P6 近目标恢复 | `log/codex_p6_navigation_20261108/near_goal_recovery_r1/result.json` | 估计剩余 19.38 cm 时短断流,停稳后新轨迹授权并到达 |
|
||||
| P6 定位失效停车 | `log/codex_p6_navigation_20261108/loss_stop/result.json` | 0.440 s 停稳,恢复定位进程后故障锁停;没有真值回退 |
|
||||
| P6 原真值入口回归 | `log/codex_p6_navigation_20261108/truth_regression_r3/result.json` | 仅直达,源时间戳制动 0.110 s 后连续静止 1.1 s;旧立即静止协议失败记录保留 |
|
||||
| P6 LIO 指定坡道 | `log/codex_p6_lio_terrain_20261108/{red_round_trip_final,blue_round_trip_r2}/result.json` | 两侧上、下坡 4/4;同轮顶部台阶拒绝 2/2;最大到点误差 5.60 cm |
|
||||
| P6 坡道断流与箱体 | `log/codex_p6_lio_terrain_20261108/{blue_round_trip_r2,ramp_obstacle}/result.json` | 下游断流 0.410 s 停稳,同一目标新轨迹恢复;66/66 箱体回波保留、占用目标拒绝 |
|
||||
|
||||
P5 平地扩展见 `P5_NARROW.md`,坡道专用入口与证据见 `P5_SLOPE.md`。
|
||||
P6 独立传感器与 Point-LIO 定位基线见 `P6_LOCALIZATION.md`。
|
||||
P6 平地估计导航入口与证据见 `P6_NAVIGATION.md`。
|
||||
指定坡道 LIO 入口见 `P6_LIO_TERRAIN.md`;仅验收该地图两条坡道。
|
||||
真实厂家扫描图案、实车噪声标定、真实轮组和真实双机联调未验收。
|
||||
工程噪声/偏置、连续路线、低障碍视场和本机双进程拆分已补验,见 RELEASE_VALIDATION.md。
|
||||
当前启动、构建、RViz 和消息接口见 `P3_P4_NAVIGATION.md`。
|
||||
|
||||
## 实现边界
|
||||
|
||||
- 只使用 Gazebo Classic;完整地图为 `src/robocon_gazebo`,不是旧 Blender 首片区。
|
||||
- 算法继续来自 `minco_ws/src/scan`,在 `sim_ws/build/navigation` 中构建,未复制算法实现。
|
||||
- 仿真覆盖位于 `src/br_sim_bringup`,实车算法包不依赖 Gazebo。
|
||||
- `r2027_robot_description` 使用原生 SDF、单刚体;默认 planar_move,坡道入口显式选择 contact。
|
||||
contact 仅施加水平力与世界 Z 力矩,重力/接触决定高度与倾斜;不模拟真实轮组牵引与打滑。
|
||||
- 质量 10.31 kg、质心、惯量、雷达安装均为模型假设,不是现场测量结果。
|
||||
- 机器人运动与世界点云由 Gazebo 真值和精确时间 TF 得到,未伪造 Point-LIO 字段。
|
||||
这描述原真值入口;新 scan_lio 入口仅用传感器、Point-LIO 和固定已知起点先验,真值只进独立评价器。
|
||||
- 平地入口 80 cm 车体、9 cm 裕度、0.01 rad 朝向容差;坡道入口单独采用 4 cm 裕度、0.3 m/s 上限。
|
||||
该地图坡道有效净宽 0.975 m,9 cm 无法容纳。不得用仿真配置替换实车安全裕度。
|
||||
- 坡道使用已有 REFERENCE_PATH,Path.z 是地表高度,规划器加 0.15 m 得到车体中心参考。
|
||||
已知通行面只在规划支路过滤;已有 step_blocker 给独立规划话题添加明确先验台阶禁行层。
|
||||
原始雷达与完整世界点云不添加虚拟障碍,未实现任意未知悬崖识别。
|
||||
- 原 SCAN/控制器新增默认关闭的 terrain_motion 分支:仅显式开启时允许矩形参考路径与完整姿态速度转换。
|
||||
实车配置未变,原算法包仍不依赖 Gazebo。Git 现在包含这部分 minco_ws 源码改动。
|
||||
- 包内 ramp.obj 的 8 个面由朝内改为朝外,顶点/尺寸/位姿不变;外部源不动。
|
||||
其余三个导入模型文件继续与来源相同;不能继续宣称当前四文件全部字节一致。
|
||||
- `mid360_sim.launch.py with_lio:=true` 是独立评估入口,暂不启动 SCAN。
|
||||
射线真实每 1 ms 采样,100 ms 打包;扫描图案为明确标注的近似,通道为软件分组。
|
||||
默认 ideal 无注入噪声;可选 mild/stress 径向白噪声、丢点及物理 IMU 白噪声/固定偏置,不模拟材质。
|
||||
IMU 由原生 ImuSensor 求解,姿态标记不可用;内置偏置来自官方手册,整机安装高度仍是假设。
|
||||
- 原 Livox CMake 新增默认 OFF 的 LIVOX_INTERFACES_ONLY;仅在仿真安装前缀设 ON,未安装硬件 SDK。
|
||||
原 Point-LIO 只修改构建依赖(直接 PCL、显式 glog),没有修改滤波器,实车配置不动。
|
||||
源码输入为 /sim/mid360/lidar 与 /sim/mid360/imu;真值只进入独立评价工具。
|
||||
- Point-LIO 输出属于 camera_init、参考点是 IMU 原点;与 base_link 相差 (0.011,0.02329,0.25588) m。
|
||||
不得仅重命名 frame 或 topic 就替换 /body_odom。估计 TF 消息关闭,原 broadcaster 仍创建 /tf 发布端。
|
||||
- 共享 Sim.start 修复模型生成竞态:端口与 clock 就绪后,还必须观察 spawn_entity 成功才允许查询/置位。
|
||||
- 新 `lio_navigation_adapter.py` 将 IMU 原点估计转到车体中心,处理固定 world 对齐与配对去畸变点云,
|
||||
输出独立 `/sim/navigation/*` 与 lio_* TF 帧;不订阅真值/TF、不调用物理查询、不在线重对齐。
|
||||
- 新平地 LIO profile 使用向下 0.50 m 的障碍膨胀,将实际高处回波纳入行驶层;不补造雷达点。
|
||||
此保守配置不适用于坡道或悬空净高。保持 80 cm 车体及 9 cm 安全裕度。
|
||||
- SCAN 新增 manager.min_replan_distance,原默认 0.20 m 不变;仅 LIO profile 设 0.04 m,
|
||||
避免近目标短断流后的恢复死锁;碰撞检查和轨迹授权仍执行。
|
||||
- 共享进程工具使用每轮私有环境标识 BR_SIM_RUN_TOKEN 回收本轮子进程,支持换会话、重新挂接,
|
||||
不按名字批量杀进程;旧 teardown 的瞬时端口采样竞态已通过有界等待修复,旧证据保留。
|
||||
- `scan_lio_terrain.launch.py` 是独立参考路径入口:已知地表仅在规划副本按 6 cm 残差过滤,
|
||||
不抬高估计或点云;4 cm 裕度、80 cm 车体不减,2.5 cm 体素配 10×3×2 m 窗口。
|
||||
原 Point-LIO 仿真专用 profile 将降采样细化到 0.10 m,保留原残差方差;滤波实现和实车参数未变。
|
||||
下游规划云最大年龄 0.20 s,速度上限 0.20 m/s,末段速度下限 0.02 m/s、接近增益 0.3。
|
||||
低于或等于 0.10 m 的障碍可能被过滤,未知悬崖识别仍未实现;不能扩展成全地形通行保证。
|
||||
- 本轮带噪声坡道验证暴露缺少通行面边界先验的问题。仅在 LIO 坡道规划支路增加已知坡边禁行平面,
|
||||
不修改物理碰撞、不伪装雷达回波;采样 0.10 m、共 8484 先验点,pos_deadband=0.005 m。
|
||||
红侧 mild、蓝侧 ideal 各四例重跑通过,新增坡边越界目标拒绝;具体指标见最终验收摘要。
|
||||
- 平地 LIO 的终点朝向容差收紧为 0.02 rad,连续换向后仍按终态源时间检查 0.20 s 制动与 1.1 s 静止。
|
||||
同一个 Point-LIO/地图生命周期、mild 噪声、独立两个 launch 进程连续八段通过;并非全比赛任务。
|
||||
- start_sim:=false 不查询机器人/Gazebo 包,不创建物理进程;实际跨机仍待机器人电脑和网络现场验证。
|
||||
|
||||
## 必须保持的约定
|
||||
|
||||
1. 世界坐标米/秒/弧度,Z 向上;红 +Y、蓝 −Y,坡道下降 +X,不旋转或缩放源地图。
|
||||
2. 本机默认 `GAZEBO_MASTER_URI=http://127.0.0.1:11355`、`ROS_DOMAIN_ID=77`、`ROS_LOCALHOST_ONLY=1`。
|
||||
跨机显式设置 ROS_LOCALHOST_ONLY=0;机器人入口尊重域/本地范围环境变量。
|
||||
3. 只有一个 gzserver;官方 init/factory SystemPlugin 各一次,不使用 ros_gz_bridge。
|
||||
4. world→odom 单位静态;odom→base_link 插件发布;base_link→lidar 静态 z=0.30。
|
||||
5. Odometry pose 属 header.frame_id,twist 属 child_frame_id;不能重命名 frame 冒充坐标变换。
|
||||
6. 节点显式 use_sim_time;机器人入口时钟配置 100 Hz,场地历史基线 10 Hz。
|
||||
7. 暂停时 Classic 不发布新时钟;暂停服务返回成功还需真值和时钟冻结证据。
|
||||
8. 检查时只启动和清理自己的进程。端口占用则退出,不按进程名批量杀其他进程。
|
||||
9. 数据缺失判 INVALID,不把没收到接触当成碰撞失效;构建成功不能代替运行验收。
|
||||
10. 不启动真实串口桥、不改系统驱动;本轮已授权暂存和提交,禁止代用户 push。
|
||||
|
||||
## 历史结论修正
|
||||
|
||||
- 旧 P2 R1 文档曾写 9/9,实际原始 final 为 7 PASS、2 FAIL。Codex 修复固定两秒运动判定、
|
||||
M4/M5 世界系方向与机器人时钟配置后,全部重新实测 9/9,旧证据没有改写。
|
||||
- 旧 Fortress “旋转碰撞失效”推论已撤回:测试订阅晚于首接触,属于采集问题,不能归因引擎。
|
||||
- Classic K02 采集曾被并行测试按名称杀进程干扰;后续工具只清理本轮所有进程。
|
||||
- GUI 旧轮由用户目视确认且用户不要求截图。本轮导航为无界面运行;未重新验收 GUI/RViz。
|
||||
具体 GPU renderer 仍未确认,不能声称排除了软渲染。
|
||||
|
||||
## 旧方案清理
|
||||
|
||||
用户明确授权后,删除 `src/br_gazebo`、旧导出配置和专用探针/导出工具、
|
||||
旧 `build/br_gazebo`、顶层 Fortress 安装入口,以及 Blender 下载/解压副本。
|
||||
释放 1,634,121,119 字节;逐项清单在 `log/codex_p5_20261108/cleanup_manifest.json`。
|
||||
本轮再次复核旧路径并移除过期操作文档、旧顶层构建标记及链接。
|
||||
`docs/archive/fortress/README.md` 只保留退役说明;旧文档备份和原始测试日志留在 Git 忽略的 log/。
|
||||
逐项复核见 `log/codex_release_20261108/cleanup_audit.json`;文内旧工具路径仅为历史引用。
|
||||
|
||||
保留并继续使用当前 Classic/navigation 的 build/install、P1 Classic 和 P2/P3/P4 证据。
|
||||
外部 `/home/kevin/2027RC场地地图/` 与 `/home/kevin/r2027_gazebo_model/` 未作改动。
|
||||
源码、模型、文档、原算法可选分支及构建调整随本轮提交;build/install/log 和缓存不入库。
|
||||
提交哈希以 git log 为准,本轮不执行 push。
|
||||
|
||||
## 收尾状态与后续现场工作
|
||||
|
||||
P5 本次两侧坡道与指定台阶边界子阶段完成,详细限制见 P5_SLOPE.md;不能扩大为任意全场任务通过。
|
||||
最终机读证据为 `log/codex_p5_slope_20261108/acceptance_summary.json`,本轮结束时仿真已停止、端口释放。
|
||||
P6 独立定位基线已完成,最终证据位于 `log/codex_p6_20261108/acceptance_summary.json`。
|
||||
P6 平地估计导航已接通并验证直达、横移、转向、绕障、短断流恢复与定位失效停车,见 P6_NAVIGATION.md。
|
||||
本轮机读索引为 `log/codex_p6_navigation_20261108/acceptance_summary.json`;结束时仿真停止、11355 端口释放。
|
||||
P6 指定坡道导航也已完成;机读索引为 `log/codex_p6_lio_terrain_20261108/acceptance_summary.json`。
|
||||
最终两侧同参数重新实测,非跨轮拼接;实际最小车体空隙 6.97 cm,横向/竖直定位误差最大约 1.94/3.29 cm。
|
||||
本轮已完成本机连续路线、工程噪声/偏置注入、盲区/低障碍测量及双进程拆分,
|
||||
证据摘要随源码保存于 `docs/validation/20261108.json`,说明见 RELEASE_VALIDATION.md。
|
||||
后续需实车尺寸/轮组/雷达安装标定、机器人电脑在线后的真实跨机验收,及完整比赛任务定义。
|
||||
单 MID360 的近地盲区不能靠调参保证消失;需要额外感知或可靠先验后再验收未知低障碍避让。
|
||||
不能直接把平地 LIO 入口用于坡道;使用专用入口及已知地表路径,详见 P6_LIO_TERRAIN.md。
|
||||
完整新入口和复测命令见 P6_NAVIGATION.md;独立定位见 P6_LOCALIZATION.md。
|
||||
硬件驱动默认分支未构建/运行,不宣称实车通过。
|
||||
@@ -0,0 +1,215 @@
|
||||
# 简化全向机器人验收(Codex 接管复测,2026-11-08)
|
||||
|
||||
在已验收的 Classic 完整场地上加入简化全向机器人,验证**车体系 `/cmd_vel` → 实际运动 → 里程计 →
|
||||
停止行为**这条链路。本文原轮次不开导航、不接传感器、不验证爬坡。
|
||||
后续新增可选 `drive:=contact`,默认仍为 planar;坡道验收见 [P5 坡道](P5_SLOPE.md)。
|
||||
|
||||
> **当前结论**:重新运行全部 9 项,**9/9 PASS**,退出码 0。
|
||||
> 证据:`log/codex_p2_20261108/run/p2_001.json`、同目录 `P2_REPORT.md`。
|
||||
> 平移误差 1.1 mm、转角误差 −0.0043 rad;odom 与独立真值按时间配对的最大差
|
||||
> 4.0 mm / 5.7 mrad / 0.0010 m/s,均低于既定阈值。
|
||||
>
|
||||
> **旧结论更正**:此前 R1 文档写 9/9,但 `log/p2_001_r1/final` 实际为 7 PASS、2 FAIL,
|
||||
> 且检查器曾从实际运动响应反推期望值、未正确处理 M4/M5 世界运动方向。本轮恢复固定 2 s
|
||||
> 指令与事先给定的世界系期望位移,以独立真值测量;未降低阈值。机器人入口显式配置
|
||||
> `/clock` 发布率 100 Hz,替代原先 10 Hz 的配置。旧证据保留,不覆盖。
|
||||
|
||||
---
|
||||
|
||||
## 1. 模型
|
||||
|
||||
| 项 | 取值 | 来源 |
|
||||
|---|---|---|
|
||||
| 水平外包络 | **0.800 × 0.800 m** | `planner_vehicle.yaml` 记录的整车最大外包络 |
|
||||
| 车体箱体 | 0.80 × 0.80 × 0.16 m | 外包络即箱体 XY;高度沿用外部模型的 0.16 |
|
||||
| 支撑轮 | 4 × 圆柱 r=0.10 m、宽 0.06 m | 半径沿用外部模型 |
|
||||
| 轮心 | (±0.30, ±0.30, −0.05) m | 轮外缘与箱体边沿齐平,外包络正好 0.80 |
|
||||
| `base_link` | 箱体几何中心,模型原点与它重合 | 任务要求 |
|
||||
| 名义触地面 | base_link 下方 **0.150 m** | = 轮半径 0.10 − 轮心 z(−0.05) |
|
||||
|
||||
模型文件:`src/r2027_robot_description/sdf/r2027_omni_robot.sdf.xacro`(**SDF**,见 §4.1)。
|
||||
|
||||
### 1.1 质量、质心与惯量(R1 修正)
|
||||
|
||||
| 项 | 取值 |
|
||||
|---|---|
|
||||
| 总质量 M | **10.31 kg**(车体 5.51 + 4×1.2) |
|
||||
| 质心(相对 base_link) | **(0, 0, −0.023278370514) m** |
|
||||
| Ixx(绕质心) | **0.757474524410 kg·m²** |
|
||||
| Iyy(绕质心) | **0.768034524410 kg·m²** |
|
||||
| Izz(绕质心) | **1.465173333333 kg·m²** |
|
||||
| 非对角项 | **0** |
|
||||
|
||||
惯性参考系放在组合质心(`<inertial><pose>0 0 com_z 0 0 0</pose>`),张量绕质心、轴向与
|
||||
base_link 平行。**base_link、模型原点、collision、visual、TF 坐标都没有移动**。
|
||||
|
||||
全部由参数算:`com_z = 4·m_w·wheel_z / M`,各体先取自身 COM 惯量再加 `m·|d|²`;
|
||||
z 向偏移只进 Ixx/Iyy(含 dz²),不进 Izz(只含 dx²+dy²)。
|
||||
`log/p2_001_r1/INERTIA_CHECK.md` 是一份**独立核对**:从展开后的 SDF 读几何、从 xacro 读质量,
|
||||
用另一套实现重算,与任务书预期值差 ≤ 4e-13,并比对修改前后的几何签名完全一致。
|
||||
|
||||
> 改前那组(ixx=iyy=0.7630613、izz=1.4651733)是**绕 base_link 原点**的,不是绕质心,
|
||||
> 不能与本表混用。
|
||||
|
||||
质量、惯量仍是**建模假设**:真车质量、重心高度、轮组、雷达位置未确认。本轮只验证平地运动学接口。
|
||||
|
||||
---
|
||||
|
||||
## 2. 接口
|
||||
|
||||
| 接口 | 类型 | 说明 |
|
||||
|---|---|---|
|
||||
| `/cmd_vel` | `geometry_msgs/msg/Twist` | 输入,车体系 vx / vy / wz |
|
||||
| `/sim/cmd_vel` | 同上 | 转发节点独占发布,**插件只订阅它** |
|
||||
| `/odom` | `nav_msgs/msg/Odometry` | pose 属 `odom`、twist 属 `base_link` |
|
||||
| `/tf` | — | `odom → base_link`(插件发布) |
|
||||
| `/tf_static` | — | `world → odom`(静态变换发布) |
|
||||
| `/gazebo/get_entity_state`、`/gazebo/set_entity_state` | 服务 | 独立真值查询/置位 |
|
||||
|
||||
启动:`ros2 launch r2027_robot_description robocon_robot.launch.py gui:=false`
|
||||
|
||||
### 2.1 频率口径(配置值 ≠ 实测值)
|
||||
|
||||
| 项 | 配置 | 实测 |
|
||||
|---|---|---|
|
||||
| `planar_move` 速度更新 `update_rate` | 100 Hz | 未单独统计 |
|
||||
| `/odom` `publish_rate` | 50 Hz | **约 50 Hz**(一次运行 1690 帧 / 约 33.8 s) |
|
||||
| 转发节点发布率 | 100 Hz | 未逐条统计 |
|
||||
| 机器人入口 `/clock` | 100 Hz | 本轮控制协议按仿真时钟运行;暂停冻结已验证 |
|
||||
|
||||
不得把配置值写成实测值,也不得用 `/odom` 的实测频率反推插件内部更新率。
|
||||
|
||||
### 2.2 命令转发(`scripts/cmd_vel_timeout.py`)
|
||||
|
||||
订阅 `/cmd_vel`,发布 `/sim/cmd_vel`,**不存在订阅与发布同一话题的回路**。
|
||||
指令静默超过 **0.5 s 仿真时间**后持续输出零速度;从未收到指令时也一直输出零;
|
||||
正常退出前补发 5 帧零速度。
|
||||
|
||||
---
|
||||
|
||||
## 3. 实测结果
|
||||
|
||||
指令持续 **2.0 s 仿真时间**,每例先置位到出生点 (−4.5, 4.5, 0.17, yaw) 并等落稳。
|
||||
|
||||
| 用例 | 初始 yaw | 指令 | 实测世界位移 | 误差 | 漂移 | 判定 |
|
||||
|---|---|---|---|---|---|---|
|
||||
| M1 前进 | 0 | vx=0.20 | Δ=(**0.3989**, 0.0000) | −0.0011 | 0.0000 | PASS |
|
||||
| M2 横移 | 0 | vy=0.20 | Δ=(0.0000, **0.3989**) | −0.0011 | 0.0000 | PASS |
|
||||
| M3 转向 | 0 | wz=0.30 | Δyaw=**0.5957**,平移 0.0000 | −0.0043 | 0.0000 | PASS |
|
||||
| M4 转向后前进 | π/2 | vx=0.20 | Δ=(0.0000, **0.3989**) | −0.0011 | 0.0000 | PASS |
|
||||
| M5 转向后横移 | π/2 | vy=0.20 | Δ=(**−0.3989**, 0.0000) | +0.0011 | 0.0000 | PASS |
|
||||
|
||||
| 用例 | 内容 | 实测 | 阈值 | 判定 |
|
||||
|---|---|---|---|---|
|
||||
| S1 | 显式零指令停车 | 停稳 **0.012 s**,其后 1 s 位移 0.0000 m | 0.20 s / 0.02 m | PASS |
|
||||
| S2 | 停止发布后超时停车 | 最后指令后 **0.512 s** 停稳 | 0.70 s | PASS |
|
||||
| S3 | 静止暂停/恢复 | 见 §5.1:时钟漂移 0、状态时间戳单一取值、位姿变化 0、恢复后前进 | — | PASS |
|
||||
| T1 | TF / odom | 见 §5.2:发布者唯一、world→odom 单位、TF 与 odom 逐帧一致 | — | PASS |
|
||||
|
||||
**本节历史轮次 odom 与真值**(按 `header.stamp` 配对,配对时间差 ≤ 30 ms):位置差 ≤ 0.0040 m、
|
||||
yaw 差 ≤ 0.0057 rad、水平速度差 ≤ 0.0010 m/s(阈值 0.02 / 0.02 / 0.02)。
|
||||
|
||||
P5 新驱动在加减速时暴露出旧“直接取较早 odom”比较的时间偏差。
|
||||
当前检查器改为用真值时间两侧的 odom 线性插值:不外推,两帧间隔≤30 ms,记录两端时间与插值比例;
|
||||
角度按最短弧插值。位置/角度/速度阈值没有改变,旧日志不回写。
|
||||
contact 和默认 planar 的完整新轮次分别见 P5 坡道证据表。
|
||||
|
||||
**yaw=π/2 时的车体语义**:世界运动方向分别是 +Y 与 −X,而 `/odom.twist` 仍是车体正的 vx / vy
|
||||
(M4 真值车体系 (0.1995, 0),`odom.twist` (0.20, 0.00);M5 真值 (0, 0.1995),`odom.twist` (0.00, 0.20))。
|
||||
|
||||
**出生位姿**:`get_entity_state` 首帧即 (−4.5, 4.5),落稳后 z=0.1490。`/odom` 首帧同样是 (−4.5, 4.5),
|
||||
**没有被归零**——它是 Gazebo 实际位姿,不是指令积分。
|
||||
|
||||
---
|
||||
|
||||
## 4. 两处模型表达改动(P2 提出,R1 保留)
|
||||
|
||||
### 4.1 URDF → SDF:URDF 的接触参数在本机链路上不生效
|
||||
|
||||
第一版用 URDF,轮子上写 `<gazebo reference="..."><mu1>/<mu2>/<kp>/<kd>`,2 s 只走 **0.3138 m**(应 0.40)。
|
||||
两条独立证据:
|
||||
|
||||
1. `gz sdf -p` 转出的 collision **没有 `<surface>`**,`<mu1>` 全部丢失;
|
||||
2. 直接把 μ 从 0.05 改成 **0.0**,实测位移仍是 **0.3137 m**,完全不变。
|
||||
|
||||
说明接触参数没进物理引擎,轮子退回默认 μ=1.0,摩擦每 10 ms 把 planar_move 设定的速度
|
||||
从 0.19 拉到 0.12(锯齿)。改原生 SDF 后同一用例变成 0.3946 m。
|
||||
|
||||
### 4.2 四轮独立 link → 单刚体
|
||||
|
||||
SDF 版第一版把 4 个轮子做成独立 link + fixed joint:平移正常,**转向只走出 0.2236 rad**(应 0.60)。
|
||||
扫描四档角速度:
|
||||
|
||||
| 指令 wz (rad/s) | 实测 Δyaw | 比值 |
|
||||
|---|---|---|
|
||||
| 0.15 | 0.1126 | 0.375 |
|
||||
| 0.30 | 0.2417 | 0.403 |
|
||||
| 0.60 | 0.4636 | 0.386 |
|
||||
| 1.20 | 0.9317 | 0.388 |
|
||||
|
||||
比值恒定、与指令大小无关(不是饱和);把 μ 从 0.05 降到 0.01 只让它从 0.2236 涨到 0.2417(+8%),
|
||||
与地面摩擦不成比例。合并成单刚体后 Δyaw 变成 0.5957。
|
||||
|
||||
**结论要收着说**:以上只说明「在当时的模型与配置下,把 4 个轮子做成独立 link 会观察到转向跟踪
|
||||
只有指令的约 0.39 倍」,**内部机理尚未完全定位**(可能与 4 个 weld 约束和接触求解的耦合有关,未验证)。
|
||||
因此**不能**推广成「独立轮 link 必然只有 0.386 倍」,也不能推断其它机器人或其它引擎会一样。
|
||||
合并成单刚体是**规避**这个现象的选择:几何、质量、惯量(含平行轴项)都保留,只是不再有独立轮 link;
|
||||
任务要求的 TF 只有 `world→odom` 与 `odom→base_link`,本来就不含轮子帧。
|
||||
|
||||
---
|
||||
|
||||
## 5. 判定方式(R1 重写 S3 / T1)
|
||||
|
||||
### 5.1 S3:暂停必须被**观察到**生效
|
||||
|
||||
流程:置位落稳 → 发零 → **暂停服务成功** → 处理一批在途消息(0.35 s 内持续 spin,这批样本丢弃)→
|
||||
建立基准(时钟 + 带时间戳的真值)→ 观察窗口内**持续处理回调**并反复走真值服务,取得 ≥ 2 次
|
||||
**带仿真时间戳**的真实查询 → 恢复 → 观察时间实际前进。
|
||||
|
||||
判据(全过才 PASS):`pause_service_ok`、`samples_min2`、`clock_frozen`(多次读取漂移 < 1e-9)、
|
||||
`state_time_frozen`(所有状态时间戳同一取值)、`pose_frozen`(≤ 1e-6 m/rad)、
|
||||
`resumed`(> 0.3 s)、`resume_state_advances`。
|
||||
服务不可用或带时间戳样本不足 → **INVALID**,不判 PASS;**不使用任何缓存值**。
|
||||
|
||||
实测:暂停 1.20 s 内 4186 次时钟读取漂移 **0.0**,状态时间戳只有 **1 个取值**,
|
||||
位姿变化 **0.0**;恢复后仿真时间前进 0.610 s。
|
||||
|
||||
### 5.2 T1:唯一性只由 **ROS 发布端信息** 判定
|
||||
|
||||
保留每条 TF 的 `frame_id`、`child_frame_id`、`header.stamp`、平移与旋转四元数(原始样本落盘)。
|
||||
唯一性用 `ros2 topic info <topic> -v` 的 **PUBLISHER** 段节点名判定,
|
||||
**不再用「数据里字典键只有一个」这种数据侧计数冒充发布者唯一**。
|
||||
|
||||
判据:`/tf` 只有一个发布者、`/tf_static` 只有一个发布者、两者不同、
|
||||
`/tf` 的发布者与 `/odom` 的发布者是同一个、边界各只有一条、没有边同时出现在两个话题、
|
||||
`world→odom` 为单位变换(平移与旋转误差均为 0)、TF 与 `/odom` 逐帧一致(≤ 1e-6)、
|
||||
odom 帧名正确、时间单调。
|
||||
|
||||
实测:`/tf` 发布者 `['planar_move']`、`/tf_static` 发布者 `['world_to_odom']`、
|
||||
`/odom` 发布者 `['planar_move']`;边 `{odom->base_link}` / `{world->odom}`;
|
||||
`world→odom` 平移与旋转误差均 0;TF-odom 配对 1648 条,最大差 0.0 m / 0.0 rad。
|
||||
|
||||
这些 TF 发布者数量适用于 `lidar:=false` 的 P2 运行。P3 增加一个静态发布者
|
||||
`base_to_lidar`,发布独立的 `base_link→lidar` 边;不应再按“静态发布者必须只有一个”验收 P3。
|
||||
|
||||
---
|
||||
|
||||
## 6. 两个定向反例(旧 R1 记录,本轮未重跑)
|
||||
|
||||
| 反例 | 构造 | 预期 | 实测 |
|
||||
|---|---|---|---|
|
||||
| S3-NEG | 暂停服务照常调用、返回 success,随即恢复(世界实际未暂停),其余流程不变 | S3 不得 PASS | **FAIL**,退出码 30:时钟漂移 1.2、状态时间戳出现 1195 个取值 |
|
||||
| T1-NEG | 测试进程内临时起一个节点,额外发布一份 `world→odom`(静态) | T1 必须拒绝 | **FAIL**,退出码 30:`/tf_static` 发布者变成 `['world_to_odom', 't1_negative_dup_tf']` |
|
||||
|
||||
S3 反例**没有靠开关判死**:`pause_service_ok` 在反例里仍为 True,是时钟/状态时间戳的观察把它判掉的。
|
||||
两个反例都**只使用本轮创建的节点**,判定后立即 destroy;生产运行不含反例,
|
||||
所以「反例预期失败」不计入生产用例失败(反例的 JSON 里 `negative_run=true`)。
|
||||
|
||||
---
|
||||
|
||||
## 7. 边界
|
||||
|
||||
- 只验证**平地**运动接口;不评价坡道动力学、爬坡、越障、制动距离。
|
||||
- 轮子是圆柱固定支撑件,**没有辊子各向异性摩擦**,不代表麦轮真实接触;不模拟轮子滚动。
|
||||
- 质量/惯量是建模假设(质心位置由参数算得,不是实测重心)。
|
||||
- 本节 P2 结果不包含传感器或导航;新链路另见 `P3_P4_NAVIGATION.md`。
|
||||
@@ -0,0 +1,169 @@
|
||||
# 三维点云与 SCAN 真值导航(2026-11-08)
|
||||
|
||||
用户已授权 Codex 直接实现、构建和运行。本轮仍使用完整比赛场地与 Gazebo Classic,
|
||||
不启动真实雷达、Point-LIO、串口桥。算法来自原有 `minco_ws/src/scan`,没有复制第二套实现。
|
||||
|
||||
本文件描述原真值导航入口;后续 MID360/Point-LIO 平地闭环已建立独立入口,见 [P6_NAVIGATION.md](P6_NAVIGATION.md)。
|
||||
|
||||
## 当前验收
|
||||
|
||||
- P2:`log/codex_p2_20261108/run/p2_001.json`,完整 9/9 PASS。
|
||||
- P3:`log/codex_p3_20261108/run/result.json`,yaw=0、π/2 两组各 13 项 PASS。
|
||||
每组配对 8 帧,约 10 Hz;有效点 7624/7637。独立 Gazebo 真值与点云变换最大误差
|
||||
0.000000391/0.000000375 m。地面、北围栏、西围栏均在已知世界坐标上,不只检查 frame_id。
|
||||
证据含原始、世界系、独立计算点坐标的 `.npz`。
|
||||
- P4 平地真值闭环:`log/codex_p4_20261108/arrival_r3/result.json`,四条路线 **4/4 PASS**、退出码 0。
|
||||
无界面实际运行,未要求截图;完整真值轨迹、命令、状态与局部点云诊断保存在同目录各用例 JSON。
|
||||
|
||||
| 路线 | 世界系目标 (x,y,yaw) | 终点位置误差 | 结果 |
|
||||
|---|---|---|---|
|
||||
| 直达 | (−3.6,4.5,0) | 0.05890 m | PASS |
|
||||
| 保持朝向横移 | (−3.6,3.5,0) | 0.05906 m | PASS,观察到 vy 指令 |
|
||||
| 返回并对齐朝向 | (−4.5,4.5,π/2) | 0.05871 m | PASS |
|
||||
| 绕障 | (−4.5,1.5,π/2) | 0.05889 m | PASS,最小保守车体间隙 0.14883 m |
|
||||
|
||||
每例要求本次目标被确认、经历 ACTIVE、最终 SUCCEEDED,并由独立 Gazebo 真值确认误差<0.10 m、
|
||||
朝向误差<0.10 rad,以及停止后连续 1.1 s 速度<0.01 m/s、漂移<0.02 m。测试过程不主动补发零速度。
|
||||
绕障仅在运行时插入一个静态 0.25×0.25×0.60 m 测试箱,中心 (−4.6,3.0,0.3),
|
||||
原比赛场地文件不变;间隙按含实际 yaw 的 0.8 m 方形车体包围盒独立计算。
|
||||
|
||||
保留失败诊断:`straight/`、`full_r1/`、`diagnostic/` 为过滤车体前的失败;
|
||||
`self_filter_r2/` 已能到点,但规划器任务完成/控制器停车窗口同为 8 cm,在实际回调采样中未正常结项。
|
||||
采用控制器 6 cm、规划器 8 cm 的嵌套阈值及稳定出生高度后,四例均完成。
|
||||
没有降低物理到达判据,也没有把 FAILED 改写为 PASS。
|
||||
|
||||
数据中断停车:`log/codex_p4_20261108/data_loss/result.json`,**PASS**、退出码 0。
|
||||
车辆运动中只对本轮自己创建的数据适配进程 SIGSTOP,不注入停车指令;就绪信号撤销,
|
||||
独立真值测得 0.240 s 仿真时间内停稳,后续漂移约 5×10⁻¹⁴ m,保持静止;随后 SIGCONT 恢复进程并清理。
|
||||
该轮保存采集工具启动时的 SHA256 与源码快照。各次测试结束后均确认 11355 端口释放,未杀其他进程。
|
||||
|
||||
P3 当前为通用瞬时三维射线雷达:CPU `ray`,720×32,水平 360°、垂直 ±30°,
|
||||
0.15–20 m、10 Hz;位于 `base_link` 上方 0.30 m,姿态相同。
|
||||
这是仿真安装假设,尚未代表实际雷达型号与安装外参。没有扫描畸变、IMU、ring 或逐点时间字段,
|
||||
不满足 Point-LIO 验收条件。CPU 射线不依赖 GPU 雷达渲染,图形设备未确认仍不阻塞本轮。
|
||||
|
||||
## 接口和参考点
|
||||
|
||||
单位 m/s/rad,右手系 Z 向上;地图保持原始世界坐标(红 +Y,蓝 −Y)。
|
||||
机器人根与 `base_link` 同为箱体中心,落稳 z≈0.148987 m,平地 z=0。
|
||||
|
||||
| 话题 | 类型 | 语义 |
|
||||
|---|---|---|
|
||||
| `/lidar/points` | `sensor_msgs/msg/PointCloud2` | lidar 系;XYZ、intensity;真实传感器仿真时间戳 |
|
||||
| `/cloud_registered` | 同上 | world 系,按原始时间戳查 TF 后变换;保留其他字段与时间戳 |
|
||||
| `/cloud_registered_for_scan` | 同上 | 世界点云的导航支路;近零地面和车体自身回波的 XYZ 置 NaN,其他点不变 |
|
||||
| `/odom` | `nav_msgs/msg/Odometry` | Gazebo 插件真值;pose 属 odom,twist 属 base_link |
|
||||
| `/body_odom` | 同上 | world 系箱体中心 pose,base_link 系 twist |
|
||||
| `/aft_mapped_to_init` | 同上 | world 系雷达 pose,lidar 系 twist;由真值与安装变换计算 |
|
||||
| `/move_base_simple/goal` | `geometry_msgs/msg/PoseStamped` | world 系目标位置与有效目标四元数 |
|
||||
| `/cmd_vel` | `geometry_msgs/msg/Twist` | 现有闭环控制器输出,车体系 vx/vy/wz |
|
||||
| `/sim/cmd_vel` | 同上 | 超时保护节点独占发布,插件只订阅此话题 |
|
||||
| `/planning/perception_ready` | `std_msgs/msg/Bool` | 根据真实新鲜数据持续发布,失效时停止放行 |
|
||||
|
||||
TF:`world→odom` 单位静态,`odom→base_link` 由唯一运动插件动态发布,
|
||||
`base_link→lidar` 静态 (0,0,0.30),无重复边。
|
||||
适配器确认 world→odom 确实为单位变换后才生成世界里程计;改变该契约会拒绝样本。
|
||||
雷达原始 stamp 不可用时等待精确时间 TF,超过 2 s 丢弃并告警;不回退到最新 TF。
|
||||
|
||||
所有新节点和规划控制节点明确 `use_sim_time=true`;机器人入口配置 `/clock` 100 Hz,
|
||||
`/odom` 50 Hz,适配器继承其时间戳。场地单独入口保留旧基线时钟配置。
|
||||
数据就绪要求车体/雷达里程计年龄≤0.20 s、云年龄≤0.25 s(仿真时间),且消息帧与数值有效。
|
||||
就绪指地图输入流可用,不表示台阶识别或 Point-LIO 已就绪。
|
||||
|
||||
## 导航选择与边界
|
||||
|
||||
使用现有矩形模式:0.80×0.80 m 车体,单边裕度 0.09 m,任务开始朝向保持,
|
||||
到达后由现有转向安全检查决定是否允许目标朝向旋转。该模式正确将车体系速度旋转到世界系,
|
||||
也允许保持车头横移。源码的默认圆形分支未做这项速度转换,本轮没有修改实车算法或启用该分支。
|
||||
后续 P5 把仿真行驶朝向容差从 0.035 收紧到 0.01 rad;车体尺寸和 9 cm 裕度不变。
|
||||
窄通道结果、采用理由及回归状态见 [P5 说明](P5_NARROW.md)。
|
||||
P5 平地参数已全量重跑四条 P4 路线,4/4 PASS;证据在
|
||||
`log/codex_p5_20261108/p4_regression/result.json`。
|
||||
|
||||
`br_sim_bringup/config/scan_sim.yaml` 在原实车配置之后覆盖仿真时间、参考高度、
|
||||
地图下界 −0.1 m 和矩形模式。真实雷达/实车参数文件保持原样,实车包不依赖 Gazebo。
|
||||
|
||||
导航支路按完全相同的 stamp 和点索引配对原始/世界点云,以原始 lidar 系坐标移除车体包围盒回波:
|
||||
`|x|,|y|≤0.42`、`−0.47≤z≤−0.20` m(安装偏移 0.30 m,车体 z∈[−0.15,0.08],2 cm 数值裕度)。
|
||||
不使用最新位姿近似自过滤,未配对的样本不放行;原始/完整世界云不变。
|
||||
地面过滤为世界 z≤0.015 m,不增加虚构障碍或补造感知字段。外围 4 cm 矮围栏仍有回波保留。
|
||||
控制器停车窗收紧到 0.06 m,位于原规划器 0.08 m 完成窗内,给不同节点的里程计回调留余量。
|
||||
导航入口出生 z=0.15 m,避免首次里程计仍在从 0.17 m 下落时被规划器锁作手动目标高度。
|
||||
**本入口限制平地**:`scan_sim.launch.py` 没有坡面通行处理;不要向台阶或坡面下发目标。
|
||||
后续坡道专用入口、已知地形先验、参考路径高度与接触驱动见 [P5 坡道](P5_SLOPE.md)。
|
||||
坡道工作对原 SCAN/控制器新增默认关闭的 `terrain_motion` 分支;本文平地入口保持原默认行为。
|
||||
质量、轮组和雷达安装仍为简化模型假设;真值闭环通过不等于 Point-LIO 通过。
|
||||
P6 已另建 MID360 兼容传感器与原 Point-LIO 的独立评估入口,见 [P6 定位说明](P6_LOCALIZATION.md);
|
||||
本文导航入口仍使用真值,没有自动切换定位源。
|
||||
|
||||
## 从仓库根目录构建
|
||||
|
||||
```bash
|
||||
source /opt/ros/humble/setup.bash
|
||||
# P6 新增传感器使用原 Livox 消息;只生成接口,不构建硬件 SDK/驱动。
|
||||
PATH=/usr/bin:$PATH colcon --log-base sim_ws/log/interfaces_build build \
|
||||
--base-paths minco_ws/src/perception/livox_ros_driver2 --packages-select livox_ros_driver2 \
|
||||
--build-base sim_ws/build/localization --install-base sim_ws/install/localization \
|
||||
--cmake-args -DLIVOX_INTERFACES_ONLY=ON -DPython3_EXECUTABLE=/usr/bin/python3 -DBUILD_TESTING=OFF
|
||||
source sim_ws/install/localization/setup.bash
|
||||
PATH=/usr/bin:$PATH colcon --log-base sim_ws/log/navigation_build build \
|
||||
--base-paths minco_ws/src/scan --packages-up-to scan_planner step_blocker \
|
||||
--build-base sim_ws/build/navigation --install-base sim_ws/install/navigation \
|
||||
--parallel-workers 2 --cmake-args -DPython3_EXECUTABLE=/usr/bin/python3 \
|
||||
-DBUILD_TESTING=OFF -DCMAKE_BUILD_TYPE=Release
|
||||
source sim_ws/install/navigation/setup.bash
|
||||
PATH=/usr/bin:$PATH colcon --log-base sim_ws/log/sim_build build \
|
||||
--base-paths sim_ws/src --packages-select robocon_gazebo r2027_robot_description br_sim_bringup \
|
||||
--build-base sim_ws/build/classic --install-base sim_ws/install/classic \
|
||||
--symlink-install --cmake-args -DPython3_EXECUTABLE=/usr/bin/python3 -DBUILD_TESTING=OFF
|
||||
```
|
||||
|
||||
本轮构建证据:`log/codex_navigation_build/` 与 `log/codex_bringup_build/`。
|
||||
|
||||
## 启动与复测
|
||||
|
||||
终端必须使用同一个 ROS 域。先关闭自己先前启动的仿真,确保 11355 未占用;
|
||||
不要和真实机器人程序或另一个仿真同时运行。
|
||||
|
||||
```bash
|
||||
source /opt/ros/humble/setup.bash
|
||||
source /home/kevin/RC2027_BR_code/sim_ws/install/classic/setup.bash
|
||||
export ROS_DOMAIN_ID=77 ROS_LOCALHOST_ONLY=1
|
||||
export GAZEBO_MASTER_URI=http://127.0.0.1:11355
|
||||
ros2 launch br_sim_bringup scan_sim.launch.py # gui:=false 可无界面
|
||||
```
|
||||
|
||||
另开终端,重复 source 和 ROS 域设置后,可先下发已验证的平地目标:
|
||||
|
||||
```bash
|
||||
ros2 topic pub --once /move_base_simple/goal geometry_msgs/msg/PoseStamped \
|
||||
'{header: {frame_id: world}, pose: {position: {x: -3.6, y: 4.5, z: 0.15}, orientation: {w: 1.0}}}'
|
||||
```
|
||||
|
||||
如需 RViz,复用仓库现有配置;其中目标工具原配置为 `/goal_pose`,必须显式重映射:
|
||||
|
||||
```bash
|
||||
ros2 run rviz2 rviz2 \
|
||||
-d /home/kevin/RC2027_BR_code/minco_ws/src/scan/plan_manage/rviz/vehicle.rviz \
|
||||
--ros-args -p use_sim_time:=true -r /goal_pose:=/move_base_simple/goal
|
||||
```
|
||||
|
||||
RViz 固定坐标系为 world,在平地区域用 2D Goal Pose 下目标与朝向。
|
||||
本轮运行证据来自无界面测试,未重新验收新入口的 GUI/RViz 画面。
|
||||
|
||||
仅机器人和传感器、不启动导航:
|
||||
|
||||
```bash
|
||||
ros2 launch r2027_robot_description robocon_robot.launch.py lidar:=true
|
||||
```
|
||||
|
||||
以下验收工具自己起停仿真,不能与上面的 launch 同时运行;输出目录用新的名称,勿覆盖历史证据。
|
||||
|
||||
```bash
|
||||
/usr/bin/python3 sim_ws/tools/check_sim_lidar.py --out sim_ws/log/p3_manual
|
||||
/usr/bin/python3 sim_ws/tools/check_scan_navigation.py --out sim_ws/log/p4_manual
|
||||
/usr/bin/python3 sim_ws/tools/check_scan_navigation.py --out sim_ws/log/p4_data_loss_manual --fault-only
|
||||
```
|
||||
|
||||
退出码 0=通过,30=有效失败,40=采集或前置条件无效。工具只收尾自己创建的进程;
|
||||
不要求截图。导航检查用独立 Gazebo 真值判定到达、停车和绕障间隙,不能仅靠规划器自报成功。
|
||||
@@ -0,0 +1,90 @@
|
||||
# P5 窄通道与地形边界(2026-11-08)
|
||||
|
||||
本文记录完整比赛场地中的平地导航扩展;后续坡道工作另见 [P5 坡道](P5_SLOPE.md)。
|
||||
本文中的拒绝测试仍使用平地入口,不代表坡道入口拒绝同一路线。全场通行性尚未验收。
|
||||
继续使用同一份 SCAN/闭环控制实现、80 cm 方形简化车体、Gazebo Classic 和真值定位。
|
||||
|
||||
## 修正与理由
|
||||
|
||||
1.20 m 临时通道初测不能通过。采集到的实际膨胀地图表明:通道两条中心体素列
|
||||
(x=−4.525、−4.475 m)均被占用,车辆没有进入。保留证据在
|
||||
`log/codex_p5_20261108/diag_margin_09/`,退出码 30;首轮采集工具在无穿越样本时抛异常,
|
||||
记为 INVALID(`run/`,退出码 40),后续修正为有效 FAIL,未改写旧数据。
|
||||
|
||||
原因是原配置允许 0.035 rad 朝向偏差,矩形地图在 9 cm 显式裕度外还增加角点运动包络和
|
||||
完整 5 cm 体素覆盖。单靠 0.80+2×0.09=0.98 m 估算通道要求会遗漏这些项。
|
||||
|
||||
**当前决定**:物理尺寸与单边 9 cm 裕度不变,仿真配置的行驶朝向容差收紧为
|
||||
0.01 rad(约 0.57°)。角点包络按实际允许偏差缩小;没有删除墙体、缩小车体或改动算法碰撞检查。
|
||||
这是基于真值定位和当前控制能力的仿真配置,不直接替换实车的容差。
|
||||
|
||||
## 场景和判据
|
||||
|
||||
测试在原场地西侧平地临时生成两面静态墙,各厚 0.10 m、长 1.50 m、高 0.60 m,
|
||||
y∈[2.5,4.0],通道中心 x=−4.5 m。每例全新启动、结束清理,原地图文件不变。
|
||||
墙的运行时模型位姿由 GetEntityState 查询,中心距减去两半墙厚得到净宽,与指定宽度误差≤1 µm。
|
||||
|
||||
- 可通行例:从 (−4.5,4.5) 到 (−4.5,1.8),完整穿越后到点停车。
|
||||
要求本次任务 ACTIVE→SUCCEEDED、真值位置误差<0.10 m、到点后持续静止;
|
||||
全程按实际 yaw 的方形车体包围盒计算墙间隙,要求≥0.03 m。
|
||||
- 过窄例:净宽 0.95 m,目标在通道内 (−4.5,3.25),小于物理宽度加两侧 9 cm 裕度。
|
||||
要求本次目标得到确认后 FAILED、从未 ACTIVE、命令始终为零、真值漂移<0.02 m,
|
||||
且感知仍新鲜,排除因无数据而假拒绝。
|
||||
- 台阶目标:(−2.5,3.5);所测坡道入口目标:(2.0,3.5),该例从 (2.2,4.65) 出生。
|
||||
同样要求在新鲜感知下拒绝并静止。这只确认所测目标,非全场地形防护或坡道通行验收。
|
||||
|
||||
全部采用独立 Gazebo 真值;不靠控制器里程计自证运动,不注入零指令帮助停车。
|
||||
参考点仍为箱体中心 base_link;单位 m/s/rad,world 坐标与时间约定同 P3/P4。
|
||||
|
||||
## 已取得证据
|
||||
|
||||
`log/codex_p5_20261108/heading_r1/`:四例 4/4 PASS,退出码 0。
|
||||
|
||||
| 用例 | 结果 | 实测 |
|
||||
|---|---|---|
|
||||
| 1.20 m 通道,yaw=0 | PASS | 最小墙间隙 0.2000 m,终点误差 0.05870 m,11.85 s 仿真时间完成 |
|
||||
| 0.95 m 通道 | PASS(按预期拒绝) | 新鲜感知、零命令、原目标保留、车辆保持静止 |
|
||||
| 台阶目标 | PASS(按预期拒绝) | 新鲜感知、零命令、原目标保留、车辆保持静止 |
|
||||
| 所测坡道入口目标 | PASS(按预期拒绝) | 新鲜感知、零命令、原目标保留、车辆保持静止 |
|
||||
|
||||
该通道 yaw=0 运行的最大朝向误差约 1.2×10⁻¹⁴ rad,观察到车体系 vy 指令最大 0.4 m/s。
|
||||
车头转 90° 的同通道测试也已通过,退出码 0,证据在 `log/codex_p5_20261108/yaw90/`。
|
||||
最小墙间隙 0.1999985 m、终点误差 0.05935 m、最大朝向误差 0.00000368 rad,
|
||||
观察到车体系 vx 指令最大约 0.50 m/s。两种朝向均通过,不宣称任意斜角入通道已验证。
|
||||
汇总 `log/codex_p5_20261108/summary.json` 逐项引用真实数据源,共 **5/5 PASS**。
|
||||
原 P4 四条路线已使用当前配置完整重新实测 **4/4 PASS**、退出码 0:
|
||||
`log/codex_p5_20261108/p4_regression/result.json`。位置误差为 0.05838、0.05914、
|
||||
0.05915、0.05892 m,绕障最小保守间隙 0.16121 m;不是沿用旧配置结果。
|
||||
各轮均只清理本轮进程,结束后 11355 端口释放。
|
||||
|
||||
原始数据包含逐例 JSON、wall SDF、运行时墙位姿、点云/地图 `.npz`、进程日志和清理结果。
|
||||
没有补拍截图。当前测试依赖瞬时射线雷达和真值定位,不代表 Point-LIO 定位性能。
|
||||
|
||||
## 复现
|
||||
|
||||
```bash
|
||||
source /opt/ros/humble/setup.bash
|
||||
source /home/kevin/RC2027_BR_code/sim_ws/install/classic/setup.bash
|
||||
cd /home/kevin/RC2027_BR_code
|
||||
/usr/bin/python3 sim_ws/tools/check_narrow_navigation.py --out sim_ws/log/p5_manual
|
||||
```
|
||||
|
||||
工具自己起停仿真,不能与手动 launch 同时运行。可用 `--case` 单独选择用例,
|
||||
例如 `--case corridor_120_yaw90`。退出码 0/30/40 分别表示通过/有效失败/采集无效。
|
||||
|
||||
## 本轮清理
|
||||
|
||||
按用户授权删除旧 Fortress 包、导出配置、18 个专用脚本、旧 build/install 入口、
|
||||
Blender 下载和解压副本,合计 1,634,121,119 字节(约 1.63 GB)。
|
||||
历史说明移至 `docs/archive/fortress`;原始外部资源、旧测量日志与当前 Classic 数据保留。
|
||||
逐项清单见 `log/codex_p5_20261108/cleanup_manifest.json`。
|
||||
清理后场地 assets 验证退出码 0,只有三个当前仿真包参与 colcon 枚举,
|
||||
并已用清理后的安装树完成上述运行测试。
|
||||
|
||||
## 后续进展
|
||||
|
||||
P5 平地窄通道子阶段完成。后续已新增可选 contact 驱动、地表高度参考路径与已知通行面配置,
|
||||
使用独立 `scan_terrain.launch.py`,详细验收见 [P5 坡道](P5_SLOPE.md)。
|
||||
默认平地入口仍为 planar_move、9 cm 裕度;坡道专用入口为 4 cm 裕度,不能混用验收结论。
|
||||
精细轮组模型仍后置。
|
||||
Point-LIO 阶段另外需要真实语义的 IMU、逐点采样时间及雷达模型适配,不伪造字段绕过接口。
|
||||
@@ -0,0 +1,180 @@
|
||||
# P5 坡道:接触物理与 SCAN 闭环(2026-11-08)
|
||||
|
||||
本阶段验证完整 Classic 场地上的红、蓝坡道与顶部落脚区;复用原有 SCAN 和闭环控制器。
|
||||
定位仍为 Gazebo 真值,雷达仍为通用三维瞬时射线模型。MID360、IMU、逐点时间与 Point-LIO
|
||||
属于后续 P6,本阶段没有用伪造字段绕过它们。
|
||||
|
||||
## 地图修复
|
||||
|
||||
坡道宽 1 m、水平长 3.5 m、高 0.597 m,世界 X 从 −0.8 到 2.7;
|
||||
红侧 Y∈[3,4],蓝侧 Y∈[−4,−3],坡度 atan(0.597/3.5)≈0.16894 rad。
|
||||
箱体中心 base_link 为参考点;平地落稳 Z≈0.148987 m,顶部落脚区表面 Z=0.600 m。
|
||||
|
||||
原 `ramp.obj` 的 8 个三角面全部朝内,有向体积 −1.04475 m³。
|
||||
在同一驱动下原圆柱支撑进坡失败,改球形支撑也失败;仅反转网格面索引后,原圆柱支撑完成
|
||||
上坡、坡中停车、顶部落脚和下坡。这是几何 A/B 证据,不归因为 Gazebo 的旋转碰撞缺陷。
|
||||
|
||||
生产修复只反转面索引,6 个顶点、尺寸、位姿不变,前后均闭合,体积变为 +1.04475 m³。
|
||||
未改外部 `/home/kevin/r2027_gazebo_model/`;其余三个导入模型文件继续与来源字节一致。
|
||||
来源和哈希见 `src/robocon_gazebo/SOURCE_PROVENANCE.md`。
|
||||
`tools/repair_ramp_winding.py` 只接受固定来源哈希;资源检查独立核对坐标不变、面恰好反向、
|
||||
边闭合与正体积,禁止把其他任意修改当作相同修复。
|
||||
|
||||
## 运动与算法选择
|
||||
|
||||
默认 `scan_sim.launch.py` 和机器人默认 `drive:=planar` 保持平地行为。
|
||||
新 `scan_terrain.launch.py` 显式选择 `drive:=contact`,加载 `libbr_contact_drive.so`:
|
||||
|
||||
- 仅施加世界水平力和绕世界 Z 的力矩,不设定位姿或速度;Z、roll、pitch 由重力和真实接触求解。
|
||||
- 用实际接触法线计算坡面上的水平驱动力;没有向上的支撑接触时不施力,不提供空中推进。
|
||||
- 是理想全向执行器,包含坡面重力补偿。不是轮组牵引、打滑、滚动、接触摩擦真实性验收。
|
||||
- 原四个圆柱支撑、单刚体、质量 10.31 kg、质心和惯量不变,均仍为模型假设。
|
||||
- `/cmd_vel` 与 `/sim/cmd_vel` 均为 `geometry_msgs/msg/Twist`,vx、vy 属车体系;
|
||||
wz 在此简化驱动中控制世界竖直轴转向。坡道测试保持 yaw=0,不宣称任意倾斜姿态转向已验证。
|
||||
- 原命令保护仍唯一发布 `/sim/cmd_vel`;驱动内部另有 0.5 s 仿真时间超时。
|
||||
`/odom` 是完整真值姿态,pose 属 odom、twist 属 base_link;唯一发布 odom→base_link。
|
||||
- `/sim/drive_contacts` 为 `gazebo_msgs/msg/ContactsState`,来自实际求解器;
|
||||
`/sim/drive_wrench` 为 `geometry_msgs/msg/WrenchStamped`,世界坐标,记录实际施加的驱动力矩。
|
||||
|
||||
原 SCAN 矩形模式曾只允许手动平面目标;现在仅当显式开启 `fsm.terrain_motion=true` 时,
|
||||
允许已有 REFERENCE_PATH 模式,仍强制控制器反馈与感知就绪。
|
||||
规划器和控制器在该模式下用完整四元数转换车体速度,控制器反解车体 XY 在世界水平面的投影;
|
||||
倾翻或投影接近奇异时停车。新增参数默认 false,实车参数文件没有改动,算法包不依赖 Gazebo。
|
||||
这几处可选改动位于原 `minco_ws/src/scan/plan_manage`,没有复制第二套算法。
|
||||
|
||||
## 路径、通行面与禁行层
|
||||
|
||||
坡道入口使用 `/initial_path`,类型 `nav_msgs/msg/Path`,frame 为 world,单位米。
|
||||
**路径 Z 是已知地表高度**,由现有参考路径逻辑加 0.15 m 得到 base_link 参考高度。
|
||||
当前不使用 2D Goal Pose;导航入口不会自动发路径或开车。
|
||||
|
||||
`terrain_sim.yaml` 显式配置已知坡面和 0.6 m 平台平面。
|
||||
只在规划支路把这些面上 1.5 cm 内的回波置 NaN;完整 `/cloud_registered` 与原始 `/lidar/points`
|
||||
保持真实射线结果,不抬高真值里程计,也不把台阶当作可通行面。
|
||||
|
||||
复用现有 `step_blocker`,把已知阶梯下降区 X∈[−2.7,−1.8]、两侧坡道 Y 范围声明为禁行区域。
|
||||
输出独立规划话题 `/sim/terrain_planning_cloud`,包含明确的先验禁行墙,**不是模拟雷达回波**。
|
||||
这是本地图上的已知约束,尚未实现任意未知悬崖/台阶识别。
|
||||
就绪门控同时要求该规划话题年龄≤0.3 s;该节点停止输出不能继续沿用旧就绪状态。
|
||||
|
||||
坡道与 25 mm 围栏外伸之间的有效宽度为 0.975 m。
|
||||
平地的 0.80+2×0.09=0.98 m 已超过它,且尚有角点与体素保护,因此不能沿用 9 cm 显式裕度。
|
||||
本入口单独采用 4 cm 单边显式裕度、0.01 rad 朝向容差、0.3 m/s 上限;平地仍为 9 cm。
|
||||
默认红侧中心 Y=3.5125 m,蓝侧 Y=−3.5125 m;名义车体两边最小空隙各 8.75 cm。
|
||||
这是低速真值模型的专用配置,不能据此缩小实车安全裕度。
|
||||
|
||||
坐标与时间不变:米/秒/弧度、Z 向上;world→odom 为单位静态,base_link→lidar 为 Z=0.30 m。
|
||||
各节点显式使用仿真时间,机器人入口 `/clock` 配置 100 Hz、odom 配置 50 Hz。
|
||||
|
||||
## 验收证据
|
||||
|
||||
本轮原始数据根目录:`log/codex_p5_slope_20261108/`。
|
||||
运行批次与退出码记录在 `remaining_checks.json`;每例保留真值、命令、任务状态与进程清理结果。
|
||||
最终 `acceptance_summary.json` 校验各组报告、证据哈希、源码/插件哈希和进程清理;
|
||||
`final_build.log` 记录三个仿真包完成,`assets_final.log` 记录最终安装资源检查通过。
|
||||
|
||||
| 检查 | 证据路径(相对上述根目录) | 实测结果 |
|
||||
|---|---|---|
|
||||
| contact 驱动平地接口 | `flat_r2/p2_001.json` | 9/9 PASS;2 s 前进 0.3945 m、横移 0.3947 m、转向 0.5785 rad;显式停稳 0.086 s、停发超时停稳 0.586 s |
|
||||
| 默认 planar 底盘回归 | `planar_regression/p2_001.json` | 全部重新实测 9/9 PASS;显式/超时停稳 0.012 / 0.512 s |
|
||||
| 生产地图重力与坡道物理 | `physical_production/result.json` | 自由落体 3 项、上下坡 10 项全部 PASS;不是只跑隔离副本 |
|
||||
| 两侧坡道球体接触回归 | `contact_regression_r3/contacts/contacts.json` | K05/K06 2/2 新实测 PASS,未重跑其余六个 P1 接触例 |
|
||||
| 红侧上坡、下坡 | `red_round_trip/result.json` | 2/2 PASS;XY 误差 0.058650 / 0.058488 m |
|
||||
| 蓝侧上坡、下坡 | `blue_round_trip/result.json` | 2/2 PASS;XY 误差 0.058874 / 0.058858 m |
|
||||
| 两侧台阶禁行 | `red_stairs/result.json`、`blue_stairs/result.json` | 2/2 PASS;感知新鲜、原目标保留、从未 ACTIVE、零命令与真值静止 |
|
||||
| 默认平地导航回归 | `flat_regression/result.json` | 四条路线全部重新运行,4/4 PASS;不是沿用旧日志 |
|
||||
| 相关原算法单元检查 | `unit_tests.log` | footprint、terrain_velocity、goal_execution_utils、reference_path_utils 四个目标通过 |
|
||||
|
||||
以上四次坡道到点后的观察窗口漂移均近零;按真实姿态、包含全部车体的保守局部盒
|
||||
X/Y∈[−0.4,0.4]、Z∈[−0.15,0.15] 投影到世界 Y,距围栏外侧/坡边的最小间隙为
|
||||
红上 0.085347 m、红下 0.085545 m、蓝上 0.085632 m、蓝下 0.085607 m。
|
||||
这包含箱体和圆柱支撑,且比实际上半部更保守;不是仅用中心线偏差估计间隙。
|
||||
离线计算保留在 `derive_clearance.py`、`derived_clearance.json`,记录输入原始 JSON 的 SHA256,
|
||||
不改写导航采集结果。
|
||||
|
||||
生产物理复测:自由落体加速度 −9.8000 m/s²;坡中高度误差最大 0.001143 m、
|
||||
俯仰误差最大 0.0000133 rad;坡中停车后半窗口速度最大 0.0000536 m/s、漂移 0 m。
|
||||
最大真实接触穿透 0.001029 m;倾斜时点云到已知坡面的最大距离 0.001871 m。
|
||||
命令存在但未触地时驱动力为零;全程驱动力 Z 和力矩 X/Y 为零。
|
||||
全部串行运行,结束后 11355 端口释放;`remaining_checks.json` 的七个任务均退出 0。
|
||||
|
||||
坡道导航要求:本次任务 ACTIVE→SUCCEEDED,独立真值 XY 误差<0.10 m、Z 误差<0.03 m,
|
||||
坡中俯仰误差<0.05 rad、高度误差<0.04 m、横向偏差<0.03 m,真实坡道接触存在、
|
||||
最大穿透<5 mm,到点速度<0.01 m/s、观察窗口漂移<0.02 m。
|
||||
台阶负例从坡中 X=1.5 m 发到已在局部地图内的 X=−2.5 m:要求新鲜感知下 FAILED、
|
||||
原目标保留、从未 ACTIVE、始终零命令、真值静止。
|
||||
|
||||
保留失败和无效证据:
|
||||
|
||||
- 原朝内网格 `ramp_r1/`、`ramp_spheres/` 及诊断目录:进坡失败;
|
||||
球支撑实验已撤销,生产仍是原圆柱。
|
||||
- `ramp_flipped/`:隔离世界中仅翻面后物理通过;生产地图复测另外列出。
|
||||
- `flat/` 的 ROS 域设置错误、早期接触回归的相对路径/环境问题属于 INVALID,不能计通过。
|
||||
- `flat_r1/` 曾因把较早 odom 与加速中的真值直接比较产生速度差;检查器现对真值时间
|
||||
使用两侧 odom 插值,不外推、间隔上限 30 ms,阈值不变。`flat_r2/` 为完整新实测。
|
||||
- `navigation_r1/` 的两次坡道通过,但旧负例目标最初在滑动地图外,车辆先靠近后拒绝,
|
||||
不符合旧测试的“从起点静止”前提。新负例把目标放进可观测范围;没有改写旧 FAIL。
|
||||
- 接触回归早期中断遗留的自有 gzserver 按已核对 PID、启动时间与命令行单独清理,
|
||||
记录于 `owned_leftover_cleanup.json`;没有按进程名批量终止其他仿真。
|
||||
|
||||
## 构建、运行与复现
|
||||
|
||||
从仓库根目录构建;P6 后传感器依赖原 Livox 消息,首次先按
|
||||
[导航构建说明](P3_P4_NAVIGATION.md) 生成消息接口(无需硬件 SDK),
|
||||
或按 [P6 说明](P6_LOCALIZATION.md) 一并构建定位包。再构建原算法和已有 step_blocker、仿真包:
|
||||
|
||||
```bash
|
||||
source /opt/ros/humble/setup.bash
|
||||
source sim_ws/install/localization/setup.bash
|
||||
PATH=/usr/bin:$PATH colcon --log-base sim_ws/log/navigation_build build \
|
||||
--base-paths minco_ws/src/scan --packages-up-to scan_planner step_blocker \
|
||||
--build-base sim_ws/build/navigation --install-base sim_ws/install/navigation \
|
||||
--parallel-workers 2 --cmake-args -DPython3_EXECUTABLE=/usr/bin/python3 \
|
||||
-DBUILD_TESTING=ON -DCMAKE_BUILD_TYPE=Release
|
||||
source sim_ws/install/navigation/setup.bash
|
||||
PATH=/usr/bin:$PATH colcon --log-base sim_ws/log/sim_build build \
|
||||
--base-paths sim_ws/src --packages-select robocon_gazebo r2027_robot_description br_sim_bringup \
|
||||
--build-base sim_ws/build/classic --install-base sim_ws/install/classic \
|
||||
--symlink-install --cmake-args -DPython3_EXECUTABLE=/usr/bin/python3 -DBUILD_TESTING=OFF
|
||||
```
|
||||
|
||||
本机已构建。每个终端先执行:
|
||||
|
||||
```bash
|
||||
source /opt/ros/humble/setup.bash
|
||||
source /home/kevin/RC2027_BR_code/sim_ws/install/classic/setup.bash
|
||||
export ROS_DOMAIN_ID=77 ROS_LOCALHOST_ONLY=1
|
||||
export GAZEBO_MASTER_URI=http://127.0.0.1:11355
|
||||
```
|
||||
|
||||
终端一启动红侧坡道导航(`gui:=false` 可无界面):
|
||||
|
||||
```bash
|
||||
ros2 launch br_sim_bringup scan_terrain.launch.py
|
||||
```
|
||||
|
||||
等 `/planning/perception_ready` 为 true,终端二发上坡路径:
|
||||
|
||||
```bash
|
||||
ros2 run scan_planner reference_path_publisher.py --ros-args \
|
||||
-p use_sim_time:=true -p frame_id:=world \
|
||||
-p 'waypoints:=[3.5,3.5125,0.0,2.7,3.5125,0.0,-0.8,3.5125,0.597,-1.2,3.5125,0.6]'
|
||||
```
|
||||
|
||||
下坡时交换路径点的顺序。蓝侧启动加 `y:=-3.5125`,同时把路径里的 Y 改为 −3.5125。
|
||||
本轮为无界面自动验收,没有新截图,也未重新确认 GPU renderer。
|
||||
|
||||
自动工具自己起停仿真,与手动 launch 互斥;每次使用新的输出目录,顺序执行:
|
||||
|
||||
```bash
|
||||
/usr/bin/python3 sim_ws/tools/check_omni_robot.py --drive contact --out sim_ws/log/contact_manual
|
||||
/usr/bin/python3 sim_ws/tools/check_slope_drive.py --out sim_ws/log/slope_physics_manual
|
||||
/usr/bin/python3 sim_ws/tools/check_slope_navigation.py --out sim_ws/log/slope_red_manual
|
||||
/usr/bin/python3 sim_ws/tools/check_slope_navigation.py --side blue --out sim_ws/log/slope_blue_manual
|
||||
/usr/bin/python3 sim_ws/tools/check_slope_navigation.py --case stairs_rejected --out sim_ws/log/stairs_red_manual
|
||||
/usr/bin/python3 sim_ws/tools/check_slope_navigation.py --side blue --case stairs_rejected --out sim_ws/log/stairs_blue_manual
|
||||
```
|
||||
|
||||
退出码 0/30/40 分别为通过/有效失败/无效采集。仅清理本轮拥有的进程,端口占用即退出。
|
||||
本次只验收上述两条坡道路线和已知台阶禁行,不等于完整比赛任务、任意坡道、真实麦轮或
|
||||
Point-LIO 通过。下一阶段再增加 MID360 采样、真实物理语义 IMU 与逐点时间,并对照真值评估定位。
|
||||
@@ -0,0 +1,169 @@
|
||||
# P6:LIO 指定坡道导航验收(2026-11-08)
|
||||
|
||||
独立入口 `scan_lio_terrain.launch.py` 复用 Point-LIO、SCAN、闭环控制器、接触驱动和 step_blocker。
|
||||
本文件原“最终验收”表是此前理想模式基线。本轮参数与复测更新见文末及 RELEASE_VALIDATION.md。
|
||||
原真值坡道入口、LIO 平地入口和实车参数不变。当前结论以本文件后续验收表为准,构建成功不能作为导航通过。
|
||||
|
||||
## 坐标、输入与先验
|
||||
|
||||
单位米/秒/弧度,world Z 向上。默认已知平地起点 (3.5,3.5125,0.15,yaw=0),
|
||||
蓝侧用 y=-3.5125。静止估计达到既有启动标准后,只锁定一次已知起点变换;
|
||||
不订阅真值/TF,不调用物理服务,不在线对齐。真值只进入独立采集器。
|
||||
本入口要求从平地启动,不能把机器人直接放在坡中却仍声明 roll/pitch=0 的先验。
|
||||
|
||||
适配器仍将 IMU 原点转换到 base_link,处理完整姿态与速度参考点,
|
||||
点云沿用 Point-LIO 的逐点配准及配对原光学字段。接口和公式见 P6_NAVIGATION.md。
|
||||
已知地表路径 `/initial_path` 为 nav_msgs/Path,frame=world;Path.z 是地面高度,原算法加 0.15 m。
|
||||
/cmd_vel 为 geometry_msgs/Twist,vx/vy 属车体,简化 contact 驱动的 wz 控制世界 Z 转向。
|
||||
全部节点显式仿真时间,沿用 ROS_DOMAIN_ID=77、GAZEBO_MASTER_URI 11355。
|
||||
|
||||
## 地形过滤与禁行层
|
||||
|
||||
独立 profile 不加载平地向下 0.50 m 膨胀,使用 0.05 m。
|
||||
在完整世界估计云发布后,仅在规划副本中按场地已知坡面、平台及底层平面过滤。
|
||||
竖直残差范围设为 0.06 m:此前独立坡道定位最大 Z 误差约 0.038 m,加 0.02 m 余量。
|
||||
没有抬高点云、改估计高度或伪造低处回波。完整云、原字段、源时间和点索引保持。
|
||||
**此过滤不能认证高度≤0.10 m 的低障碍**:定位误差与过滤带可能覆盖它们,后续需另作感知方案。
|
||||
单元测试覆盖 ±4 cm 坡面误差下地面被滤除、15 cm 高障碍点仍保留;真实障碍行为另验。
|
||||
|
||||
step_blocker 复用已知台阶禁行先验,输入 `/sim/navigation/planning_cloud`,
|
||||
输出 `/sim/navigation/terrain_planning_cloud`,添加的点明确是规划约束,不能当作雷达观测。
|
||||
适配器就绪同时要求该最终话题年龄≤0.20 s;自身估计≤0.20 s,配准云≤0.25 s。
|
||||
未收到或下游停止输出时撤销就绪,不允许仅凭上游新鲜继续行驶。
|
||||
|
||||
## 通道与参数
|
||||
|
||||
车体 0.80×0.80 m、4 cm 单边显式裕度、0.01 rad 朝向容差不缩减,速度上限先取 0.20 m/s。
|
||||
坡道净宽 0.975 m,名义车体两边空隙各 8.75 cm;定位、跟踪、旋转与体素量化都要占用这段预算。
|
||||
|
||||
首轮 5 cm 体素反复拒绝轨迹;改为 2.5 cm 体素,窗口由 10×10×5 m 改为
|
||||
10×3×2 m,体素数从约 400 万变为约 384 万。窗口跟随估计,足够覆盖单条坡道和局部路径。
|
||||
保留原算法的完整体素保护,细化分辨率不是缩小安全裕度。
|
||||
|
||||
定位使用独立 `point_lio_terrain.yaml`,由 mid360 入口新增可选 lio_profile 参数加载。
|
||||
原默认 profile 不变。最终试验保留原雷达残差方差 0.01 m²,仅将点云/地图降采样从 0.15 m 细化到 0.10 m。
|
||||
每次调参都必须独立实测,不能当作真实雷达标定。
|
||||
|
||||
## 实验记录
|
||||
|
||||
证据根目录 `log/codex_p6_lio_terrain_20261108/`,旧报告不改写。
|
||||
|
||||
| 轮次 | 实际结果 |
|
||||
|---|---|
|
||||
| red_up | FAIL:物理接触/高度/通道成立,但真实到点误差 0.16785 m;耗时约 80 s,最大纵向定位误差 0.14924 m |
|
||||
| red_up_r1 | FAIL:仅细化地图后耗时约 37 s,真实到点误差仍 0.13154 m;最大横向偏离约 0.03442 m,超过 0.03 m 标准 |
|
||||
| red_up_r2 | INVALID:尝试提高雷达残差权重,静止速度估计约 0.04 m/s,启动门控不放行;未发路径、未行驶,已撤回此参数 |
|
||||
| red_up_r3 | PASS:细化定位降采样后,真实上坡到点误差 0.03422 m,完整车体最小空隙 0.07672 m |
|
||||
| red_round_trip | PASS:上坡、顶部台阶拒绝、下坡 3/3;使用当时 0.30 s 下游门限 |
|
||||
| blue_round_trip | FAIL:上坡到点通过,但暂停下游后停稳 0.540 s,超过 0.50 s;未执行该轮台阶和下坡,门限随后收紧为 0.20 s |
|
||||
| ramp_obstacle | PASS:坡上新增 0.25×0.25×0.60 m 静态箱,66/66 个被选中的实际回波保留;目标占用被拒绝、没有 ACTIVE、始终静止 |
|
||||
| blue_round_trip_r1 | FAIL:收紧下游门限后断流 0.410 s 停车通过,但下坡终态制动采样为 0.210 s,超过 0.200 s;末段速度随后降低,采样加密 |
|
||||
| blue_round_trip_r2 | PASS:最终参数下上坡、台阶拒绝、下坡 3/3;包含断流停车和同一目标恢复 |
|
||||
| red_round_trip_final | PASS:与蓝侧同一份最终参数,上坡、台阶拒绝、下坡 3/3 全部重跑 |
|
||||
| flat_lio_regression | PASS:原 LIO 平地直达单例新实测,非四路线全量回归 |
|
||||
| unit_tests_r1.log / unit_tests_final.log | 8/8 PASS,包括新地形过滤和下游陈旧门控;不能代替物理验证 |
|
||||
|
||||
独立物理要求:实际 XY 到点<0.10 m、高度误差<0.03 m;坡中高度误差<0.04 m、
|
||||
俯仰误差<0.05 rad、全程横向偏离<0.03 m;完整车体投影到边界的实际空隙>0.04 m,
|
||||
真实坡道接触存在、穿透<5 mm;终态源时间后≤0.20 s 停稳,再连续 1.1 s 静止。
|
||||
估计与真值只按源时间戳配对,横向误差<0.03 m、竖直误差<0.05 m,不重新拟合对齐。
|
||||
|
||||
无截图要求;没有重新验收 GPU、GUI、真实轮组、噪声、任意地形或双机。
|
||||
|
||||
## 启动和复测
|
||||
|
||||
终端先按 P6_NAVIGATION.md source ROS 与 `sim_ws/install/classic/setup.bash`,设置相同 ROS 域和仿真地址。
|
||||
一个入口只启动一个 server,与其他仿真互斥:
|
||||
|
||||
```bash
|
||||
ros2 launch br_sim_bringup scan_lio_terrain.launch.py
|
||||
# 蓝侧加 y:=-3.5125;gui:=false 为无界面。
|
||||
```
|
||||
|
||||
等待 `/planning/perception_ready` 为 true,再在另一同环境终端发红侧上坡路径:
|
||||
|
||||
```bash
|
||||
ros2 run scan_planner reference_path_publisher.py --ros-args \
|
||||
-p use_sim_time:=true -p frame_id:=world \
|
||||
-p 'waypoints:=[3.5,3.5125,0.0,2.7,3.5125,0.0,-0.8,3.5125,0.597,-1.2,3.5125,0.6]'
|
||||
```
|
||||
|
||||
下坡把点顺序反转;蓝侧所有 Y 改成 −3.5125。不使用 2D Goal Pose,不自动发路径。
|
||||
固定起点锁定后不能挪车再继续原任务;不得用 `vehicle_bringup` 启动实车雷达或串口桥。
|
||||
|
||||
从源码重建沿用 P6_LOCALIZATION.md 的接口、定位与导航依赖,然后重建 br_sim_bringup:
|
||||
|
||||
```bash
|
||||
source /opt/ros/humble/setup.bash
|
||||
source sim_ws/install/classic/setup.bash
|
||||
PATH=/usr/bin:$PATH colcon --log-base sim_ws/log/lio_terrain_build build \
|
||||
--base-paths sim_ws/src --packages-select br_sim_bringup \
|
||||
--build-base sim_ws/build/classic --install-base sim_ws/install/classic \
|
||||
--symlink-install --cmake-args -DPython3_EXECUTABLE=/usr/bin/python3 -DBUILD_TESTING=OFF
|
||||
```
|
||||
|
||||
自动工具自己起停仿真,不能与手动 launch 同时运行;每次用新输出目录,串行执行:
|
||||
|
||||
```bash
|
||||
/usr/bin/python3 sim_ws/tools/check_lio_terrain.py --out sim_ws/log/lio_terrain_red_manual
|
||||
/usr/bin/python3 sim_ws/tools/check_lio_terrain.py --side blue --planning-loss --out sim_ws/log/lio_terrain_blue_manual
|
||||
/usr/bin/python3 sim_ws/tools/check_lio_terrain.py --obstacle-only --out sim_ws/log/lio_terrain_box_manual
|
||||
```
|
||||
|
||||
0/30/40 分别为通过、有效失败、无效采集。`--planning-loss` 仅暂停本轮拥有的 step_blocker 进程 0.8 s,
|
||||
不停止 Point-LIO、不发送额外零速;要求 0.50 s 内停稳,恢复后同一任务重新授权。
|
||||
最终制动窗口按终态消息源时间戳开始计时,采样等待 5 ms(实际 clock 为 10 ms),不能拿观察时刻抹去延迟。
|
||||
末段接近速度已改为仿真专用 `goal_v_floor=0.02`、`goal_slow_gain=0.3`,保持 6 cm finish_dist 和原到点验收阈值。
|
||||
|
||||
|
||||
## 最终验收
|
||||
|
||||
机读索引 `log/codex_p6_lio_terrain_20261108/acceptance_summary.json` 保存证据、采集工具与最终源码哈希。
|
||||
红、蓝最终整轮各含三例,使用同一份最终参数和采集器;不把早期单独通过的用例拼成整轮结果。
|
||||
四条运动路线均使用原 Point-LIO/SCAN/闭环控制,真值只进入独立评分器。
|
||||
|
||||
| 路线 | 真实 XY 到点误差 | 终态源时间后停稳 | 完整车体最小通道空隙 |
|
||||
|---|---|---|---|
|
||||
| 红侧上坡 | 0.03737 m | 0.070 s | 0.07057 m |
|
||||
| 红侧下坡 | 0.05528 m | 0.140 s | 0.07055 m |
|
||||
| 蓝侧上坡(含断流恢复) | 0.02962 m | 0.150 s | 0.06967 m |
|
||||
| 蓝侧下坡 | 0.05597 m | 0.190 s | 0.07155 m |
|
||||
|
||||
两侧台阶目标均在感知新鲜时 FAILED、从未 ACTIVE、原目标保留、零指令和物理静止。
|
||||
四条运动路线的真实接触穿透最大约 0.001033 m;定位横向误差最大约 0.01943 m,
|
||||
竖直误差最大约 0.03290 m。独立真值按源时间插值,间隔限制 120 ms;没有重新对齐或拟合。
|
||||
这些是本轮观测值,不是定位误差上界保证,不能直接扩大为实车安全证明。
|
||||
|
||||
蓝侧上坡期间仅暂停本轮 step_blocker 0.8 s,车辆在 0.410 s 内停稳,后半段保持静止;
|
||||
Point-LIO 继续运行,数据恢复后同一任务的轨迹编号从 4 增为 5,再到达原目标。
|
||||
`planning_loss_audit.json` 独立核对暂停期间的 HOLD、实际停稳、新轨迹编号与进程归属。
|
||||
|
||||
坡上箱体用例使用较早的 5 cm/s 末段参数,但全程未发非零命令;未声称随最终报告工具重新跑物理。
|
||||
66 个选中实际回波的 XYZ 在规划副本中逐值保持,范围 z=0.41867~0.88959 m;
|
||||
`obstacle_point_audit.json` 与原始 npz 独立核对保留情况。目标被占用检查拒绝,车辆没有接近撞停。
|
||||
仅验证此 0.60 m 箱体与已知台阶先验,不扩大为低障碍或任意悬崖检测通过。
|
||||
|
||||
该基线结束时仿真已停止、11355 端口释放,未执行 Git 写操作;没有要求截图。
|
||||
|
||||
## 收尾修订:带噪声坡道边界(2026-11-08)
|
||||
|
||||
轻度噪声试验发现仅有地表过滤和台阶先验时,规划可能从坡道侧面绕行,完整车体越出通行面。
|
||||
本轮在 **LIO 坡道专用** step_blocker.regions 增加红/蓝坡道的四条侧边界平面,坐标来自已知场地。
|
||||
这是显式规划先验,不是 Gazebo 实体墙,也不添加到原始雷达或完整估计云。
|
||||
所有未知悬崖仍不保证识别。4 cm 裕度、0.80 m 车体与物理地图未变。
|
||||
|
||||
先验采样从 0.05 m 改为 0.10 m,共 8484 点;体素碰撞膨胀覆盖采样间隙。
|
||||
密集版本约 4.8 万点造成下游消息陈旧及超时,失败日志保留,未放宽 0.20 s 下游年龄门限。
|
||||
控制器 pos_deadband 收紧为 0.005 m;其余速度、制动和静止阈值保持。
|
||||
新增 edge_rejected 用例:平台内地表高度正确,但完整车体将越过坡边的目标必须被拒绝。
|
||||
|
||||
最终 `log/codex_release_20261108/terrain_mild_r2/`(红侧 mild)与
|
||||
`blue_corridor_regression/`(蓝侧 ideal,含下游断流)各完整重跑四例:
|
||||
上坡、台阶目标拒绝、坡边越界目标拒绝、下坡,均 4/4 PASS。
|
||||
红侧上下坡真实到点误差 2.87/5.76 cm、完整车体最小空隙 6.48/5.79 cm;
|
||||
蓝侧上下坡到点误差 1.99/5.54 cm、最小空隙 7.89/8.13 cm。
|
||||
坡边目标拒绝时不发运动,不以撞上实体墙证明安全。
|
||||
早期坡上箱体拒绝仍沿用上一节的独立证据,本轮未重测该箱体。
|
||||
|
||||
连续导航、传感器压力与视场边界结果见 [ROBUSTNESS.md](ROBUSTNESS.md)。
|
||||
硬件轮组、实车标定和真正两机网络仍未验收;本轮用户授权提交源码并自行 push。
|
||||
@@ -0,0 +1,201 @@
|
||||
# P6:MID360 兼容传感器与 Point-LIO 定位基线(2026-11-08)
|
||||
|
||||
本阶段新增独立的 `mid360_sim.launch.py`,先验证传感器语义,再用原仓库 Point-LIO 与独立真值比较。
|
||||
原 `scan_sim.launch.py`、`scan_terrain.launch.py` 仍使用通用雷达与真值导航;本入口暂不启动 SCAN。
|
||||
本文件记录独立定位基线;后续平地导航接入与验收另见 [P6_NAVIGATION.md](P6_NAVIGATION.md)。
|
||||
真实雷达噪声和打滑条件未验收。
|
||||
本文记录默认 ideal 独立定位基线。后续已增加可选工程白噪声/固定偏置/丢点,
|
||||
并完成注入统计与 mild 导航验证,见 [ROBUSTNESS.md](ROBUSTNESS.md);不等于实车噪声标定。
|
||||
|
||||
## 已核实输入与决定
|
||||
|
||||
原程序在 `minco_ws/src/perception/Point-LIO`:`lidar_type=1` 订阅
|
||||
`livox_ros_driver2/msg/CustomMsg`,逐点 `offset_time` 按纳秒除以 1e6,转成内部毫秒时间。
|
||||
`line<4`、有效 tag、先后顺序和真实采样时间必须满足,不能把瞬时整帧补一列时间后冒充扫描。
|
||||
IMU 为 `sensor_msgs/msg/Imu`,读取角速度和比力;该实现不使用消息中的 orientation 作为定位观测。
|
||||
当前传感器包装也明确把 `orientation_covariance[0]` 设为 −1,表示没有姿态解算,不输出绝对姿态真值。
|
||||
|
||||
官方 [规格](https://www.livoxtech.com/mid-360/specs) 和
|
||||
[用户手册 v1.2](https://terra-1-g.djicdn.com/851d20f7b9f64838a34cd02351370894/Livox/Livox_Mid-360_User_Manual_EN.pdf)
|
||||
给出水平 360°、竖直 −7°~52°、200 k 点/秒、典型 10 Hz,内置 IMU 200 Hz。
|
||||
采用这些接口目标,**不声称重建了厂家光学扫描轨迹**。
|
||||
|
||||
默认 ideal 模型是可审计的理想近似:
|
||||
|
||||
- 真实 ODE 射线求交;每个 1 ms 物理步发出 200 条射线,100 ms 打包一次。
|
||||
每批点共享实际仿真时刻,时间分辨率为 1 ms,**没有虚构 5 µs 子步时间**。
|
||||
时间跳变时丢弃未完成帧,不补采、不外推世界状态;只支持已验证的 1 ms 物理步。
|
||||
- 持续的准均匀非重复方向序列,近似非重复扫描;不是厂家扫描图案或真实覆盖率模型。
|
||||
line=0~3 是软件兼容分组,不宣称真实发射器身份。tag=0x10 表示此理想模型的有效单次回波。
|
||||
- 发射预算 20,000 射线/帧,只有 0.1~40 m 内的真实命中进入消息。
|
||||
**不是每帧 20,000 个有效点**;场地空域无回波,不填充到最大距离或补造点。
|
||||
反射强度固定 100,没有材质反射率、阳光、多径、测距噪声或故障概率模型。
|
||||
- 使用 Gazebo 原生 ImuSensor 的实际传感器求解,薄包装 `libbr_mid360_imu.so` 只发布
|
||||
同一带时间戳读数中的 SI 比力 m/s²、角速度 rad/s,包括重力与安装偏置的运动效应。
|
||||
不发布传感器内部的世界姿态。无注入噪声/偏置,不能据此评价实车鲁棒性。
|
||||
|
||||
Gazebo IMU 具体语义核对了官方
|
||||
[ImuSensor 实现](https://github.com/gazebosim/gazebo-classic/blob/gazebo11/gazebo/sensors/ImuSensor.cc)
|
||||
与 [ROS 插件](https://github.com/ros-simulation/gazebo_ros_pkgs/blob/ros2/gazebo_plugins/src/gazebo_ros_imu_sensor.cpp),
|
||||
同时由静止、运动、自由落体和坡面实测交叉验证。
|
||||
|
||||
## 坐标、时间与话题
|
||||
|
||||
仍为米/秒/弧度、右手系 Z 向上,完整 Classic 场地和 contact 驱动;质量与车体假设不变。
|
||||
`lidar` 光学原点位于 base_link 上方 0.30 m,轴向一致,这是仿真安装假设,非实车测量。
|
||||
按上述手册,IMU 在光学系的位置为 (0.011,0.02329,−0.04412) m,轴向相同;
|
||||
因此 base_link→mid360_imu 平移为 (0.011,0.02329,0.25588) m。
|
||||
Point-LIO 的光学到 IMU 外参为 (−0.011,−0.02329,+0.04412) m、单位旋转,方向不能颠倒。
|
||||
|
||||
| 话题 | 类型 | 语义 |
|
||||
|---|---|---|
|
||||
| `/sim/mid360/lidar` | `livox_ros_driver2/msg/CustomMsg` | 光学系原始扫描,每点在各自采样时刻表达,包含运动畸变 |
|
||||
| `/sim/mid360/points` | `sensor_msgs/msg/PointCloud2` | 同一原始扫描的可视化副本,保留 offset_time/line/tag;未去畸变 |
|
||||
| `/sim/mid360/imu` | `sensor_msgs/msg/Imu` | mid360_imu 系 SI 比力、角速度;orientation 明确标为不可用 |
|
||||
| `/sim/mid360/status` | `std_msgs/msg/String` | 每帧实际首末采样时刻、发射数、有效命中数、物理步与近似模型标记 |
|
||||
| `/sim/lio/aft_mapped_to_init` | `nav_msgs/msg/Odometry` | camera_init 系 IMU 原点 pose,body 系 twist;不是车体中心 |
|
||||
| `/sim/lio/cloud_registered_full` | `sensor_msgs/msg/PointCloud2` | Point-LIO 的估计配准云,frame 为 camera_init |
|
||||
| `/odom`、`/gazebo/get_entity_state` | Odometry、服务 | 独立真值,用于对照;Point-LIO 不订阅 |
|
||||
|
||||
CustomMsg.header.stamp 与 timebase 都是该帧首个采样批次的仿真时刻;
|
||||
timebase 与 offset_time 均为纳秒,header 的 ROS 时间表示与它严格一致。
|
||||
点实际采样时刻 = timebase + offset_time;最后一批为起点 +99 ms,下一帧起点 +100 ms。
|
||||
可视化副本的 header 也是帧起点,不能对整帧套一次 TF 当作已配准世界云。
|
||||
|
||||
所有节点使用仿真时间。Gazebo 插件通过本机 gazebo_ros::Node 工厂显式设置 use_sim_time=true;
|
||||
新增 launch 节点和 Point-LIO 配置也明确设置 true。传感器采样不依赖 GUI 或 GPU。
|
||||
MID360 模式不启动原瞬时点云 `sim_data_adapter`,防止它把多时刻点云当成瞬时扫描。
|
||||
|
||||
Point-LIO 在 `/sim/lio` 下运行,绝对点云发布名也显式重映射。
|
||||
`publish.tf_send_en=false`,不发布估计 TF 边,避免与真值 base_link 树冲突;
|
||||
它仍会创建 `/tf` 发布端,这是现有实现的广播器初始化行为,不能仅凭发布端存在判断发生了 TF 冲突。
|
||||
评价工具同时保留实际观察到的 TF 边。估计的 camera_init 没有被重命名成 world。
|
||||
|
||||
## 构建改动与依赖边界
|
||||
|
||||
新增传感器代码位于 `src/r2027_robot_description/src/mid360_sensor.cpp`、`mid360_imu.cpp`,不是第二套定位算法。
|
||||
原 SCAN 的 P5 修改保持不变,本阶段没有改 Point-LIO 滤波实现。
|
||||
|
||||
原 Livox 包的 CMake 新增 `LIVOX_INTERFACES_ONLY`,默认 OFF,实车硬件分支保持原样。
|
||||
仿真显式设为 ON,直接从原 `.msg` 生成同名消息,不复制协议、不安装硬件 SDK、不启动网卡驱动。
|
||||
安装到独立 `sim_ws/install/localization`,没有覆盖其他工作区安装。
|
||||
本机没有 Livox SDK,故本轮只验证消息模式,**未重新构建或验收默认硬件驱动分支**。
|
||||
|
||||
Point-LIO 本机缺少未被代码使用的 pcl_ros 包,但已有 PCL 和 pcl_conversions。
|
||||
其 CMake 改为显式寻找实际使用的 PCL common/filters/io,并显式链接已有 glog;
|
||||
包依赖同步改为 PCL 开发库。原源码成功全新构建,不引入 Gazebo 依赖。
|
||||
未安装系统包、未改 NVIDIA 驱动、未改外部资源、未暂存或提交 Git。
|
||||
|
||||
从仓库根目录构建定位包(本机内存 15 GiB,编译限制单任务):
|
||||
|
||||
```bash
|
||||
source /opt/ros/humble/setup.bash
|
||||
PATH=/usr/bin:$PATH MAKEFLAGS=-j1 CMAKE_BUILD_PARALLEL_LEVEL=1 \
|
||||
colcon --log-base sim_ws/log/localization_build build \
|
||||
--base-paths minco_ws/src/perception/livox_ros_driver2 minco_ws/src/perception/Point-LIO \
|
||||
--packages-up-to point_lio --executor sequential \
|
||||
--build-base sim_ws/build/localization --install-base sim_ws/install/localization \
|
||||
--cmake-args -DLIVOX_INTERFACES_ONLY=ON -DPython3_EXECUTABLE=/usr/bin/python3 \
|
||||
-DPYTHON_EXECUTABLE=/usr/bin/python3 -DBUILD_TESTING=OFF -DCMAKE_BUILD_TYPE=Release
|
||||
source sim_ws/install/localization/setup.bash
|
||||
source sim_ws/install/navigation/setup.bash
|
||||
PATH=/usr/bin:$PATH colcon --log-base sim_ws/log/sim_build build \
|
||||
--base-paths sim_ws/src --packages-select robocon_gazebo r2027_robot_description br_sim_bringup \
|
||||
--build-base sim_ws/build/classic --install-base sim_ws/install/classic \
|
||||
--symlink-install --parallel-workers 1 \
|
||||
--cmake-args -DPython3_EXECUTABLE=/usr/bin/python3 -DBUILD_TESTING=OFF
|
||||
```
|
||||
|
||||
若还未构建 navigation,先按 `P3_P4_NAVIGATION.md` 构建它;原算法不复制。
|
||||
构建日志位于 `log/codex_p6_20261108/{interfaces_build,lio_build,sim_build,bringup_build,imu_build}.log`。
|
||||
PCL 的 pcap/png 可选 IO 警告不涉及本轮消息流和关闭的 PCD 保存功能。
|
||||
|
||||
## 验收方法与证据
|
||||
|
||||
数据根目录 `log/codex_p6_20261108/`。不要求截图,逐例使用新目录,不覆盖旧证据。
|
||||
所有工具串行运行、只清理本轮进程,0/30/40 分别为通过/有效失败/无效采集。
|
||||
最终机读索引 `acceptance_summary.json` 校验五组原始报告、清理结果、数值一致性,
|
||||
分别记录报告哈希、验收时源码哈希与实际插件/算法二进制哈希。
|
||||
源码构建调整的 diff 另存 `perception_build.diff`;没有暂存、提交或推送。
|
||||
|
||||
传感器:从独立 Gazebo 服务按时间采集完整姿态,逐点插值采样位姿,独立解析场地 46 个 box、
|
||||
2 个 cylinder 与 2 个坡道三角网格,用另一套解析求交比较实际距离。
|
||||
不靠“点落在某个近似平面附近”选择性筛点;保留全部采样误差,检查 p95<5 mm、p99<20 mm。
|
||||
再故意把所有点放在帧末时刻求交,要求运动时明显失败,以排除传感器暗中先行去畸变或补造时间。
|
||||
同时检查时间基准、1 ms 批次偏移、10 Hz、通道/tag、发射预算、IMU 200 Hz、SI 比力与角速度。
|
||||
当前最终轮还要求所有 IMU 消息均声明 orientation 不可用。
|
||||
|
||||
定位:Point-LIO 只收传感器和时钟,实际订阅表、参数 dump 落盘。
|
||||
起点静止时仅用一对 IMU 位姿计算一次固定 SE3,后续全程固定;不拟合整条轨迹、不在线真值纠偏。
|
||||
此对齐只发生在离线评分器,**没有传回 Point-LIO**。
|
||||
按每条估计自身时间戳与独立真值比较 IMU 原点位置和完整姿态;预先阈值分别 0.10 m、0.10 rad。
|
||||
检查连续输出、无倒退、p95 延迟<0.3 s、最大延迟<1.0 s;输出频率上限配置 100 Hz,不当作实测值。
|
||||
|
||||
| 用例 | 原始证据 | 结果 |
|
||||
|---|---|---|
|
||||
| 平地传感器 | `sensors_flat_r3/result.json` | 16 项 PASS,前进/横移/转向逐点几何 p99 最大约 0.015 mm;错误整帧时刻 p95 最大 0.452 m |
|
||||
| 坡上静止传感器 | `sensors_slope_r2/result.json` | 14 项 PASS;比力均值约 (−1.6478,0,9.6605) m/s²,与实际俯仰一致 |
|
||||
| 平地 Point-LIO | `lio_flat_r2/result.json` | 9 项 PASS;最大位置 0.010802 m、最大姿态 0.002423 rad、末点 0.005439 m;p95 延迟 0.093 s,平均输出约 92.90 Hz |
|
||||
| 上下坡 Point-LIO | `lio_slope_r1/result.json` | 10 项 PASS;最大位置 0.084729 m、最大姿态 0.012685 rad、末点 0.000685 m;p95 延迟 0.100 s,平均输出约 92.58 Hz |
|
||||
| 默认通用雷达回归 | `generic_regression_r1/result.json` | yaw=0、π/2 两组各 13 项重新实测 PASS;没有把旧 P3 结果当作本轮新结果 |
|
||||
|
||||
平地有效回波实测约 935~1169 点/帧,坡上约 1699~1718 点/帧,不写成 20k 有效点。
|
||||
最终窗口内 IMU 实测平均约 200.00 / 200.08 Hz,最大相邻间隔 7 / 9 ms;没有把配置频率当实测。
|
||||
最终两次 LIO 的时间戳间隔中位频率均约 95.24 Hz,表中另列整个评估窗口的实际平均频率。
|
||||
坡道误差按世界轴分解的最大绝对值约 X=0.0772、Y=0.0210、Z=0.0379 m,不能只看末点回环误差。
|
||||
无噪声模型下的亚毫米传感器几何误差不代表真实 MID360 测距精度。
|
||||
`sensors_flat/` 是早期采集器 numpy 标量序列化失败的 INVALID,没有可接受的最终报告;
|
||||
`lio_flat/` 在模型生成完成前查询真值,属于 INVALID;修复就绪门控后从新目录重测,旧目录保留。
|
||||
`generic_regression/` 同样发现共享 Sim.start 只等待端口、尚未等模型生成就允许置位的竞态,
|
||||
属于 INVALID。共享启动门控现要求 spawn_entity 实际成功,再由各工具独立判断落稳;
|
||||
默认通用雷达从新目录重测。构建成功和输入兼容不能代替实际运行。
|
||||
早期已通过的传感器/定位轮次保留为开发证据;最终上述四例全部使用 orientation 不可用的 IMU 包装。
|
||||
传感器 r3/r2 又把耗时的离线几何分析移到在线采集之后,增加全窗口 IMU 连续性检查,
|
||||
消除检查器分析期间自身不处理回调造成的漏收。原轮次未回写为新检查器的结果。
|
||||
|
||||
## 启动与复现
|
||||
|
||||
每个终端先执行:
|
||||
|
||||
```bash
|
||||
source /opt/ros/humble/setup.bash
|
||||
source /home/kevin/RC2027_BR_code/sim_ws/install/classic/setup.bash
|
||||
export ROS_DOMAIN_ID=77 ROS_LOCALHOST_ONLY=1
|
||||
export GAZEBO_MASTER_URI=http://127.0.0.1:11355
|
||||
```
|
||||
|
||||
只看传感器:
|
||||
|
||||
```bash
|
||||
ros2 launch br_sim_bringup mid360_sim.launch.py
|
||||
```
|
||||
|
||||
同时运行原 Point-LIO:
|
||||
|
||||
```bash
|
||||
ros2 launch br_sim_bringup mid360_sim.launch.py with_lio:=true
|
||||
```
|
||||
|
||||
`gui:=false` 可无界面。这个入口不自动发运动命令,不运行 SCAN;车体命令仍是 `/cmd_vel`。
|
||||
RViz 可显示 `/sim/mid360/points`(原始畸变扫描)或 `/sim/lio/cloud_registered_full`(估计配准扫描)。
|
||||
看估计云时把 Fixed Frame 设为 camera_init;看原始云可用 lidar 或 world。
|
||||
camera_init 尚未向 world 发布对齐 TF,不能把两个不同原点直接叠加比较。
|
||||
|
||||
自动测试自己起停仿真,不能与手动 launch 同时运行:
|
||||
|
||||
```bash
|
||||
/usr/bin/python3 sim_ws/tools/check_mid360.py --out sim_ws/log/mid360_flat_manual
|
||||
/usr/bin/python3 sim_ws/tools/check_mid360.py --case slope --out sim_ws/log/mid360_slope_manual
|
||||
/usr/bin/python3 sim_ws/tools/check_point_lio.py --out sim_ws/log/lio_flat_manual
|
||||
/usr/bin/python3 sim_ws/tools/check_point_lio.py --case slope --out sim_ws/log/lio_slope_manual
|
||||
```
|
||||
|
||||
平地导航接入已单独处理:IMU 原点到 base_link 的位姿与速度参考点、camera_init 与导航世界的初始对齐、
|
||||
扫描去畸变后的点云、自过滤和唯一 TF 发布,以及定位失效后的停车。
|
||||
不能简单把 `/sim/lio/aft_mapped_to_init` 重命名成当前真值 `/body_odom`。
|
||||
新入口与平地验收见 P6_NAVIGATION.md;坡道导航仍需另行核算定位误差、延迟与间隙预算,
|
||||
不能直接沿用真值定位条件下的 4 cm 专用裕度。
|
||||
当前坡面过滤厚度 1.5 cm 也小于本轮最大的 Z 向定位误差,需单独验证地形过滤和高度参考。
|
||||
|
||||
后续指定坡道的独立预算、过滤与导航验收已完成,见 [P6_LIO_TERRAIN.md](P6_LIO_TERRAIN.md)。
|
||||
上述独立定位基线的测量值保留,不能与新配置混为同一轮。
|
||||
@@ -0,0 +1,198 @@
|
||||
# P6:Point-LIO 驱动的平地 SCAN 闭环(2026-11-08)
|
||||
|
||||
本阶段在已有 MID360 兼容近似扫描、物理 IMU 和原 Point-LIO 上,复用现有 SCAN/闭环控制器。
|
||||
新增独立 `scan_lio.launch.py`。原真值平地入口和坡道入口保留,实车参数文件不变。
|
||||
本入口只验收平地,不能把独立上下坡定位通过扩大为坡道导航通过。
|
||||
后续已在独立地形入口完成指定坡道导航,见 [P6_LIO_TERRAIN.md](P6_LIO_TERRAIN.md);本入口仍仅用于平地。
|
||||
本文件后面的四路线结果为此前理想模式基线。收尾修订在平地 LIO profile 中将终点朝向容差
|
||||
从 0.10 rad 收紧为 0.02 rad;带轻度工程噪声连续八段及失效停车的新证据见
|
||||
[RELEASE_VALIDATION.md](RELEASE_VALIDATION.md),实车参数不变。
|
||||
|
||||
## 输入隔离与固定起点
|
||||
|
||||
Point-LIO 只订阅 `/sim/mid360/lidar`、`/sim/mid360/imu` 和时钟。
|
||||
`lio_navigation_adapter` 只订阅 LIO 估计里程计与其逐点配准的成对点云;没有真值订阅、TF 查询或 Gazebo 服务。
|
||||
规划器和控制器只读 `/sim/navigation/*`,真值 `/odom` 与 GetEntityState 服务只用于独立验收。
|
||||
目标的高度使用既定 0.15 m,不从真值查询结果生成导航输入。
|
||||
|
||||
出生参数 x/y/z/yaw 同时给出**已知起点先验**,默认 (−4.5,4.5,0.15,0)。
|
||||
适配器观察 LIO 连续静止 1 s(至少 20 个样本,速度/角速度<0.02、位置变化<2 cm)后,
|
||||
用该先验和当时的一份估计计算固定 camera_init→world 变换。
|
||||
这不是全局重定位,也不是持续真值纠偏;启动时必须确实处于所声明的已知平地起点。
|
||||
该变换锁定后不再调整,不通过贴地、改 frame_id 或回环拟合掩盖后续误差。
|
||||
|
||||
所有量使用米/秒/弧度和仿真时间。位姿属于 header.frame_id,速度属于 child_frame_id,
|
||||
符合 [ROS Odometry 定义](https://github.com/ros2/common_interfaces/blob/humble/nav_msgs/msg/Odometry.msg)。
|
||||
输入必须是 camera_init/body,时间戳、四元数和数值有效;不把消息接收时间冒充传感器时间。
|
||||
|
||||
## 车体参考点与点云
|
||||
|
||||
当前模型的 IMU 相对 base_link 偏置 r_BI=(0.011,0.02329,0.25588) m,
|
||||
光学原点 r_BL=(0,0,0.30) m,各轴平行。整机安装仍是仿真假设,内置偏置见 P6_LOCALIZATION.md。
|
||||
|
||||
给定固定 R_WC/t_WC、LIO 的 p_CI/R_CI 与 IMU 系速度 v_I/ω_I:
|
||||
|
||||
```
|
||||
R_WB = R_WC R_CI
|
||||
p_WB = R_WC p_CI + t_WC − R_WB r_BI
|
||||
v_B = v_I − ω_I × r_BI
|
||||
p_WL = R_WC p_CI + t_WC + R_WB (r_BL − r_BI)
|
||||
v_L = v_I + ω_I × (r_BL − r_BI)
|
||||
```
|
||||
|
||||
位姿协方差随固定旋转与参考点变化转换,twist 协方差随参考点变化转换;
|
||||
原算法未提供的协方差仍未提供,不宣称已校准不确定性。
|
||||
|
||||
使用仓库已有 `/sim/lio/cloud_registered_full_lidar`:其 XYZ 由原 Point-LIO 按逐点时刻和状态快照配准,
|
||||
同一消息的 lidar_x/y/z 保留对应点的原光学坐标。只对已配准 XYZ 施加固定 R_WC/t_WC。
|
||||
不对原始畸变整帧套一次最新 TF,也不重新实现第二套去畸变算法。
|
||||
|
||||
- `/sim/navigation/cloud_registered` 保留完整转换结果和配对原光学坐标。
|
||||
- `/sim/navigation/planning_cloud` 只把地面及自身回波的 XYZ 置 NaN,时间戳、索引和原光学字段不变。
|
||||
- 自过滤包围盒沿用 |lidar_x/y|≤0.42、lidar_z∈[−0.47,−0.20] m;地面过滤 z≤0.015 m。
|
||||
- `/sim/navigation/body_odom` 属 world/`lio_base_link`;`sensor_odom` 属 world/`lio_lidar`。
|
||||
- `/cmd_vel` 仍由原闭环控制器产生,经过原命令保护后驱动 contact 模型。
|
||||
|
||||
估计 TF 单独命名,真值树不参与适配计算:
|
||||
|
||||
```
|
||||
world → camera_init 固定起点变换
|
||||
camera_init → lio_imu LIO 原始估计,动态
|
||||
lio_imu → lio_base_link 静态 −r_BI
|
||||
lio_base_link → lio_lidar 静态 r_BL
|
||||
```
|
||||
|
||||
## 平地配置与实际问题
|
||||
|
||||
保持 0.80×0.80 m 车体、9 cm 显式裕度、0.01 rad 行驶朝向容差;本入口线速度上限 0.3 m/s。
|
||||
没有为通过测试缩小车体或裕度,没有修改实车的雷达、外参和控制参数。
|
||||
|
||||
MID360 下视角约 −7°,在距箱体 1.5 m、光学高度约 0.45 m 时,最低可见回波约在 0.27 m。
|
||||
旧配置只向下膨胀 0.05 m,不能把这些较高回波覆盖到 0.15 m 的车体中心行驶层,首轮绕障发生了接触。
|
||||
新的平地配置使用已有 `grid_map.obstacles_inflation_z_down=0.50`,保守把较高的障碍回波纳入行驶层。
|
||||
这是派生占用地图的膨胀,不是补造低处雷达点;原始与完整配准云保持不变。
|
||||
本配置可能拒绝实际可钻过的悬空物,不能直接用于坡道或验证悬空净高。
|
||||
MID360 近场盲区和低障碍可见性仍是限制,不能声称任意低矮物均可避让。
|
||||
|
||||
新观察到的 L1 障碍也收紧了目标处转向包络。
|
||||
旧侧向目标 (−3.6,3.5) 在“8 cm 到点位置范围内任一点均能安全转向”的检查中被拒绝。
|
||||
正例改为从 (−3.8,4.5) 纯横移到 (−3.8,3.5),给 L1 留足余量,保留原安全检查与原目标拒绝行为。
|
||||
|
||||
另一问题出在恢复逻辑:一次短暂感知中断后,车辆停在距目标约 17 cm 处;
|
||||
数据恢复了,但原规划器写死“距目标<0.2 m 就不重规划”,无法完成剩余路程。
|
||||
原 `planner_manager` 新增 `manager.min_replan_distance`,默认保持 0.20 m;仅本入口设为 0.04 m。
|
||||
仍执行原轨迹优化、矩形碰撞检查和控制器授权,没有绕过感知失效停车。
|
||||
|
||||
## 就绪与失效
|
||||
|
||||
适配器每 0.05 s 根据源消息时间戳更新 `/planning/perception_ready`:
|
||||
车体估计年龄≤0.20 s、配准点云年龄≤0.25 s,固定起点已锁定且没有故障。
|
||||
不重新盖时间戳,不用缓存真值补齐流。
|
||||
|
||||
输入里程计倒退、姿态/位置跳变或锁定后时间间隔>0.5 s 时,适配器锁定停止,
|
||||
需要在已知起点重新启动整条链路;不会自动重对齐或自行恢复旧任务。
|
||||
短暂缺数据先撤销就绪,恢复后由原 SCAN 重新进行碰撞检查和轨迹授权。
|
||||
适配器本身停止输出心跳时,原控制器的心跳/授权超时继续生效。
|
||||
诊断 `/sim/navigation/status` 区分 initializing/active/stale/fault,并记录固定对齐、输入时间和原因。
|
||||
|
||||
## 验收与证据
|
||||
|
||||
本轮根目录 `log/codex_p6_navigation_20261108/`;机读索引为 `acceptance_summary.json`。
|
||||
不要求截图,运行期只清理本轮进程,不暂存、提交或推送 Git。
|
||||
|
||||
| 检查 | 实际证据 | 结果 |
|
||||
|---|---|---|
|
||||
| LIO 四条导航路线 | `navigation_r5/result.json` | 4/4 PASS,完整新实测;不是跨轮拼接 |
|
||||
| 近目标短断流恢复 | `near_goal_recovery_r1/result.json` | PASS;暂停适配器 0.40 s,同一目标获得新轨迹 2 并到达 |
|
||||
| Point-LIO 失效停车 | `loss_stop/result.json` | PASS;0.440 s 停稳,静止段漂移 0;恢复进程后保持故障锁停 |
|
||||
| 原真值直达入口回归 | `truth_regression_r3/result.json` | PASS;按源时间戳实测制动 0.110 s、到点误差 0.05635 m;只重测直达 |
|
||||
| 适配器单元测试 | `unit_tests.log` | 6/6 PASS |
|
||||
| SCAN 相关单元测试 | `algorithm_tests.log` | footprint、terrain_velocity、goal_execution_utils、reference_path_utils 四项目标通过 |
|
||||
| 配准云与参考点独立核对 | `input_contract_result.json` | 12 帧配对云、120 份里程计配对通过;采自首轮失败导航,不能充作路线通过证据 |
|
||||
| 高障碍投影到行驶层 | `obstacle_height_layer.{json,npz}` | r5 实测 136 个箱体回波 z=0.285~0.597 m,行驶层内有 32 个膨胀占用体素 |
|
||||
|
||||
| 路线 | 世界系目标 x/y/yaw | 真实终点位置误差 | 真实朝向误差 | 终态后制动时间 |
|
||||
|---|---|---|---|---|
|
||||
| 直达 | −3.8 / 4.5 / 0 | 0.05538 m | 0.00020 rad | 0.140 s |
|
||||
| 保持朝向横移 | −3.8 / 3.5 / 0 | 0.06290 m | 0.00148 rad | 0.190 s |
|
||||
| 返回转向 | −4.5 / 4.5 / π/2 | 0.05129 m | 0.06832 rad | 0.140 s |
|
||||
| 绕障 | −4.5 / 1.5 / π/2 | 0.07165 m | 0.06662 rad | 0.170 s |
|
||||
|
||||
四条路线的连续静止段漂移均为 0,绕障的保守车体最小间隙 0.12205 m。
|
||||
表中制动时间从终态消息的**源时间戳**到首个实际停稳样本计算,包含探针接收延迟;
|
||||
原 JSON 的 settle_latency_sim_s 从探针观察终态时开始计时,数值偏小,原始文件保留。
|
||||
`braking_source_audit.json` 独立重算全部 6 例,均≤0.20 s;近目标恢复 0.190 s,真值直达 0.150 s。
|
||||
工具已改为直接按终态源时间戳计时,另存观察时刻;此处离线审计未重跑物理测试。
|
||||
更新后的计时实现另在真值入口 r3 实际重跑直达并通过,制动 0.110 s;没有把这次单例称为四路线全量回归。
|
||||
近目标恢复例在估计剩余 0.19376 m 时暂停适配器,暂停结束速度 0.00493 m/s;
|
||||
状态先报告 `actual_footprint_occupied_or_odometry_stale`,恢复后轨迹由 1 增为 2,
|
||||
没有重发目标,最终真实误差 0.05394 m。
|
||||
首版恢复采集已完成动作,但测试器只匹配 perception 文本而漏掉 odometry_stale,判为 FAIL;
|
||||
修正为核对暂停时段、正确失效状态、物理静止及新轨迹编号后,在新目录重新实测通过。
|
||||
|
||||
原真值入口的 `truth_regression/` 与 `truth_regression_r1/` 严格旧停车协议均 FAIL:
|
||||
到点后首个样本约 0.027 m/s,随后静止,位置误差约 5.4 cm。
|
||||
去掉地图诊断订阅并未消除这个现象,不能归因于可视化负载。
|
||||
旧协议将终态后第一个样本直接纳入静止窗,没有单独测量底盘允许的制动时间。
|
||||
本轮新增显式 `--settle-timeout 0.20` 协议,与已有底盘停止标准和 LIO 验收一致;
|
||||
默认仍为 0,保留旧工具行为。新协议的独立复测结果另列,不宣称旧协议通过。
|
||||
|
||||
验收分开检查:
|
||||
|
||||
- 单元测试验证固定坐标对齐、参考点速度(独立有限差分)、无效四元数、配对点云、自过滤、陈旧与跳变锁停。
|
||||
- 实际 ROS 图核对算法/适配器/控制器的订阅与服务客户端,没有真值输入;通过正在收数据的探针直接查询 DDS 图。
|
||||
不依赖另开 CLI 参与者的短时发现结果;全名精确匹配,不能把 `/sim/navigation/body_odom` 误当 `/body_odom`。
|
||||
- 独立 GetEntityState 验证真实到点误差<0.10 m、朝向误差<0.10 rad、前进/横移/绕障动作成立。
|
||||
- contact 驱动单独测制动:终态后≤0.20 s 达到速度<0.01 m/s、角速度<0.02 rad/s,
|
||||
再连续 1.1 s 保持静止和漂移<0.02 m。测试器不补发零指令帮助通过。
|
||||
- 在真实运动时暂停本轮 Point-LIO,验证≤0.50 s 停车、真值继续可读且没有回退为导航输入;
|
||||
恢复进程后仍保持锁停。另在距目标<20 cm 时暂停适配器 0.4 s,验证短距离安全恢复。
|
||||
|
||||
旧失败与无效采集均保留:缺执行权限的首轮启动、启动收尾遗留、精确图匹配修复前、
|
||||
CLI 发现不完整、旧瞬时停车判据、旧高度膨胀绕障接触、目标转向安全拒绝以及近目标恢复死锁。
|
||||
不把它们改写成通过,也不靠延长感知容忍时间隐藏输入中断。
|
||||
|
||||
进程工具新增每轮私有 BR_SIM_RUN_TOKEN,启动和收尾都核对它;即使 launch 提前退出、
|
||||
子进程换会话或被重新挂接,也只回收本轮进程,不按进程名批量发送信号。
|
||||
`ownership_test.json` 包含独立会话孤儿进程被回收、无关进程仍存活的对照。
|
||||
首次遗留 server 的清理另记录 PID、启动标识与精确本轮 ROS_LOG_DIR。
|
||||
早期报告的 teardown.port_free=false 是 SIGKILL 后立即读取套接字的竞态;原报告保留。
|
||||
后续各轮启动前均独立确认端口空闲,工具现增加有界等待,失效停车轮已记录 port_free=true。
|
||||
|
||||
## 运行与复现
|
||||
|
||||
已构建的本机终端:
|
||||
|
||||
```bash
|
||||
source /opt/ros/humble/setup.bash
|
||||
source /home/kevin/RC2027_BR_code/sim_ws/install/classic/setup.bash
|
||||
export ROS_DOMAIN_ID=77 ROS_LOCALHOST_ONLY=1
|
||||
export GAZEBO_MASTER_URI=http://127.0.0.1:11355
|
||||
ros2 launch br_sim_bringup scan_lio.launch.py
|
||||
```
|
||||
|
||||
等 `/planning/perception_ready` 为 true,另一个同环境终端发平地目标:
|
||||
|
||||
```bash
|
||||
ros2 topic pub --once /move_base_simple/goal geometry_msgs/msg/PoseStamped \
|
||||
'{header: {frame_id: world}, pose: {position: {x: -3.8, y: 4.5, z: 0.15}, orientation: {w: 1.0}}}'
|
||||
```
|
||||
|
||||
RViz 的 Fixed Frame 设 world;估计机器人帧用 lio_base_link,可看估计配准云、规划云和轨迹。
|
||||
已知起点 x/y/z/yaw 可以通过本入口参数设置;没有重新验证 GUI/GPU renderer。
|
||||
需要改起点时重启入口,不能把已有运行中的机器人挪走后仍沿用原固定对齐。
|
||||
|
||||
从源码重建先按 P6_LOCALIZATION.md 构建定位与导航依赖;本轮另需重建 scan_planner 和 br_sim_bringup,
|
||||
原算法仍位于 minco_ws,不复制。测试器自己起停仿真,与手动 launch 互斥:
|
||||
|
||||
```bash
|
||||
ROS_DOMAIN_ID=78 /usr/bin/python3 sim_ws/tools/test_lio_navigation_adapter.py
|
||||
/usr/bin/python3 sim_ws/tools/check_lio_navigation.py --out sim_ws/log/lio_navigation_manual
|
||||
/usr/bin/python3 sim_ws/tools/check_lio_navigation.py --fault-only --out sim_ws/log/lio_loss_manual
|
||||
/usr/bin/python3 sim_ws/tools/check_lio_navigation.py --recovery-only --out sim_ws/log/lio_recovery_manual
|
||||
/usr/bin/python3 sim_ws/tools/check_scan_navigation.py --straight-only --no-map-diagnostics \
|
||||
--settle-timeout 0.20 --out sim_ws/log/truth_bounded_stop_manual
|
||||
```
|
||||
|
||||
0/30/40 分别为通过/有效失败/采集无效;每次使用新的输出目录,保留实际 diff 与原始证据。
|
||||
本轮仍为无噪声近似 MID360、理想全向执行器,真实轮组/打滑、硬件 SDK/驱动、坡道导航和双机未验收。
|
||||
@@ -0,0 +1,88 @@
|
||||
# 本机仿真收尾验收(2026-11-08)
|
||||
|
||||
本轮完成当前可在笔记本闭环的软件任务:工程噪声注入与核验、同一定位生命周期连续导航、
|
||||
指定坡道带噪声约束、近地视场测量、独立进程拆分、构建入口与旧方案清理。
|
||||
已经可以在完整 Classic 场地上测试仓库原 Point-LIO、SCAN 和闭环控制器。
|
||||
没有把实际轮组、实车标定、真实两机网络或完整比赛任务列为通过。
|
||||
|
||||
精简机读摘要随源码保存于 [validation/20261108.json](validation/20261108.json),
|
||||
包含源文件/结果哈希、实际生成模型中的噪声参数、逐项指标及未验证项。
|
||||
原始日志、点云和时间序列在本机 `sim_ws/log/codex_release_20261108/`,不随 Git 分发。
|
||||
此前 P1~P6 证据见 [HANDOFF.md](HANDOFF.md) 及各阶段文档,本轮未重新运行所有历史用例。
|
||||
|
||||
## 本轮新实测
|
||||
|
||||
环境:Ubuntu 22.04、ROS 2 Humble、Gazebo Classic 11.10.2、系统 Python 3.10。
|
||||
全程使用仿真时间、米/秒/弧度;真值只进入独立评分器,不输入估计导航。
|
||||
固定已知起点只对齐一次,没有在线重对齐、传送车辆或重置第二圈地图。
|
||||
|
||||
| 检查 | 本轮最终证据目录 | 结果与范围 |
|
||||
|---|---|---|
|
||||
| 噪声、偏置、丢点与时间 | `noise_stress_r2` | 9/9 PASS;stress 径向误差 σ=0.015063 m,丢点率 5.0805%;不等于 stress 导航通过 |
|
||||
| 连续导航及进程拆分 | `continuous_split_mild_r2` | mild、两个独立 launch、同一 Point-LIO/地图连续两圈八段,8/8 PASS |
|
||||
| 红侧带噪声坡道 | `terrain_mild_r2` | mild,上坡、台阶拒绝、坡边目标拒绝、下坡,4/4 PASS |
|
||||
| 蓝侧坡道回归与规划流中断 | `blue_corridor_regression` | ideal,同样四例 4/4 PASS;暂停本轮 step_blocker 后 0.320 s 停稳,同一任务重新授权并到达 |
|
||||
| 带噪声定位失效停车 | `mild_loss_stop` | mild,0.340 s 停稳;恢复定位进程后仍故障锁停,无真值回退 |
|
||||
| 近地视场边界 | `low_obstacles_r2` | 9/9 测量符合几何预期;仅代表视场边界核验,**不代表低障碍避让通过** |
|
||||
| 默认理想传感器回归 | `ideal_sensor_regression` | 原平地 16/16 检查 PASS,真实时间字段、物理 IMU、几何与扫描畸变成立 |
|
||||
| 一键构建后的导航 | `post_build_straight` | 新启动原估计导航,直达单例 PASS,到点误差 0.06100 m;未声称四路线重跑 |
|
||||
| 资源检查 | `assets_final/assets.json` | 来源哈希、碰撞计数和坡道面朝向检查全部通过;非全部 50 个碰撞体新物理验证 |
|
||||
| 适配器单元测试 | `unit_adapter_after_build.log` | 8/8 PASS |
|
||||
| SCAN 相关 CTest 目标 | `unit_algorithm_after_build.log` | 矩形车体、地形速度、目标执行、参考路径四组全部通过 |
|
||||
| 算法端独立启动结构 | `algorithm_only_launch.json` | start_sim=false 不查询机器人/Gazebo 包、不创建仿真进程;非真实跨机测试 |
|
||||
|
||||
连续八段的最大真实到点误差 0.07400 m,终态源时间后最大制动时间 0.180 s,
|
||||
每段随后连续静止 1.1 s。两次绕障的保守车体间隙分别为 0.19275/0.15503 m。
|
||||
这是直达、横移、返回转向、绕障的已知路线重复,不是完整比赛任务编排。
|
||||
|
||||
| 最终坡道运动路线 | 真实 XY 到点误差 | 完整车体最小通道空隙 | 终态源时间后制动 |
|
||||
|---|---|---|---|
|
||||
| 红上(mild) | 0.02868 m | 0.06483 m | 0.120 s |
|
||||
| 红下(mild) | 0.05756 m | 0.05789 m | 0.100 s |
|
||||
| 蓝上(ideal,含断流恢复) | 0.01994 m | 0.07887 m | 0.190 s |
|
||||
| 蓝下(ideal) | 0.05540 m | 0.08127 m | 0.150 s |
|
||||
|
||||
## 暴露的问题与最终修正
|
||||
|
||||
- 连续换向时,原 0.10 rad 完成容差允许较大的末端角速度,实际超过 0.20 s 制动预算。
|
||||
仅平地 LIO 仿真覆盖收紧为 0.02 rad;细化采样后仍失败的日志保留,没有扩大停车阈值。
|
||||
- 带噪声坡道曾发生侧向绕出通行面的有效失败。LIO 坡道规划支路增加已知坡边禁行先验,
|
||||
并将位置死区收紧为 0.005 m;物理场地和原始雷达不加墙、不加假回波。
|
||||
- 新先验过密时,下游点云陈旧并导致超时。最终采样 0.10 m、8484 点,保留 2 m 高度及碰撞膨胀,
|
||||
没有放宽 0.20 s 下游门限。红/蓝侧最终参数各完整重跑四例,不拼接早期单例。
|
||||
- IMU 实际平均约 200 Hz,但物理步调度使相邻间隔为 3~7 ms。
|
||||
验收检查正向连续时间、最大间隙和平均频率,不把时间戳重写成精确 5 ms。
|
||||
- 低障碍可见性必须考虑箱体远端顶角;删除箱体后独立查询确认消失,并使用唯一实体名。
|
||||
早期错误预期和无效采集保留,不改写成通过。
|
||||
|
||||
本机失败/无效轮次仍在原输出目录,原因另列于机读摘要。
|
||||
采集工具哈希与最终源码快照分列,版本不同的历史数据不声称由当前工具重跑。
|
||||
|
||||
## 构建与清理
|
||||
|
||||
`bash sim_ws/tools/build_sim.sh` 已实际执行成功,四段依次构建 1/1/8/3 个包:
|
||||
原 Livox 消息(interfaces-only)、原 Point-LIO、原 SCAN/step_blocker 依赖、三个仿真包。
|
||||
未安装硬件 SDK,未复制第二套算法。上游 Gazebo CMake 的 PkgConfig 名称警告和 PCL 可选
|
||||
pcap/png IO 警告保留在 `bootstrap.log`,无构建失败。构建后另做直达运行检查及相关单元测试。
|
||||
|
||||
旧方案清理复核:35 个永久旧路径确认不存在(另有历史清单中的五个生成缓存路径)。
|
||||
包括 Fortress 的 br_gazebo、旧配置/探针/导出工具、构建安装入口与 Blender 下载副本;此前释放约 1.63 GB。
|
||||
本轮又移除了四份过期操作文档、顶层旧构建标记及链接。退役说明保留,旧文档备份位于
|
||||
Git 忽略的 `log/codex_release_20261108/retired_fortress_docs.tar.gz`。
|
||||
原始场地资源、当前 Classic 代码/构建前缀和原始测试证据保留。
|
||||
Classic 仍使用的 ignition::math 属正常依赖,不作为 Fortress 残留卸载。
|
||||
|
||||
源码、模型、配置、README 和精简验收摘要入库;build/install/log、缓存、下载包不入库。
|
||||
全部自动用例结束后本轮仿真进程已清理,11355 端口释放;不按名字杀其他进程。
|
||||
用户授权本轮 git commit,push 留给用户。
|
||||
|
||||
## 后续现场工作
|
||||
|
||||
真实车模仍在其他电脑,当前质量、外包络及整机雷达安装是明确的仿真假设。
|
||||
P7 真实轮组/打滑与实际双机联调需测量资料和设备在线,当前不宣称完成。
|
||||
本机拆分的使用方式和未来跨机验收清单见 [DEPLOY_SPLIT.md](DEPLOY_SPLIT.md)。
|
||||
|
||||
单 MID360 在当前高度/最低视角下看不到部分近处低障碍;坡道地面过滤也可能抹去低矮点。
|
||||
需要补充近地感知或可靠先验后才能验收未知低障碍避让,不能通过补假点声称解决。
|
||||
扫描图案、材质、多径、温漂/随机游走、实车噪声标定、未知悬崖和完整比赛规则任务仍未验收。
|
||||
本轮无界面运行,按用户要求不补截图;GUI/RViz 和实际 GPU renderer 未重新验收。
|
||||
@@ -0,0 +1,81 @@
|
||||
# 传感器压力、连续导航与感知边界
|
||||
|
||||
传感器使用物理射线与原生 IMU。可选噪声在物理观测上注入,始终保留采样时间,
|
||||
没有用随机 IMU 代替物理 IMU,也不伪造点的微秒时间。默认 ideal 保留原基线。
|
||||
|
||||
实现采用独立径向高斯误差、固定每轴 IMU 偏置和白噪声,概念参照
|
||||
[Gazebo Classic 噪声说明](https://classic.gazebosim.org/tutorials?cat=sensors&tut=sensor_noise)。
|
||||
本项目在自定义物理步传感器插件中实现;参数是工程压力输入,**不是厂家指标或实车标定**。
|
||||
没有加入随机游走、温漂、材质反射率、厂家扫描轨迹和角度误差。
|
||||
|
||||
## 可选 profile
|
||||
|
||||
配置在 `src/r2027_robot_description/config/sensor_profiles.yaml`。
|
||||
单位:测距标准差 m、加速度标准差 m/s²、角速度标准差 rad/s,偏置使用相同 SI 单位。
|
||||
|
||||
| profile | 测距 σ | 丢点概率 | 加速度 σ | 角速度 σ |
|
||||
|---|---|---|---|---|
|
||||
| ideal(默认) | 0 | 0 | 0 | 0 |
|
||||
| mild | 0.005 | 0.01 | 0.01 | 0.0005 |
|
||||
| stress | 0.015 | 0.05 | 0.04 | 0.0015 |
|
||||
|
||||
每轴固定偏置与 seed 也在 YAML,启动时检查数值有效。固定 seed 用于本机复现,
|
||||
不保证不同物理调度、编译器或平台逐点字节一致。
|
||||
仅在实际命中后加入径向误差/丢点;超出量程的噪声点丢弃并计数,不补造未命中的点。
|
||||
IMU 姿态继续标记不可用,协方差只记录所加白噪声方差;Point-LIO 内部权重不因此自动标定。
|
||||
|
||||
```bash
|
||||
ros2 launch br_sim_bringup scan_lio.launch.py sensor_profile:=mild
|
||||
ros2 launch br_sim_bringup scan_lio_terrain.launch.py sensor_profile:=mild
|
||||
```
|
||||
|
||||
核验工具把噪声点与按源时间插值的独立真值射线求交比较;IMU 静止比力扣除独立重力投影,
|
||||
检查均值、标准差、丢点统计、报文计数以及实际采样时间。
|
||||
200 Hz 是配置/平均频率,源间隔会有物理步调度抖动;不通过重写时间戳伪装成恒定 5 ms。
|
||||
|
||||
## 连续导航
|
||||
|
||||
```bash
|
||||
/usr/bin/python3 sim_ws/tools/check_lio_navigation.py --laps 2 --split \
|
||||
--sensor-profile mild --out sim_ws/log/continuous_mild_manual
|
||||
```
|
||||
|
||||
同一场景、同一个 Point-LIO 生命周期连续完成八段:两圈直达、横移、返回转向、绕障。
|
||||
第二圈保留第一圈障碍、地图和估计,不传送、不重置、不重新对齐。
|
||||
这是已知验证路线,**不是完整比赛规则任务或任何路线均能通行的证明**。
|
||||
|
||||
原实车 0.10 rad 终点朝向容差在连续换向中导致完成时角速度过高;
|
||||
仅在 LIO 平地仿真覆盖中收紧为 0.02 rad,实车配置不变。
|
||||
终态源时间后仍须≤0.20 s 达到线速度<0.01 m/s、角速度<0.02 rad/s,之后连续 1.1 s 静止。
|
||||
制动采样加密至 5 ms 等待(clock 10 ms),没有扩大停车时间阈值。
|
||||
|
||||
双进程拆分与真正双机之间的区别见 [DEPLOY_SPLIT.md](DEPLOY_SPLIT.md)。
|
||||
|
||||
## 低障碍边界
|
||||
|
||||
```bash
|
||||
/usr/bin/python3 sim_ws/tools/check_low_obstacles.py --out sim_ws/log/low_obstacles_manual
|
||||
```
|
||||
|
||||
静止理想传感器、当前约 0.449 m 光学高度与 −7° 最低视角下,
|
||||
依次生成独立可查询、可删除的实体箱体,采集实际回波,不驱车撞击来证明不可见。
|
||||
每个箱体有唯一名称,删除后通过 GetEntityState 确认消失,避免 Gazebo 异步删除重名竞态。
|
||||
|
||||
3 cm 障碍在 1.5/3 m 的样例没有回波;15 cm 障碍在 1.5 m 也没有回波;
|
||||
30 cm 障碍在 0.6 m 处不可见。8 cm / 3 m 的箱体顶面有少量回波:
|
||||
计算视场必须考虑箱体远端,不能把整个箱体当作中心点。
|
||||
可见点不等于已验证绕障;坡道 profile 的 6 cm 地面过滤还会进一步限制低障碍保留。
|
||||
|
||||
此测试通过表示**边界已如实测量**,不表示低障碍避让已经实现。
|
||||
任意未知低障碍需要额外近地/深度感知或可靠场地先验;当前单 MID360 模型无法凭空补足盲区。
|
||||
|
||||
## 复测与结果
|
||||
|
||||
```bash
|
||||
/usr/bin/python3 sim_ws/tools/check_sensor_noise.py --profile stress --out sim_ws/log/noise_manual
|
||||
/usr/bin/python3 sim_ws/tools/check_lio_terrain.py --sensor-profile mild --out sim_ws/log/terrain_mild_manual
|
||||
/usr/bin/python3 sim_ws/tools/check_lio_navigation.py --sensor-profile mild --fault-only --out sim_ws/log/mild_loss_manual
|
||||
```
|
||||
|
||||
本轮最终结果与旧失败/无效轮次说明见 [RELEASE_VALIDATION.md](RELEASE_VALIDATION.md)。
|
||||
所有自动工具串行运行,与手动 launch 互斥,输出用新目录。实际日志不进 Git,摘要随源码保存。
|
||||
@@ -0,0 +1,12 @@
|
||||
# 已退役方案
|
||||
|
||||
当前仅使用 Gazebo Classic 和 `src/robocon_gazebo` 完整场地。
|
||||
旧 Fortress 包、导出配置、专用工具、构建/安装入口与 Blender 下载/解压副本均已清理。
|
||||
|
||||
过期操作文档也已移出源码目录,本机追溯备份为
|
||||
`sim_ws/log/codex_release_20261108/retired_fortress_docs.tar.gz`,不随 Git 分发。
|
||||
原始资源、旧测试原始日志保留;它们不作为当前启动入口。
|
||||
旧“旋转碰撞失效”推论已撤回,属于采集时序问题。
|
||||
|
||||
最终清理复核见 `sim_ws/docs/RELEASE_VALIDATION.md`。
|
||||
当前使用方法见 [仿真 README](../../../README.md)。
|
||||
@@ -0,0 +1,980 @@
|
||||
{
|
||||
"date": "2026-11-08",
|
||||
"scope": "本机 Classic 仿真、原 Point-LIO/SCAN 闭环及工程压力收尾;不代表实车或完整比赛任务通过",
|
||||
"environment": {
|
||||
"os": "Ubuntu 22.04",
|
||||
"ros": "Humble",
|
||||
"gazebo_classic": "11.10.2",
|
||||
"python": "/usr/bin/python3 (3.10)",
|
||||
"units": "m, s, rad",
|
||||
"world_axes": "Z up; red +Y, blue -Y",
|
||||
"ROS_DOMAIN_ID": 77,
|
||||
"ROS_LOCALHOST_ONLY": 1,
|
||||
"GAZEBO_MASTER_URI": "http://127.0.0.1:11355"
|
||||
},
|
||||
"build": {
|
||||
"status": "PASS",
|
||||
"command": "bash sim_ws/tools/build_sim.sh",
|
||||
"packages_per_stage": [
|
||||
1,
|
||||
1,
|
||||
8,
|
||||
3
|
||||
],
|
||||
"log": "sim_ws/log/codex_release_20261108/bootstrap.log",
|
||||
"sha256": "145106495049818d325099668d93fed85b7c04f75476d7683b9446fb038e91d9",
|
||||
"warnings": [
|
||||
"Upstream Gazebo CMake PkgConfig name mismatch",
|
||||
"PCL optional pcap/png IO disabled"
|
||||
]
|
||||
},
|
||||
"unit_tests": {
|
||||
"unit_adapter_after_build.log": {
|
||||
"status": "PASS",
|
||||
"test_count": 8,
|
||||
"evidence_sha256": "54979ea484fd4d506054954edcb7323f04f2535db12d7659e115376a842f3927"
|
||||
},
|
||||
"unit_algorithm_after_build.log": {
|
||||
"status": "PASS",
|
||||
"test_count": 4,
|
||||
"evidence_sha256": "35e6f7f424c0842a54a70f3307fde0a9cb606ea2c05c1c2f39467bbce7468881"
|
||||
}
|
||||
},
|
||||
"runtime_runs": {
|
||||
"noise_stress_r2": {
|
||||
"status": "PASS",
|
||||
"evidence": "sim_ws/log/codex_release_20261108/noise_stress_r2/result.json",
|
||||
"evidence_sha256": "5c729d6295ee03e95556930ff7e9a66476906d4c648284516026f655e73e0070",
|
||||
"profile": "stress",
|
||||
"checks": {
|
||||
"physical_excitation": true,
|
||||
"imu_bias": true,
|
||||
"imu_stddev": true,
|
||||
"range_noise": true,
|
||||
"dropout": true,
|
||||
"packet_accounting": true,
|
||||
"acquisition_times": true,
|
||||
"imu_times": true,
|
||||
"no_attitude_oracle": true
|
||||
},
|
||||
"range_residual_mean_m": 2.278511964413087e-05,
|
||||
"range_residual_stddev_m": 0.015062798566325355,
|
||||
"dropout_fraction": 0.050804822417725645,
|
||||
"imu_mean_rate_hz": 200.0,
|
||||
"imu_interval_range_s": [
|
||||
0.0029999999999992255,
|
||||
0.007000000000000561
|
||||
],
|
||||
"teardown": {
|
||||
"port_free": true,
|
||||
"never_touched_unknown_pid": true
|
||||
}
|
||||
},
|
||||
"low_obstacles_r2": {
|
||||
"status": "PASS",
|
||||
"evidence": "sim_ws/log/codex_release_20261108/low_obstacles_r2/result.json",
|
||||
"evidence_sha256": "ca71a3d6bcded7a7e746968cb6a9e0c52d74ce6b90b1d80866de5b94d0e7c4d2",
|
||||
"scope": "stationary ideal sensor visibility only; not navigation acceptance",
|
||||
"cases": [
|
||||
{
|
||||
"ok": true,
|
||||
"height_m": 0.03,
|
||||
"distance_m": 1.5,
|
||||
"expected_visible": false,
|
||||
"observed_returns": 0,
|
||||
"frames": 14,
|
||||
"navigation_capability": "UNSUPPORTED: no returns, cannot promise avoidance"
|
||||
},
|
||||
{
|
||||
"ok": true,
|
||||
"height_m": 0.03,
|
||||
"distance_m": 3.0,
|
||||
"expected_visible": false,
|
||||
"observed_returns": 0,
|
||||
"frames": 14,
|
||||
"navigation_capability": "UNSUPPORTED: no returns, cannot promise avoidance"
|
||||
},
|
||||
{
|
||||
"ok": true,
|
||||
"height_m": 0.08,
|
||||
"distance_m": 1.5,
|
||||
"expected_visible": false,
|
||||
"observed_returns": 0,
|
||||
"frames": 14,
|
||||
"navigation_capability": "UNSUPPORTED: no returns, cannot promise avoidance"
|
||||
},
|
||||
{
|
||||
"ok": true,
|
||||
"height_m": 0.08,
|
||||
"distance_m": 3.0,
|
||||
"expected_visible": true,
|
||||
"observed_returns": 18,
|
||||
"frames": 14,
|
||||
"navigation_capability": "visible points only; motion untested"
|
||||
},
|
||||
{
|
||||
"ok": true,
|
||||
"height_m": 0.15,
|
||||
"distance_m": 1.5,
|
||||
"expected_visible": false,
|
||||
"observed_returns": 0,
|
||||
"frames": 14,
|
||||
"navigation_capability": "UNSUPPORTED: no returns, cannot promise avoidance"
|
||||
},
|
||||
{
|
||||
"ok": true,
|
||||
"height_m": 0.15,
|
||||
"distance_m": 3.0,
|
||||
"expected_visible": true,
|
||||
"observed_returns": 101,
|
||||
"frames": 14,
|
||||
"navigation_capability": "visible points only; motion untested"
|
||||
},
|
||||
{
|
||||
"ok": true,
|
||||
"height_m": 0.3,
|
||||
"distance_m": 0.6,
|
||||
"expected_visible": false,
|
||||
"observed_returns": 0,
|
||||
"frames": 14,
|
||||
"navigation_capability": "UNSUPPORTED: no returns, cannot promise avoidance"
|
||||
},
|
||||
{
|
||||
"ok": true,
|
||||
"height_m": 0.3,
|
||||
"distance_m": 1.5,
|
||||
"expected_visible": true,
|
||||
"observed_returns": 233,
|
||||
"frames": 14,
|
||||
"navigation_capability": "visible points only; motion untested"
|
||||
},
|
||||
{
|
||||
"ok": true,
|
||||
"height_m": 0.6,
|
||||
"distance_m": 1.5,
|
||||
"expected_visible": true,
|
||||
"observed_returns": 1817,
|
||||
"frames": 14,
|
||||
"navigation_capability": "visible points only; motion untested"
|
||||
}
|
||||
],
|
||||
"teardown": {
|
||||
"port_free": true,
|
||||
"never_touched_unknown_pid": true
|
||||
}
|
||||
},
|
||||
"continuous_split_mild_r2": {
|
||||
"status": "PASS",
|
||||
"evidence": "sim_ws/log/codex_release_20261108/continuous_split_mild_r2/result.json",
|
||||
"evidence_sha256": "a5d6ecb464f96ae019eba585fc58dcd2a725911ff35c2569be97a67416c15afc",
|
||||
"sensor_profile": "mild",
|
||||
"laps": 2,
|
||||
"split": true,
|
||||
"collector_sha256": "306f940d738715741e8e372a92215abb5a157127f4f814bd0642bf748cea7981",
|
||||
"cases": [
|
||||
{
|
||||
"name": "straight",
|
||||
"lap": 1,
|
||||
"ok": true,
|
||||
"checks": {
|
||||
"acknowledged": true,
|
||||
"active": true,
|
||||
"succeeded": true,
|
||||
"arrival": true,
|
||||
"yaw": true,
|
||||
"stopped": true,
|
||||
"commands_observed": true,
|
||||
"moved": true,
|
||||
"bounded_braking": true,
|
||||
"stopped_rotation": true
|
||||
},
|
||||
"position_error_m": 0.05699990910460994,
|
||||
"yaw_error_rad": 2.5727578423012557e-05,
|
||||
"settle_latency_sim_s": 0.129999999999999,
|
||||
"min_obstacle_clearance_m": null
|
||||
},
|
||||
{
|
||||
"name": "lateral",
|
||||
"lap": 1,
|
||||
"ok": true,
|
||||
"checks": {
|
||||
"acknowledged": true,
|
||||
"active": true,
|
||||
"succeeded": true,
|
||||
"arrival": true,
|
||||
"yaw": true,
|
||||
"stopped": true,
|
||||
"commands_observed": true,
|
||||
"moved": true,
|
||||
"lateral_command": true,
|
||||
"bounded_braking": true,
|
||||
"stopped_rotation": true
|
||||
},
|
||||
"position_error_m": 0.06184782896561852,
|
||||
"yaw_error_rad": 0.0009770037394825275,
|
||||
"settle_latency_sim_s": 0.14000000000000057,
|
||||
"min_obstacle_clearance_m": null
|
||||
},
|
||||
{
|
||||
"name": "return_and_turn",
|
||||
"lap": 1,
|
||||
"ok": true,
|
||||
"checks": {
|
||||
"acknowledged": true,
|
||||
"active": true,
|
||||
"succeeded": true,
|
||||
"arrival": true,
|
||||
"yaw": true,
|
||||
"stopped": true,
|
||||
"commands_observed": true,
|
||||
"moved": true,
|
||||
"bounded_braking": true,
|
||||
"stopped_rotation": true
|
||||
},
|
||||
"position_error_m": 0.051452961430941954,
|
||||
"yaw_error_rad": 0.01275600219030082,
|
||||
"settle_latency_sim_s": 0.1700000000000017,
|
||||
"min_obstacle_clearance_m": null
|
||||
},
|
||||
{
|
||||
"name": "detour",
|
||||
"lap": 1,
|
||||
"ok": true,
|
||||
"checks": {
|
||||
"acknowledged": true,
|
||||
"active": true,
|
||||
"succeeded": true,
|
||||
"arrival": true,
|
||||
"yaw": true,
|
||||
"stopped": true,
|
||||
"commands_observed": true,
|
||||
"moved": true,
|
||||
"bounded_braking": true,
|
||||
"stopped_rotation": true,
|
||||
"physical_clearance": true,
|
||||
"detoured": true
|
||||
},
|
||||
"position_error_m": 0.061990953005132014,
|
||||
"yaw_error_rad": 0.00967111226828532,
|
||||
"settle_latency_sim_s": 0.14000000000000057,
|
||||
"min_obstacle_clearance_m": 0.1927462944302255
|
||||
},
|
||||
{
|
||||
"name": "straight",
|
||||
"lap": 2,
|
||||
"ok": true,
|
||||
"checks": {
|
||||
"acknowledged": true,
|
||||
"active": true,
|
||||
"succeeded": true,
|
||||
"arrival": true,
|
||||
"yaw": true,
|
||||
"stopped": true,
|
||||
"commands_observed": true,
|
||||
"moved": true,
|
||||
"bounded_braking": true,
|
||||
"stopped_rotation": true
|
||||
},
|
||||
"position_error_m": 0.04630451980835924,
|
||||
"yaw_error_rad": 0.012513910620132433,
|
||||
"settle_latency_sim_s": 0.14999999999999147,
|
||||
"min_obstacle_clearance_m": null
|
||||
},
|
||||
{
|
||||
"name": "lateral",
|
||||
"lap": 2,
|
||||
"ok": true,
|
||||
"checks": {
|
||||
"acknowledged": true,
|
||||
"active": true,
|
||||
"succeeded": true,
|
||||
"arrival": true,
|
||||
"yaw": true,
|
||||
"stopped": true,
|
||||
"commands_observed": true,
|
||||
"moved": true,
|
||||
"lateral_command": true,
|
||||
"bounded_braking": true,
|
||||
"stopped_rotation": true
|
||||
},
|
||||
"position_error_m": 0.06639365123485702,
|
||||
"yaw_error_rad": 0.014776963732141702,
|
||||
"settle_latency_sim_s": 0.18000000000000682,
|
||||
"min_obstacle_clearance_m": null
|
||||
},
|
||||
{
|
||||
"name": "return_and_turn",
|
||||
"lap": 2,
|
||||
"ok": true,
|
||||
"checks": {
|
||||
"acknowledged": true,
|
||||
"active": true,
|
||||
"succeeded": true,
|
||||
"arrival": true,
|
||||
"yaw": true,
|
||||
"stopped": true,
|
||||
"commands_observed": true,
|
||||
"moved": true,
|
||||
"bounded_braking": true,
|
||||
"stopped_rotation": true
|
||||
},
|
||||
"position_error_m": 0.04614392008857156,
|
||||
"yaw_error_rad": 0.014109197250406158,
|
||||
"settle_latency_sim_s": 0.11999999999999034,
|
||||
"min_obstacle_clearance_m": null
|
||||
},
|
||||
{
|
||||
"name": "detour",
|
||||
"lap": 2,
|
||||
"ok": true,
|
||||
"checks": {
|
||||
"acknowledged": true,
|
||||
"active": true,
|
||||
"succeeded": true,
|
||||
"arrival": true,
|
||||
"yaw": true,
|
||||
"stopped": true,
|
||||
"commands_observed": true,
|
||||
"moved": true,
|
||||
"bounded_braking": true,
|
||||
"stopped_rotation": true,
|
||||
"physical_clearance": true,
|
||||
"detoured": true
|
||||
},
|
||||
"position_error_m": 0.07400250205784548,
|
||||
"yaw_error_rad": 0.011631284615572168,
|
||||
"settle_latency_sim_s": 0.12000000000000455,
|
||||
"min_obstacle_clearance_m": 0.15503089744180193
|
||||
}
|
||||
],
|
||||
"teardown": {
|
||||
"port_free": true,
|
||||
"never_touched_unknown_pid": true
|
||||
}
|
||||
},
|
||||
"terrain_mild_r2": {
|
||||
"status": "PASS",
|
||||
"evidence": "sim_ws/log/codex_release_20261108/terrain_mild_r2/result.json",
|
||||
"evidence_sha256": "ff2c2544dbdf7055a2d3531b8ff076025f61c2bbc6d148fa54d573f77f2bf948",
|
||||
"sensor_profile": "mild",
|
||||
"collector_sha256": "3c6382b0c5251fbc007d73c4f37242a70df0256250f2a1279654ef1282f2994a",
|
||||
"cases": {
|
||||
"uphill": {
|
||||
"ok": true,
|
||||
"checks": {
|
||||
"acknowledged": true,
|
||||
"state_as_expected": true,
|
||||
"perception_fresh": true,
|
||||
"original_goal_preserved": true,
|
||||
"stopped": true,
|
||||
"bounded_braking": true,
|
||||
"estimated_lateral_error": true,
|
||||
"estimated_vertical_error": true,
|
||||
"active": true,
|
||||
"physical_arrival": true,
|
||||
"physical_height": true,
|
||||
"ramp_pitch": true,
|
||||
"ramp_height": true,
|
||||
"lane": true,
|
||||
"full_body_clearance": true,
|
||||
"real_ramp_contacts": true,
|
||||
"penetration": true
|
||||
},
|
||||
"position_error_m": 0.028680483190210784,
|
||||
"braking_latency_sim_s": 0.11999999999999744,
|
||||
"min_full_body_clearance_m": 0.06482840712059285,
|
||||
"estimated_max_abs_xyz_error_m": [
|
||||
0.053319918336580674,
|
||||
0.028895799450061155,
|
||||
0.025941580729327784
|
||||
],
|
||||
"fault_event": {}
|
||||
},
|
||||
"stairs_rejected": {
|
||||
"ok": true,
|
||||
"checks": {
|
||||
"acknowledged": true,
|
||||
"state_as_expected": true,
|
||||
"perception_fresh": true,
|
||||
"original_goal_preserved": true,
|
||||
"stopped": true,
|
||||
"bounded_braking": true,
|
||||
"estimated_lateral_error": true,
|
||||
"estimated_vertical_error": true,
|
||||
"never_active": true,
|
||||
"stationary": true,
|
||||
"zero_commands": true
|
||||
},
|
||||
"position_error_m": 1.3214972395089783,
|
||||
"braking_latency_sim_s": 0.02999999999999403,
|
||||
"min_full_body_clearance_m": 0.06482840712059645,
|
||||
"estimated_max_abs_xyz_error_m": [
|
||||
0.044053670958435154,
|
||||
0.027738692141753063,
|
||||
0.009076480897324157
|
||||
],
|
||||
"fault_event": {}
|
||||
},
|
||||
"edge_rejected": {
|
||||
"ok": true,
|
||||
"checks": {
|
||||
"acknowledged": true,
|
||||
"state_as_expected": true,
|
||||
"perception_fresh": true,
|
||||
"original_goal_preserved": true,
|
||||
"stopped": true,
|
||||
"bounded_braking": true,
|
||||
"estimated_lateral_error": true,
|
||||
"estimated_vertical_error": true,
|
||||
"never_active": true,
|
||||
"stationary": true,
|
||||
"zero_commands": true
|
||||
},
|
||||
"position_error_m": 2.2162660616700633,
|
||||
"braking_latency_sim_s": 0.030000000000001137,
|
||||
"min_full_body_clearance_m": 0.06482840712059645,
|
||||
"estimated_max_abs_xyz_error_m": [
|
||||
0.043190625604138555,
|
||||
0.027076328623278467,
|
||||
0.008885946744428663
|
||||
],
|
||||
"fault_event": {}
|
||||
},
|
||||
"downhill": {
|
||||
"ok": true,
|
||||
"checks": {
|
||||
"acknowledged": true,
|
||||
"state_as_expected": true,
|
||||
"perception_fresh": true,
|
||||
"original_goal_preserved": true,
|
||||
"stopped": true,
|
||||
"bounded_braking": true,
|
||||
"estimated_lateral_error": true,
|
||||
"estimated_vertical_error": true,
|
||||
"active": true,
|
||||
"physical_arrival": true,
|
||||
"physical_height": true,
|
||||
"ramp_pitch": true,
|
||||
"ramp_height": true,
|
||||
"lane": true,
|
||||
"full_body_clearance": true,
|
||||
"real_ramp_contacts": true,
|
||||
"penetration": true
|
||||
},
|
||||
"position_error_m": 0.05755757998781817,
|
||||
"braking_latency_sim_s": 0.09999999999999432,
|
||||
"min_full_body_clearance_m": 0.057893292463502,
|
||||
"estimated_max_abs_xyz_error_m": [
|
||||
0.04282737266180492,
|
||||
0.027281887775965963,
|
||||
0.023447749141021323
|
||||
],
|
||||
"fault_event": {}
|
||||
}
|
||||
},
|
||||
"teardown": {
|
||||
"port_free": true,
|
||||
"never_touched_unknown_pid": true
|
||||
}
|
||||
},
|
||||
"blue_corridor_regression": {
|
||||
"status": "PASS",
|
||||
"evidence": "sim_ws/log/codex_release_20261108/blue_corridor_regression/result.json",
|
||||
"evidence_sha256": "d72a5f11b17f3a886ee2275a595d9c2680ee4f322ce84be469638fb09faf4f1a",
|
||||
"sensor_profile": "ideal",
|
||||
"collector_sha256": "3c6382b0c5251fbc007d73c4f37242a70df0256250f2a1279654ef1282f2994a",
|
||||
"cases": {
|
||||
"uphill": {
|
||||
"ok": true,
|
||||
"checks": {
|
||||
"acknowledged": true,
|
||||
"state_as_expected": true,
|
||||
"perception_fresh": true,
|
||||
"original_goal_preserved": true,
|
||||
"stopped": true,
|
||||
"bounded_braking": true,
|
||||
"estimated_lateral_error": true,
|
||||
"estimated_vertical_error": true,
|
||||
"downstream_hold_exercised": true,
|
||||
"downstream_readiness_revoked": true,
|
||||
"downstream_stop_in_time": true,
|
||||
"downstream_held_still": true,
|
||||
"downstream_new_grant": true,
|
||||
"active": true,
|
||||
"physical_arrival": true,
|
||||
"physical_height": true,
|
||||
"ramp_pitch": true,
|
||||
"ramp_height": true,
|
||||
"lane": true,
|
||||
"full_body_clearance": true,
|
||||
"real_ramp_contacts": true,
|
||||
"penetration": true
|
||||
},
|
||||
"position_error_m": 0.019937342176674627,
|
||||
"braking_latency_sim_s": 0.18999999999999773,
|
||||
"min_full_body_clearance_m": 0.07886910031850819,
|
||||
"estimated_max_abs_xyz_error_m": [
|
||||
0.05116479906699667,
|
||||
0.010588440037797575,
|
||||
0.028374928233226182
|
||||
],
|
||||
"fault_event": {
|
||||
"start": 19.560000000000002,
|
||||
"resumed": 20.380000000000003,
|
||||
"stop_latency_sim_s": 0.31999999999999673
|
||||
}
|
||||
},
|
||||
"stairs_rejected": {
|
||||
"ok": true,
|
||||
"checks": {
|
||||
"acknowledged": true,
|
||||
"state_as_expected": true,
|
||||
"perception_fresh": true,
|
||||
"original_goal_preserved": true,
|
||||
"stopped": true,
|
||||
"bounded_braking": true,
|
||||
"estimated_lateral_error": true,
|
||||
"estimated_vertical_error": true,
|
||||
"never_active": true,
|
||||
"stationary": true,
|
||||
"zero_commands": true
|
||||
},
|
||||
"position_error_m": 1.3190224471138856,
|
||||
"braking_latency_sim_s": 0.01999999999999602,
|
||||
"min_full_body_clearance_m": 0.08126798839097155,
|
||||
"estimated_max_abs_xyz_error_m": [
|
||||
0.048105127307717765,
|
||||
0.007605746505156219,
|
||||
0.0273752456958386
|
||||
],
|
||||
"fault_event": {}
|
||||
},
|
||||
"edge_rejected": {
|
||||
"ok": true,
|
||||
"checks": {
|
||||
"acknowledged": true,
|
||||
"state_as_expected": true,
|
||||
"perception_fresh": true,
|
||||
"original_goal_preserved": true,
|
||||
"stopped": true,
|
||||
"bounded_braking": true,
|
||||
"estimated_lateral_error": true,
|
||||
"estimated_vertical_error": true,
|
||||
"never_active": true,
|
||||
"stationary": true,
|
||||
"zero_commands": true
|
||||
},
|
||||
"position_error_m": 2.2162075663942207,
|
||||
"braking_latency_sim_s": 0.04000000000000625,
|
||||
"min_full_body_clearance_m": 0.08126798839097155,
|
||||
"estimated_max_abs_xyz_error_m": [
|
||||
0.04456799056518723,
|
||||
0.006945733931256637,
|
||||
0.027032214026139534
|
||||
],
|
||||
"fault_event": {}
|
||||
},
|
||||
"downhill": {
|
||||
"ok": true,
|
||||
"checks": {
|
||||
"acknowledged": true,
|
||||
"state_as_expected": true,
|
||||
"perception_fresh": true,
|
||||
"original_goal_preserved": true,
|
||||
"stopped": true,
|
||||
"bounded_braking": true,
|
||||
"estimated_lateral_error": true,
|
||||
"estimated_vertical_error": true,
|
||||
"active": true,
|
||||
"physical_arrival": true,
|
||||
"physical_height": true,
|
||||
"ramp_pitch": true,
|
||||
"ramp_height": true,
|
||||
"lane": true,
|
||||
"full_body_clearance": true,
|
||||
"real_ramp_contacts": true,
|
||||
"penetration": true
|
||||
},
|
||||
"position_error_m": 0.055395886084998396,
|
||||
"braking_latency_sim_s": 0.15000000000000568,
|
||||
"min_full_body_clearance_m": 0.08126798839097155,
|
||||
"estimated_max_abs_xyz_error_m": [
|
||||
0.04549692742840161,
|
||||
0.009324941391017916,
|
||||
0.02780228843285104
|
||||
],
|
||||
"fault_event": {}
|
||||
}
|
||||
},
|
||||
"teardown": {
|
||||
"port_free": true,
|
||||
"never_touched_unknown_pid": true
|
||||
}
|
||||
},
|
||||
"mild_loss_stop": {
|
||||
"status": "PASS",
|
||||
"evidence": "sim_ws/log/codex_release_20261108/mild_loss_stop/result.json",
|
||||
"evidence_sha256": "ccc5ce538fff1925224230cd11c3586b9533da548506efead91fdd993a7b1a35",
|
||||
"sensor_profile": "mild",
|
||||
"laps": 1,
|
||||
"split": false,
|
||||
"collector_sha256": "306f940d738715741e8e372a92215abb5a157127f4f814bd0642bf748cea7981",
|
||||
"cases": [
|
||||
{
|
||||
"name": "lio_loss_stop",
|
||||
"ok": true,
|
||||
"checks": {
|
||||
"started_moving": true,
|
||||
"readiness_revoked": true,
|
||||
"stopped_in_time": true,
|
||||
"remained_stopped": true,
|
||||
"no_truth_fallback": true,
|
||||
"restart_latched_stopped": true,
|
||||
"no_motion_after_resume": true
|
||||
},
|
||||
"stop_latency_sim_s": 0.3399999999999981,
|
||||
"drift_m": 0.0
|
||||
}
|
||||
],
|
||||
"teardown": {
|
||||
"port_free": true,
|
||||
"never_touched_unknown_pid": true
|
||||
}
|
||||
},
|
||||
"ideal_sensor_regression": {
|
||||
"status": "PASS",
|
||||
"evidence": "sim_ws/log/codex_release_20261108/ideal_sensor_regression/result.json",
|
||||
"evidence_sha256": "1b0afc239e71a2d0a6759fb1915cae25ca6e5e8897a6b8d7861e7d8758b54f75",
|
||||
"checks": {
|
||||
"geometry": true,
|
||||
"frame_and_count": true,
|
||||
"finite_fov": true,
|
||||
"timebase": true,
|
||||
"actual_batch_times": true,
|
||||
"frame_rate": true,
|
||||
"livox_flags": true,
|
||||
"ray_budget": true,
|
||||
"pattern_continues": true,
|
||||
"imu_specific_force": true,
|
||||
"imu_frame_rate": true,
|
||||
"no_attitude_oracle": true,
|
||||
"imu_continuity": true,
|
||||
"gyro_motion": true,
|
||||
"real_scan_distortion": true,
|
||||
"free_fall_imu": true
|
||||
},
|
||||
"collector_sha256": "242fc8b6f72ecce377dc74ed7b925fa8413a132ff3ca8349b2bc9e12fb972684",
|
||||
"measured_imu_rate_hz": 199.9764871855161,
|
||||
"maximum_imu_interval_s": 0.0070000000000014495,
|
||||
"teardown": {
|
||||
"port_free": true,
|
||||
"never_touched_unknown_pid": true
|
||||
}
|
||||
},
|
||||
"post_build_straight": {
|
||||
"status": "PASS",
|
||||
"evidence": "sim_ws/log/codex_release_20261108/post_build_straight/result.json",
|
||||
"evidence_sha256": "1f9e28e416e034c716c7229f3b980bc7fdcfbc2e5bc90cf32f1bf7995add9d7f",
|
||||
"sensor_profile": "ideal",
|
||||
"laps": 1,
|
||||
"split": false,
|
||||
"collector_sha256": "306f940d738715741e8e372a92215abb5a157127f4f814bd0642bf748cea7981",
|
||||
"cases": [
|
||||
{
|
||||
"name": "straight",
|
||||
"lap": 1,
|
||||
"ok": true,
|
||||
"checks": {
|
||||
"acknowledged": true,
|
||||
"active": true,
|
||||
"succeeded": true,
|
||||
"arrival": true,
|
||||
"yaw": true,
|
||||
"stopped": true,
|
||||
"commands_observed": true,
|
||||
"moved": true,
|
||||
"bounded_braking": true,
|
||||
"stopped_rotation": true
|
||||
},
|
||||
"position_error_m": 0.06099977673871584,
|
||||
"yaw_error_rad": 2.9687464687140706e-15,
|
||||
"settle_latency_sim_s": 0.14000000000000057,
|
||||
"min_obstacle_clearance_m": null
|
||||
}
|
||||
],
|
||||
"teardown": {
|
||||
"port_free": true,
|
||||
"never_touched_unknown_pid": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"assets": {
|
||||
"status": "PASS",
|
||||
"check_count": 18,
|
||||
"evidence": "sim_ws/log/codex_release_20261108/assets_final/assets.json",
|
||||
"evidence_sha256": "19968efd281c01db37ec2a5ebebd0f16de2bd5d5cdaa58a1fcd7f2614b682191"
|
||||
},
|
||||
"algorithm_only_launch": {
|
||||
"status": "PASS",
|
||||
"requested_packages": [
|
||||
"br_sim_bringup"
|
||||
],
|
||||
"no_robot_or_gazebo_package_lookup": true
|
||||
},
|
||||
"actual_spawned_models": {
|
||||
"noise_stress_r2": {
|
||||
"path": "sim_ws/log/codex_release_20261108/noise_stress_r2/actual_model.sdf",
|
||||
"sha256": "45a402a9fce97a71fc241212e9e49cdbdd2df15135f70c387f1725780a5a4b41",
|
||||
"noise": {
|
||||
"mid360_imu": {
|
||||
"accel_stddev": "0.04",
|
||||
"gyro_stddev": "0.0015",
|
||||
"accel_bias": "0.02 0.01 0.03",
|
||||
"gyro_bias": "0.0005 -0.0005 0.001",
|
||||
"noise_seed": "2027"
|
||||
},
|
||||
"mid360_sensor": {
|
||||
"range_stddev": "0.015",
|
||||
"dropout": "0.05",
|
||||
"noise_seed": "2027"
|
||||
}
|
||||
}
|
||||
},
|
||||
"continuous_split_mild_r2": {
|
||||
"path": "sim_ws/log/codex_release_20261108/continuous_split_mild_r2/actual_model.sdf",
|
||||
"sha256": "b6673ab9ade199b8c5c99bc68473ef211cc6f1072acac989b448dd7cfb890c9b",
|
||||
"noise": {
|
||||
"mid360_imu": {
|
||||
"accel_stddev": "0.01",
|
||||
"gyro_stddev": "0.0005",
|
||||
"accel_bias": "0.005 -0.005 0.01",
|
||||
"gyro_bias": "0.0001 -0.0001 0.0002",
|
||||
"noise_seed": "2027"
|
||||
},
|
||||
"mid360_sensor": {
|
||||
"range_stddev": "0.005",
|
||||
"dropout": "0.01",
|
||||
"noise_seed": "2027"
|
||||
}
|
||||
}
|
||||
},
|
||||
"terrain_mild": {
|
||||
"path": "sim_ws/log/codex_release_20261108/terrain_mild/actual_model.sdf",
|
||||
"sha256": "b6673ab9ade199b8c5c99bc68473ef211cc6f1072acac989b448dd7cfb890c9b",
|
||||
"noise": {
|
||||
"mid360_imu": {
|
||||
"accel_stddev": "0.01",
|
||||
"gyro_stddev": "0.0005",
|
||||
"accel_bias": "0.005 -0.005 0.01",
|
||||
"gyro_bias": "0.0001 -0.0001 0.0002",
|
||||
"noise_seed": "2027"
|
||||
},
|
||||
"mid360_sensor": {
|
||||
"range_stddev": "0.005",
|
||||
"dropout": "0.01",
|
||||
"noise_seed": "2027"
|
||||
}
|
||||
}
|
||||
},
|
||||
"low_obstacles_r2": {
|
||||
"path": "sim_ws/log/codex_release_20261108/low_obstacles_r2/actual_model.sdf",
|
||||
"sha256": "7940ed9e51e6ae4bb79ec1a40cd368f98cf324495bbf76d160085480b08d8731",
|
||||
"noise": {
|
||||
"mid360_imu": {
|
||||
"accel_stddev": "0.0",
|
||||
"gyro_stddev": "0.0",
|
||||
"accel_bias": "0.0 0.0 0.0",
|
||||
"gyro_bias": "0.0 0.0 0.0",
|
||||
"noise_seed": "2027"
|
||||
},
|
||||
"mid360_sensor": {
|
||||
"range_stddev": "0.0",
|
||||
"dropout": "0.0",
|
||||
"noise_seed": "2027"
|
||||
}
|
||||
}
|
||||
},
|
||||
"terrain_mild_r2": {
|
||||
"path": "sim_ws/log/codex_release_20261108/terrain_mild_r2/actual_model.sdf",
|
||||
"sha256": "b6673ab9ade199b8c5c99bc68473ef211cc6f1072acac989b448dd7cfb890c9b",
|
||||
"noise": {
|
||||
"mid360_imu": {
|
||||
"accel_stddev": "0.01",
|
||||
"gyro_stddev": "0.0005",
|
||||
"accel_bias": "0.005 -0.005 0.01",
|
||||
"gyro_bias": "0.0001 -0.0001 0.0002",
|
||||
"noise_seed": "2027"
|
||||
},
|
||||
"mid360_sensor": {
|
||||
"range_stddev": "0.005",
|
||||
"dropout": "0.01",
|
||||
"noise_seed": "2027"
|
||||
}
|
||||
}
|
||||
},
|
||||
"blue_corridor_regression": {
|
||||
"path": "sim_ws/log/codex_release_20261108/blue_corridor_regression/actual_model.sdf",
|
||||
"sha256": "7940ed9e51e6ae4bb79ec1a40cd368f98cf324495bbf76d160085480b08d8731",
|
||||
"noise": {
|
||||
"mid360_imu": {
|
||||
"accel_stddev": "0.0",
|
||||
"gyro_stddev": "0.0",
|
||||
"accel_bias": "0.0 0.0 0.0",
|
||||
"gyro_bias": "0.0 0.0 0.0",
|
||||
"noise_seed": "2027"
|
||||
},
|
||||
"mid360_sensor": {
|
||||
"range_stddev": "0.0",
|
||||
"dropout": "0.0",
|
||||
"noise_seed": "2027"
|
||||
}
|
||||
}
|
||||
},
|
||||
"mild_loss_stop": {
|
||||
"path": "sim_ws/log/codex_release_20261108/mild_loss_stop/actual_model.sdf",
|
||||
"sha256": "b6673ab9ade199b8c5c99bc68473ef211cc6f1072acac989b448dd7cfb890c9b",
|
||||
"noise": {
|
||||
"mid360_imu": {
|
||||
"accel_stddev": "0.01",
|
||||
"gyro_stddev": "0.0005",
|
||||
"accel_bias": "0.005 -0.005 0.01",
|
||||
"gyro_bias": "0.0001 -0.0001 0.0002",
|
||||
"noise_seed": "2027"
|
||||
},
|
||||
"mid360_sensor": {
|
||||
"range_stddev": "0.005",
|
||||
"dropout": "0.01",
|
||||
"noise_seed": "2027"
|
||||
}
|
||||
}
|
||||
},
|
||||
"ideal_sensor_regression": {
|
||||
"path": "sim_ws/log/codex_release_20261108/ideal_sensor_regression/actual_model.sdf",
|
||||
"sha256": "7940ed9e51e6ae4bb79ec1a40cd368f98cf324495bbf76d160085480b08d8731",
|
||||
"noise": {
|
||||
"mid360_imu": {
|
||||
"accel_stddev": "0.0",
|
||||
"gyro_stddev": "0.0",
|
||||
"accel_bias": "0.0 0.0 0.0",
|
||||
"gyro_bias": "0.0 0.0 0.0",
|
||||
"noise_seed": "2027"
|
||||
},
|
||||
"mid360_sensor": {
|
||||
"range_stddev": "0.0",
|
||||
"dropout": "0.0",
|
||||
"noise_seed": "2027"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"cleanup": {
|
||||
"status": "PASS",
|
||||
"obsolete_paths_rechecked": 35,
|
||||
"all_obsolete_paths_absent": true,
|
||||
"obsolete_document_count": 4,
|
||||
"ignored_backup_sha256": "c644a6a5049ad59b0ac2f9d37028994f57848d7e5d6cc5fffe76b022b7ef3721",
|
||||
"evidence_sha256": "3f423f01c8ded8f91bf8fa5cdd9b09666bc5504eab001744562341b6036e113e",
|
||||
"retained": [
|
||||
"外部原始模型资源",
|
||||
"当前 Classic/navigation/localization 构建与安装前缀",
|
||||
"Git 忽略的历史测试原始证据"
|
||||
],
|
||||
"note": "生成缓存不入库;不卸载 Classic 仍需使用的 ignition::math 库"
|
||||
},
|
||||
"final_source_sha256": {
|
||||
"minco_ws/src/perception/Point-LIO/CMakeLists.txt": "6f7659981848f0514ad781f594e54cebe055fc087ed4a1a232297bea2b3b275e",
|
||||
"minco_ws/src/perception/Point-LIO/package.xml": "298158a9ce01726bb4a6f430ce1e9a8fd9b0206b987a85d7d5478058f7b1aa73",
|
||||
"minco_ws/src/perception/livox_ros_driver2/CMakeLists.txt": "f0bc8c2779f4fa1de54e40e24c0a9b5cd75f248e346c7e4258d6c727b2b1091c",
|
||||
"minco_ws/src/perception/livox_ros_driver2/package.xml": "746a1bf6dfb9e3b60cd39af1493959deedf71b4a75f5491a9fcca5a3de46f94d",
|
||||
"minco_ws/src/scan/plan_manage/CMakeLists.txt": "8c54e7e667d8e267dd76b93cad58a0d6fa0ff879c7f666d2abe83df491f1d675",
|
||||
"minco_ws/src/scan/plan_manage/include/plan_manage/planner_manager.h": "e047fa4a968b0bb3ae36185de142997e32c97c07b537945a1dd428681d9c0445",
|
||||
"minco_ws/src/scan/plan_manage/include/plan_manage/scan_replan_fsm.h": "3f2ab7394d77e7cb4b8a8e72051dbe59af0d6ff393ccbb40f5dad0461f842c1e",
|
||||
"minco_ws/src/scan/plan_manage/include/plan_manage/terrain_velocity_utils.h": "d8b15dd684a8d31949c36c53dc8e81a64e2c8f915d7bb9916db6f9a091c00ce1",
|
||||
"minco_ws/src/scan/plan_manage/src/closed_loop_controller.cpp": "b2714df1493f4365a31b5cd17ab8ad2e47c4f5fcaaf14313bb219993d9bc8fec",
|
||||
"minco_ws/src/scan/plan_manage/src/planner_manager.cpp": "4ade56a2366cf0b65644758e8adc97036542d883cbbdece159ceef871cad56aa",
|
||||
"minco_ws/src/scan/plan_manage/src/scan_replan_fsm.cpp": "2f820153523a08ece6c7322a68c9260b373959339370e66a77aa5ca5d459c89c",
|
||||
"minco_ws/src/scan/plan_manage/test/test_terrain_velocity.cpp": "a3c9d36935d8caff0a95c99c9f8ebdaabea673f8b404f63dabba62c564f29b9c",
|
||||
"sim_ws/src/br_sim_bringup/CMakeLists.txt": "fc4f0ca02e396b692861e146266dce437cd4de72547da0e407490e8df2486376",
|
||||
"sim_ws/src/br_sim_bringup/config/lio_navigation.yaml": "3bf945773255e1a2a69ef371873f870a9982a92b7c931e520f7b458c81ddb1a9",
|
||||
"sim_ws/src/br_sim_bringup/config/lio_terrain.yaml": "e137f3b0d7ef2e25a02ea3b95f5527c7ca3d1ee5bb051d8f2c3ae9ddcc5f37f7",
|
||||
"sim_ws/src/br_sim_bringup/config/point_lio_sim.yaml": "5a515c76e62e7dd5a1e187c357c4df182987c456c2802be455c928c4c59537c5",
|
||||
"sim_ws/src/br_sim_bringup/config/point_lio_terrain.yaml": "17dfab42e9f92f7ad698d3de3da90809ef6c07b6e2c529ff930c0dd5bb1d40e9",
|
||||
"sim_ws/src/br_sim_bringup/config/scan_sim.yaml": "501eb7fdba9928b8a12def3459ea087fa0596bebfeeba5c2300b081ba8933e75",
|
||||
"sim_ws/src/br_sim_bringup/config/terrain_sim.yaml": "d6cca69dd83faa638bf3dd56713897348a10255f61b5e9935e7ed8c3893c12cb",
|
||||
"sim_ws/src/br_sim_bringup/launch/mid360_sim.launch.py": "94eca893cb146ac61ae159d3640da7516b767fb61088eed38dcaa53c9cf4c4ce",
|
||||
"sim_ws/src/br_sim_bringup/launch/scan_lio.launch.py": "79525745471938c55d828955b5939dcb8dba3d7cb92afdffd6ae1026a0ca1b78",
|
||||
"sim_ws/src/br_sim_bringup/launch/scan_lio_split.launch.py": "f4139bb1eb0f817b3c5116a44e13f8e4e27c0af9fe20e0352ebfaf9f12bdb8d7",
|
||||
"sim_ws/src/br_sim_bringup/launch/scan_lio_terrain.launch.py": "b63308b64fe4445d2f64ca0256609a8c0d41fde1d12d23c6509f2f867726623b",
|
||||
"sim_ws/src/br_sim_bringup/launch/scan_sim.launch.py": "607f25e4b6535dc95021eb2b577f7fb0e4c59366dad1217627ba71dcc1759edf",
|
||||
"sim_ws/src/br_sim_bringup/launch/scan_terrain.launch.py": "dd31a0f356ac20b6da285f5ce2f3a32e3799ffd44d7201d9d2ae302a1e0f0b4a",
|
||||
"sim_ws/src/br_sim_bringup/package.xml": "55c23fb472d539048f4b15571b2f166c03cc3e4e47b39fd3f06fbb514c9cf282",
|
||||
"sim_ws/src/br_sim_bringup/scripts/lio_navigation_adapter.py": "67c53d33fd3426425c594e7b503f21d8647cc100d72156097cb9e0c2362c58fd",
|
||||
"sim_ws/src/br_sim_bringup/scripts/scan_cloud_gate.py": "a75afa496a3afea53b9ec86e04cfe03dc4bbb3748e1349db1e8b03c471871fc1",
|
||||
"sim_ws/src/r2027_robot_description/CMakeLists.txt": "4a1f19479f2f09f7e5eba0dbfac7362363a97d561f2d7c9d9bf7353c4aebbd54",
|
||||
"sim_ws/src/r2027_robot_description/SOURCE_PROVENANCE.md": "ec05e462d584c44216bd070c0ed2485a8a7df52ee31bcf2fd9d226527da77fe9",
|
||||
"sim_ws/src/r2027_robot_description/config/gazebo.yaml": "284bca1365bf96f43eee8cdb6ed3d7420b7ef27813eea447eab2009792dee1c0",
|
||||
"sim_ws/src/r2027_robot_description/config/sensor_profiles.yaml": "73cbf9bd478e78a920325ec34701febe0df8570f2010bf2a11f81337252c9078",
|
||||
"sim_ws/src/r2027_robot_description/launch/robocon_robot.launch.py": "249050baebf070602b47121cbdb73272165c807d1ac189beb4b1f109ee5035c5",
|
||||
"sim_ws/src/r2027_robot_description/package.xml": "d852aa9a5d7ac40ee7927214bd5763052bf443af4e7dc2083c8dbff0a31036a6",
|
||||
"sim_ws/src/r2027_robot_description/scripts/cmd_vel_timeout.py": "aaf74dec186a5d0ce19e25b25bad871b86cd64786071000548d114a5f0611b98",
|
||||
"sim_ws/src/r2027_robot_description/scripts/sim_data_adapter.py": "5d6337243068cfd17e6548f230c1e354b5d264469eb1655ee97b28affa98afab",
|
||||
"sim_ws/src/r2027_robot_description/sdf/r2027_omni_robot.sdf.xacro": "6896dd217d81ee2dd319c07ef29b788ea2eb37755d442216ed02ff938babffb7",
|
||||
"sim_ws/src/r2027_robot_description/src/contact_drive.cpp": "874e9aa0704edcf13cd3c8a29e98fa974595e06bc32aef732c549d4148c006f4",
|
||||
"sim_ws/src/r2027_robot_description/src/mid360_imu.cpp": "8e10f125bb172ca77db54e28f7b7a32903ec8271f453c988722ace17738636be",
|
||||
"sim_ws/src/r2027_robot_description/src/mid360_sensor.cpp": "ceafdbbe623467e7cbb665104c75d66c9ce230be160f59997efbb48e38efdaa2",
|
||||
"sim_ws/src/robocon_gazebo/CMakeLists.txt": "7a27947f7880dc844323b6c16d6d30cd0d695c47ab403e9c6c6917569e829aca",
|
||||
"sim_ws/src/robocon_gazebo/SOURCE_PROVENANCE.md": "4bdf54fa6fcb80c309f6ad76d1fb75a6aa6e1c5cb19464dc9147182ef6771bcb",
|
||||
"sim_ws/src/robocon_gazebo/launch/robocon_gazebo.launch.py": "bdc519ed6ec827f8dd7d3824a087cbba48bb5b13027e4748f30db91f14d637b3",
|
||||
"sim_ws/src/robocon_gazebo/models/robocon_ground_full/meshes/Untitled.dae": "f69ef7a035924a9eac48e53df4e2fbd9eeb22312712f8e4f2e78f935b9d007bb",
|
||||
"sim_ws/src/robocon_gazebo/models/robocon_ground_full/meshes/ramp.obj": "c53e36c47838b79d93de6d6119e5089ace361808af9a6fff48b9952885894dcd",
|
||||
"sim_ws/src/robocon_gazebo/models/robocon_ground_full/model.config": "9a6e197fad5a32a48f7055e3bd7cd3147e65c21b08d1530d69264921e5990864",
|
||||
"sim_ws/src/robocon_gazebo/models/robocon_ground_full/model.sdf": "f7bb3481dfb626ee87a05347c51c64b2075479383a3cd255af50cc587844cc4a",
|
||||
"sim_ws/src/robocon_gazebo/package.xml": "a3b0b0764b641847cd765cf46f1eb3e351c171a15412fe953e0979218e2d4466",
|
||||
"sim_ws/src/robocon_gazebo/worlds/robocon_robot.world": "711a031dc66156ad7670523bd691e59002892d9d70b13a96eeec1dc94f9b918c",
|
||||
"sim_ws/src/robocon_gazebo/worlds/robocon_track_full.world": "e26310e8e0e7e9e97c352b197129cbeb4c88f45a14f4e388e68ba8adaa080055",
|
||||
"sim_ws/tools/build_sim.sh": "3f8c9c7ac5ccb173a9c59ac71e39d2a65a3a012be470727cea1ae8f01ecd13d2",
|
||||
"sim_ws/tools/check_classic_baseline.py": "1c4c007c51170b48d21243dbfdae7597352fa6ae28e3f4af14c4035e264b4620",
|
||||
"sim_ws/tools/check_lio_navigation.py": "306f940d738715741e8e372a92215abb5a157127f4f814bd0642bf748cea7981",
|
||||
"sim_ws/tools/check_lio_terrain.py": "3c6382b0c5251fbc007d73c4f37242a70df0256250f2a1279654ef1282f2994a",
|
||||
"sim_ws/tools/check_low_obstacles.py": "cedefe856ecc66624d25bea1d753f6bd3c4a899a99a535f663c04441a392411a",
|
||||
"sim_ws/tools/check_mid360.py": "242fc8b6f72ecce377dc74ed7b925fa8413a132ff3ca8349b2bc9e12fb972684",
|
||||
"sim_ws/tools/check_narrow_navigation.py": "1a46b387e7e298f6abd53af29a1cafdaba272df9d03b08271bafbc16c13d4b0d",
|
||||
"sim_ws/tools/check_omni_robot.py": "e8684fdd57c4c4fb730de9ea9ad05bc44eb4db67222e16b3edd2a888eb259050",
|
||||
"sim_ws/tools/check_point_lio.py": "d40a973e0510541a00e1c0bef670fede1a88406a5506d643b2106c2fc374a22c",
|
||||
"sim_ws/tools/check_scan_navigation.py": "d92e7e5c59f6be928f6307c0061c252a349de7268a7fbf8e92efe5feafd1fc31",
|
||||
"sim_ws/tools/check_sensor_noise.py": "ed063014c8b63151f503824f7869ae2e2b97e2cd85a20cbd446804faf4293d06",
|
||||
"sim_ws/tools/check_sim_lidar.py": "369b351d270dab9a523fafa2073bf463654a9ebde9e5dc1188f440c2f1633ae3",
|
||||
"sim_ws/tools/check_slope_drive.py": "85b0a26d6ac7c4453ee30fc10c2a00e0cf233503fcc54ff9f0fdc53686077499",
|
||||
"sim_ws/tools/check_slope_navigation.py": "39ee1ed0497c83475d30f542cbf63b45b9b10250720cac423b7c8ca38fb167f4",
|
||||
"sim_ws/tools/repair_ramp_winding.py": "09ba9b3795c01270e5921a57e6cf9a7e3d94a39a7d2245d603b39e2aacce95a3",
|
||||
"sim_ws/tools/test_lio_navigation_adapter.py": "4a5507dbb1a87efed50d3513327f9232b3ccd545e87bff0f830005a9f807a25b"
|
||||
},
|
||||
"source_hash_note": "final_source_sha256 为提交前源码快照;各次采集工具哈希另列,不把不同版本的旧试验声称为本次重跑。文档不自哈希。",
|
||||
"previous_phase_evidence": {
|
||||
"sim_ws/log/codex_p6_20261108/acceptance_summary.json": "628dfd6be62bec811201afaeff58af7b57ba13425ac7264852b22b0c32339000",
|
||||
"sim_ws/log/codex_p6_navigation_20261108/acceptance_summary.json": "a8423ce6acb349aae800610d706b1543cb223773d509dc2440fba4b0692253a2",
|
||||
"sim_ws/log/codex_p6_lio_terrain_20261108/acceptance_summary.json": "94812b72b229b46b67028aa7c1de3e0bd85f34356c265bc20807147c0bc2dec1"
|
||||
},
|
||||
"rejected_trials": {
|
||||
"noise_stress": "INVALID: launch argument declaration order; corrected, rerun",
|
||||
"noise_stress_r1": "FAIL: test assumed every IMU interval exactly 5 ms; physical timestamps preserved, continuity/mean-rate measured on rerun",
|
||||
"low_obstacles": "FAIL: wrong box visibility expectation; corrected FOV calculation includes far top corners",
|
||||
"low_obstacles_r1": "INVALID: asynchronous deletion plus entity name reuse; fixed with unique entities and independent state query",
|
||||
"continuous_split_mild_r1": "FAIL: terminal angular speed exceeded .20 s braking budget; tightened only simulated LIO yaw tolerance",
|
||||
"terrain_mild": "FAIL: planner could detour outside traversable ramp; explicit known side boundaries added only to planning branch",
|
||||
"terrain_mild_r1": "FAIL: oversized prior cloud caused stale downstream data and timeout; sparse 0.10 m prior, unchanged age limit"
|
||||
},
|
||||
"not_verified": [
|
||||
"真实厂家扫描轨迹、噪声标定、材质/多径、随机游走",
|
||||
"真实轮组/摩擦/打滑及实际尺寸外参",
|
||||
"真实跨机 DDS 网络与断网停车",
|
||||
"未知悬崖、任意低障碍避让",
|
||||
"完整比赛规则任务",
|
||||
"本轮 GUI/RViz 与实际 GPU renderer;按用户要求无截图",
|
||||
"硬件 SDK/驱动默认构建分支"
|
||||
],
|
||||
"shutdown": {
|
||||
"gazebo_port_11355_free": true
|
||||
},
|
||||
"git_policy": "用户授权 commit;不执行 push;原始大日志/构建产物不入库"
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
cmake_minimum_required(VERSION 3.8)
|
||||
project(br_sim_bringup)
|
||||
find_package(ament_cmake REQUIRED)
|
||||
install(DIRECTORY launch config DESTINATION share/${PROJECT_NAME}
|
||||
PATTERN "__pycache__" EXCLUDE)
|
||||
install(PROGRAMS scripts/scan_cloud_gate.py scripts/lio_navigation_adapter.py DESTINATION lib/${PROJECT_NAME})
|
||||
ament_package()
|
||||
@@ -0,0 +1,29 @@
|
||||
# Optional flat-ground LIO navigation profile. No real-vehicle files change.
|
||||
lio_navigation_adapter:
|
||||
ros__parameters:
|
||||
use_sim_time: true
|
||||
imu_position_base: [0.011, 0.02329, 0.25588]
|
||||
lidar_position_base: [0.0, 0.0, 0.30]
|
||||
ground_cutoff_z: 0.015
|
||||
|
||||
scan_planner_node:
|
||||
ros__parameters:
|
||||
manager.max_vel: 0.3
|
||||
optimization.max_vel: 0.3
|
||||
# Permit collision-checked replanning after a brief data hold near the goal.
|
||||
# Default legacy SCAN threshold stays at .20 m; finish_dist is still .06 m.
|
||||
manager.min_replan_distance: 0.04
|
||||
# MID360's -7 deg lower FOV sees the upper face of a nearby floor box.
|
||||
# Conservatively include returns up to z=.65 in the z=.15 flat driving
|
||||
# slice. This is map inflation, not fabricated low sensor returns.
|
||||
# Overhead-clearance and ramp planning require a different terrain profile.
|
||||
grid_map.obstacles_inflation_z_down: 0.50
|
||||
|
||||
closed_loop_controller:
|
||||
ros__parameters:
|
||||
max_vx: 0.3
|
||||
max_vy: 0.3
|
||||
# The original .10 rad finish tolerance ended rotations at excessive speed
|
||||
# in continuous tasks. Tighten only simulation; keep the .20 s stop budget.
|
||||
yaw_goal_tolerance: 0.02
|
||||
# Keep flat 9 cm margin and the existing 6 cm finish window.
|
||||
@@ -0,0 +1,58 @@
|
||||
# Independent low-speed terrain LIO profile. Flat profile is not included.
|
||||
lio_navigation_adapter:
|
||||
ros__parameters:
|
||||
use_sim_time: true
|
||||
imu_position_base: [0.011, 0.02329, 0.25588]
|
||||
lidar_position_base: [0.0, 0.0, 0.30]
|
||||
ground_cutoff_z: 0.015
|
||||
# Prior LIO slope max vertical error .038 m plus 2 cm allowance.
|
||||
# This intentionally cannot certify obstacles <= .10 m above known ground.
|
||||
surface_tolerance: 0.06
|
||||
traversable_planes: [-0.8, 2.7, 3.0, 4.0, -0.17057142857142857, 0.0, 0.46054285714285714,
|
||||
-0.8, 2.7, -4.0, -3.0, -0.17057142857142857, 0.0, 0.46054285714285714,
|
||||
-3.0, 3.0, -3.0, 3.0, 0.0, 0.0, 0.6,
|
||||
-1.8, -0.8, 3.0, 4.0, 0.0, 0.0, 0.6,
|
||||
-1.8, -0.8, -4.0, -3.0, 0.0, 0.0, 0.6,
|
||||
-7.0, 7.0, -8.0, 8.0, 0.0, 0.0, 0.0]
|
||||
required_planning_topic: /sim/navigation/terrain_planning_cloud
|
||||
# Baseline measured downstream age stays below .10 s. Revoke at .20 s
|
||||
# to leave enough braking time for the end-to-end .50 s loss-stop limit.
|
||||
required_planning_max_age: 0.20
|
||||
scan_planner_node:
|
||||
ros__parameters:
|
||||
manager.max_vel: 0.2
|
||||
optimization.max_vel: 0.2
|
||||
manager.min_replan_distance: 0.04
|
||||
grid_map.footprint_margin: 0.04
|
||||
# Half-size voxels reduce narrow-lane quantization without shrinking the
|
||||
# footprint or margin. A corridor-shaped window keeps memory near baseline.
|
||||
grid_map.resolution: 0.025
|
||||
grid_map.sliding_map_size_x: 10.0
|
||||
grid_map.sliding_map_size_y: 3.0
|
||||
grid_map.sliding_map_size_z: 2.0
|
||||
grid_map.local_update_range_x: 5.0
|
||||
grid_map.local_update_range_y: 1.5
|
||||
grid_map.local_update_range_z: 1.0
|
||||
# Do not project upper returns through the ramp into the driving slice.
|
||||
grid_map.obstacles_inflation_z_down: 0.05
|
||||
closed_loop_controller:
|
||||
ros__parameters:
|
||||
max_vx: 0.2
|
||||
max_vy: 0.2
|
||||
# Leave physical braking/transport budget at the unchanged 6 cm finish
|
||||
# distance. The real-vehicle 5 cm/s floor was too fast for this profile.
|
||||
goal_v_floor: 0.02
|
||||
goal_slow_gain: 0.3
|
||||
pos_deadband: 0.005
|
||||
step_blocker:
|
||||
ros__parameters:
|
||||
input_topic: /sim/navigation/planning_cloud
|
||||
output_topic: /sim/navigation/terrain_planning_cloud
|
||||
# 10 cm prior sampling is smaller than the 80 cm footprint; the existing
|
||||
# +15/-5 cm vertical inflation closes the vertical gaps. Keep wall height
|
||||
# 2 m while avoiding oversized DDS messages and lost freshness heartbeats.
|
||||
cell_size: 0.10
|
||||
# Certified corridor boundaries, not lidar returns or physical walls.
|
||||
# Without these prior planes, sparse/noisy upper returns allow a detour
|
||||
# off the side of the known ramp. Zero-width regions are vertical planes.
|
||||
regions: '-2.7,-1.8,3.0,4.0; -2.7,-1.8,-4.0,-3.0; -1.8,2.7,3.025,3.025; -1.8,2.7,4.0,4.0; -1.8,2.7,-3.025,-3.025; -1.8,2.7,-4.0,-4.0'
|
||||
@@ -0,0 +1,36 @@
|
||||
# Only simulation overrides. Original real-device configuration remains untouched.
|
||||
/**:
|
||||
ros__parameters:
|
||||
use_sim_time: true
|
||||
use_imu_as_input: false
|
||||
init_map_size: 500
|
||||
filter_size_surf: 0.15
|
||||
filter_size_map: 0.15
|
||||
runtime_pos_log_enable: false
|
||||
common.lid_topic: /sim/mid360/lidar
|
||||
common.imu_topic: /sim/mid360/imu
|
||||
common.time_diff_lidar_to_imu: 0.0
|
||||
preprocess.lidar_type: 1
|
||||
preprocess.scan_line: 4
|
||||
preprocess.blind: 0.55
|
||||
preprocess.blind_center_enable: true
|
||||
preprocess.blind_center: [0.0, 0.0, 0.0]
|
||||
mapping.imu_en: true
|
||||
mapping.extrinsic_est_en: false
|
||||
mapping.imu_time_inte: 0.005
|
||||
mapping.lidar_time_inte: 0.1
|
||||
# Gazebo's world has |g|=9.8; IMU reports SI specific force, not g units.
|
||||
mapping.acc_norm: 9.8
|
||||
mapping.satu_acc: 50.0
|
||||
mapping.satu_gyro: 35.0
|
||||
mapping.gravity: [0.0, 0.0, -9.8]
|
||||
mapping.gravity_init: [0.0, 0.0, -9.8]
|
||||
# Transform optical coordinates into the internally offset IMU frame.
|
||||
mapping.extrinsic_T: [-0.011, -0.02329, 0.04412]
|
||||
mapping.extrinsic_R: [1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0]
|
||||
odometry.publish_odometry_without_downsample: true
|
||||
odometry.publish_frequency_hz: 100
|
||||
# Keep estimated TF isolated from the independent truth TF tree.
|
||||
publish.tf_send_en: false
|
||||
publish.path_en: true
|
||||
pcd_save.pcd_save_en: false
|
||||
@@ -0,0 +1,7 @@
|
||||
# Only the noise-free simulation terrain entry loads this optional override.
|
||||
# Retain the baseline residual variance; increasing its weight caused false
|
||||
# stationary velocity and was rejected by the unchanged startup gate.
|
||||
/**:
|
||||
ros__parameters:
|
||||
filter_size_surf: 0.10
|
||||
filter_size_map: 0.10
|
||||
@@ -0,0 +1,37 @@
|
||||
# These overrides describe the simplified simulated robot, not the real robot.
|
||||
scan_planner_node:
|
||||
ros__parameters:
|
||||
use_sim_time: true
|
||||
fsm.navi_mode: 1
|
||||
fsm.require_controller_feedback: true
|
||||
fsm.require_perception_ready: true
|
||||
grid_map.rectangle_footprint: true
|
||||
grid_map.footprint_length: 0.8
|
||||
grid_map.footprint_width: 0.8
|
||||
grid_map.footprint_margin: 0.09
|
||||
# Truth-mode heading hold: tighten to ~0.57 deg; keep the 9 cm margin.
|
||||
# The map also pads corners for this angle and covers full 5 cm voxels.
|
||||
grid_map.footprint_yaw_tolerance: 0.01
|
||||
grid_map.double_cylinder_offset: 0.0
|
||||
grid_map.ground_height: -0.1
|
||||
grid_map.body_height: 0.15
|
||||
grid_map.frame_id: world
|
||||
grid_map.sensor_type: lidar
|
||||
grid_map.cloud_is_world: true
|
||||
grid_map.need_extrinsic: false
|
||||
|
||||
closed_loop_controller:
|
||||
ros__parameters:
|
||||
use_sim_time: true
|
||||
require_trajectory_status: true
|
||||
require_locked_heading: true
|
||||
require_perception_ready: true
|
||||
allow_reverse: false
|
||||
# Stop inside the planner's 0.08 m goal window, allowing separate odom callbacks.
|
||||
finish_dist: 0.06
|
||||
|
||||
scan_cloud_gate:
|
||||
ros__parameters:
|
||||
use_sim_time: true
|
||||
# Flat-ground P4 only. Preserve the complete cloud on /cloud_registered.
|
||||
ground_cutoff_z: 0.015
|
||||
@@ -0,0 +1,42 @@
|
||||
# Explicit, optional terrain/reference-path mode. Base flat mode stays unchanged.
|
||||
scan_planner_node:
|
||||
ros__parameters:
|
||||
fsm.navi_mode: 3
|
||||
fsm.terrain_motion: true
|
||||
fsm.reference_path_min_distance: 0.05
|
||||
manager.max_vel: 0.3
|
||||
optimization.max_vel: 0.3
|
||||
# The ramp is only 1 m wide (0.975 m beside the 25 mm rail overhang).
|
||||
# Keep the 80 cm body; this optional low-speed truth profile uses 4 cm
|
||||
# explicit margin plus angular and voxel padding. Flat mode stays at 9 cm.
|
||||
grid_map.footprint_margin: 0.04
|
||||
|
||||
closed_loop_controller:
|
||||
ros__parameters:
|
||||
terrain_motion: true
|
||||
max_vx: 0.3
|
||||
max_vy: 0.3
|
||||
align_to_goal_yaw: false
|
||||
|
||||
scan_cloud_gate:
|
||||
ros__parameters:
|
||||
planning_cloud_topic: /sim/terrain_planning_cloud
|
||||
# Known walkable surfaces from the authoritative field model. Sensor cloud
|
||||
# /cloud_registered remains untouched. Format: xmin,xmax,ymin,ymax,mx,my,b;
|
||||
# z=mx*x+my*y+b. The .6 m landing is the highest original stair box.
|
||||
traversable_planes: [-0.8, 2.7, 3.0, 4.0, -0.17057142857142857, 0.0, 0.46054285714285714,
|
||||
-0.8, 2.7, -4.0, -3.0, -0.17057142857142857, 0.0, 0.46054285714285714,
|
||||
-3.0, 3.0, -3.0, 3.0, 0.0, 0.0, 0.6,
|
||||
-1.8, -0.8, 3.0, 4.0, 0.0, 0.0, 0.6,
|
||||
-1.8, -0.8, -4.0, -3.0, 0.0, 0.0, 0.6]
|
||||
|
||||
step_blocker:
|
||||
ros__parameters:
|
||||
use_sim_time: true
|
||||
input_topic: /cloud_registered_for_scan
|
||||
output_topic: /sim/terrain_planning_cloud
|
||||
# Explicit prior keepout layer, not simulated lidar returns.
|
||||
regions: '-2.7,-1.8,3.0,4.0; -2.7,-1.8,-4.0,-3.0'
|
||||
wall_height: 2.0
|
||||
z_min: 0.0
|
||||
cell_size: 0.05
|
||||
@@ -0,0 +1,38 @@
|
||||
"""Independent MID360-compatible sensors and optional Point-LIO evaluation; no SCAN."""
|
||||
import os
|
||||
from ament_index_python.packages import get_package_share_directory
|
||||
from launch import LaunchDescription
|
||||
from launch.actions import DeclareLaunchArgument,IncludeLaunchDescription,OpaqueFunction
|
||||
from launch.launch_description_sources import PythonLaunchDescriptionSource
|
||||
from launch.substitutions import LaunchConfiguration
|
||||
from launch_ros.actions import Node
|
||||
|
||||
|
||||
def generate_launch_description():
|
||||
own=get_package_share_directory('br_sim_bringup')
|
||||
def simulation(context):
|
||||
if LaunchConfiguration('start_sim').perform(context).lower()!='true':return []
|
||||
robot=get_package_share_directory('r2027_robot_description')
|
||||
return [IncludeLaunchDescription(PythonLaunchDescriptionSource(os.path.join(robot,'launch','robocon_robot.launch.py')),
|
||||
launch_arguments={'sensor_profile':LaunchConfiguration('sensor_profile'),'gui':LaunchConfiguration('gui'),'lidar':'true','sensor_model':'mid360','drive':'contact',
|
||||
'x':LaunchConfiguration('x'),'y':LaunchConfiguration('y'),'z':LaunchConfiguration('z'),'yaw':LaunchConfiguration('yaw')}.items())]
|
||||
def estimator(context):
|
||||
if LaunchConfiguration('with_lio').perform(context).lower()!='true':return []
|
||||
lio=get_package_share_directory('point_lio')
|
||||
return [Node(package='point_lio',executable='pointlio_mapping',name='point_lio_sim',
|
||||
namespace='sim/lio',output='screen',
|
||||
parameters=[os.path.join(lio,'config','mid360.yaml'),os.path.join(own,'config','point_lio_sim.yaml'),
|
||||
LaunchConfiguration('lio_profile')],
|
||||
# Three absolute publishers in the existing implementation need explicit remaps.
|
||||
remappings=[('/cloud_registered_full','/sim/lio/cloud_registered_full'),
|
||||
('/cloud_registered_full_lidar','/sim/lio/cloud_registered_full_lidar')])]
|
||||
return LaunchDescription([
|
||||
DeclareLaunchArgument('gui',default_value='true'),
|
||||
DeclareLaunchArgument('with_lio',default_value='false'),
|
||||
DeclareLaunchArgument('start_sim',default_value='true'),
|
||||
DeclareLaunchArgument('sensor_profile',default_value='ideal'),
|
||||
DeclareLaunchArgument('lio_profile',default_value=os.path.join(own,'config','point_lio_sim.yaml')),
|
||||
DeclareLaunchArgument('x',default_value='-4.5'),DeclareLaunchArgument('y',default_value='4.5'),
|
||||
DeclareLaunchArgument('z',default_value='0.17'),DeclareLaunchArgument('yaw',default_value='0.0'),
|
||||
OpaqueFunction(function=simulation),
|
||||
OpaqueFunction(function=estimator)])
|
||||
@@ -0,0 +1,36 @@
|
||||
"""Flat SCAN closed loop from Point-LIO only; truth remains an independent observer."""
|
||||
import os
|
||||
from ament_index_python.packages import get_package_share_directory
|
||||
from launch import LaunchDescription
|
||||
from launch.actions import DeclareLaunchArgument,IncludeLaunchDescription,OpaqueFunction
|
||||
from launch.launch_description_sources import PythonLaunchDescriptionSource
|
||||
from launch.substitutions import LaunchConfiguration
|
||||
from launch_ros.actions import Node
|
||||
|
||||
|
||||
def generate_launch_description():
|
||||
own=get_package_share_directory('br_sim_bringup');scan=get_package_share_directory('scan_planner')
|
||||
base=os.path.join(own,'config','scan_sim.yaml');profile=os.path.join(own,'config','lio_navigation.yaml')
|
||||
def bringup(context):
|
||||
pose=[float(LaunchConfiguration(k).perform(context)) for k in ('x','y','z','yaw')]
|
||||
return [
|
||||
IncludeLaunchDescription(PythonLaunchDescriptionSource(os.path.join(own,'launch','mid360_sim.launch.py')),
|
||||
launch_arguments={'gui':LaunchConfiguration('gui'),'with_lio':'true',
|
||||
'start_sim':LaunchConfiguration('start_sim'),'sensor_profile':LaunchConfiguration('sensor_profile'),
|
||||
**{k:LaunchConfiguration(k) for k in ('x','y','z','yaw')}}.items()),
|
||||
Node(package='br_sim_bringup',executable='lio_navigation_adapter.py',name='lio_navigation_adapter',
|
||||
output='screen',parameters=[profile,{'initial_base_pose':pose}]),
|
||||
Node(package='scan_planner',executable='scan_planner_node',name='scan_planner_node',output='screen',
|
||||
parameters=[os.path.join(scan,'config','planner_vehicle.yaml'),base,profile],
|
||||
remappings=[('body_pose','/sim/navigation/body_odom'),('sensor_pose','/sim/navigation/sensor_odom'),
|
||||
('cloud','/sim/navigation/planning_cloud')]),
|
||||
Node(package='scan_planner',executable='closed_loop_controller',name='closed_loop_controller',output='screen',
|
||||
parameters=[os.path.join(scan,'config','controllers_vehicle.yaml'),base,profile],
|
||||
remappings=[('body_pose','/sim/navigation/body_odom'),('cmd_vel','/cmd_vel')]),
|
||||
]
|
||||
return LaunchDescription([
|
||||
DeclareLaunchArgument('start_sim',default_value='true'),DeclareLaunchArgument('sensor_profile',default_value='ideal'),
|
||||
DeclareLaunchArgument('gui',default_value='true'),
|
||||
DeclareLaunchArgument('x',default_value='-4.5'),DeclareLaunchArgument('y',default_value='4.5'),
|
||||
DeclareLaunchArgument('z',default_value='0.15',description='Known settled base height in this flat profile'),
|
||||
DeclareLaunchArgument('yaw',default_value='0.0'),OpaqueFunction(function=bringup)])
|
||||
@@ -0,0 +1,18 @@
|
||||
"""Local rehearsal of two independent launch processes; use the same commands on two hosts."""
|
||||
from launch import LaunchDescription
|
||||
from launch.actions import DeclareLaunchArgument,ExecuteProcess,OpaqueFunction
|
||||
from launch.substitutions import LaunchConfiguration
|
||||
|
||||
|
||||
def generate_launch_description():
|
||||
def hosts(context):
|
||||
values={k:LaunchConfiguration(k).perform(context) for k in ('x','y','z','yaw','gui','sensor_profile','terrain')}
|
||||
terrain=values.pop('terrain').lower()=='true'
|
||||
args=[k+':='+v for k,v in values.items()]
|
||||
return [ExecuteProcess(cmd=['ros2','launch','r2027_robot_description','robocon_robot.launch.py',
|
||||
'lidar:=true','drive:=contact','sensor_model:=mid360']+args,output='screen'),
|
||||
ExecuteProcess(cmd=['ros2','launch','br_sim_bringup',
|
||||
'scan_lio_terrain.launch.py' if terrain else 'scan_lio.launch.py','start_sim:=false']+args,output='screen')]
|
||||
return LaunchDescription([DeclareLaunchArgument(k,default_value=v) for k,v in
|
||||
[('x','-4.5'),('y','4.5'),('z','0.15'),('yaw','0.0'),('gui','false'),('sensor_profile','ideal'),('terrain','false')]]+
|
||||
[OpaqueFunction(function=hosts)])
|
||||
@@ -0,0 +1,38 @@
|
||||
"""Explicit LIO terrain/reference-path profile; no truth navigation inputs."""
|
||||
import os
|
||||
from ament_index_python.packages import get_package_share_directory
|
||||
from launch import LaunchDescription
|
||||
from launch.actions import DeclareLaunchArgument,IncludeLaunchDescription,OpaqueFunction
|
||||
from launch.launch_description_sources import PythonLaunchDescriptionSource
|
||||
from launch.substitutions import LaunchConfiguration
|
||||
from launch_ros.actions import Node
|
||||
|
||||
|
||||
def generate_launch_description():
|
||||
own=get_package_share_directory('br_sim_bringup');scan=get_package_share_directory('scan_planner')
|
||||
base=os.path.join(own,'config','scan_sim.yaml');terrain=os.path.join(own,'config','terrain_sim.yaml')
|
||||
profile=os.path.join(own,'config','lio_terrain.yaml')
|
||||
def bringup(context):
|
||||
prior=[float(LaunchConfiguration(k).perform(context)) for k in ('x','y','z','yaw')]
|
||||
return [
|
||||
IncludeLaunchDescription(PythonLaunchDescriptionSource(os.path.join(own,'launch','mid360_sim.launch.py')),
|
||||
launch_arguments={'gui':LaunchConfiguration('gui'),'with_lio':'true',
|
||||
'start_sim':LaunchConfiguration('start_sim'),'sensor_profile':LaunchConfiguration('sensor_profile'),
|
||||
'lio_profile':os.path.join(own,'config','point_lio_terrain.yaml'),
|
||||
**{k:LaunchConfiguration(k) for k in ('x','y','z','yaw')}}.items()),
|
||||
Node(package='br_sim_bringup',executable='lio_navigation_adapter.py',name='lio_navigation_adapter',
|
||||
output='screen',parameters=[profile,{'initial_base_pose':prior}]),
|
||||
Node(package='step_blocker',executable='step_blocker',name='step_blocker',output='screen',parameters=[terrain,profile]),
|
||||
Node(package='scan_planner',executable='scan_planner_node',name='scan_planner_node',output='screen',
|
||||
parameters=[os.path.join(scan,'config','planner_vehicle.yaml'),base,terrain,profile],
|
||||
remappings=[('body_pose','/sim/navigation/body_odom'),('sensor_pose','/sim/navigation/sensor_odom'),
|
||||
('cloud','/sim/navigation/terrain_planning_cloud')]),
|
||||
Node(package='scan_planner',executable='closed_loop_controller',name='closed_loop_controller',output='screen',
|
||||
parameters=[os.path.join(scan,'config','controllers_vehicle.yaml'),base,terrain,profile],
|
||||
remappings=[('body_pose','/sim/navigation/body_odom'),('cmd_vel','/cmd_vel')]),
|
||||
]
|
||||
return LaunchDescription([
|
||||
DeclareLaunchArgument('start_sim',default_value='true'),DeclareLaunchArgument('sensor_profile',default_value='ideal'),
|
||||
DeclareLaunchArgument('gui',default_value='true'),DeclareLaunchArgument('x',default_value='3.5'),
|
||||
DeclareLaunchArgument('y',default_value='3.5125'),DeclareLaunchArgument('z',default_value='0.15'),
|
||||
DeclareLaunchArgument('yaw',default_value='0.0'),OpaqueFunction(function=bringup)])
|
||||
@@ -0,0 +1,45 @@
|
||||
"""One Classic server + generic 3D lidar + existing SCAN closed loop (truth mode)."""
|
||||
import os
|
||||
|
||||
from ament_index_python.packages import get_package_share_directory
|
||||
from launch import LaunchDescription
|
||||
from launch.actions import DeclareLaunchArgument, IncludeLaunchDescription, SetEnvironmentVariable
|
||||
from launch.launch_description_sources import PythonLaunchDescriptionSource
|
||||
from launch.substitutions import LaunchConfiguration
|
||||
from launch_ros.actions import Node
|
||||
|
||||
|
||||
def generate_launch_description():
|
||||
robot = get_package_share_directory('r2027_robot_description')
|
||||
scan = get_package_share_directory('scan_planner')
|
||||
own = get_package_share_directory('br_sim_bringup')
|
||||
overrides = os.path.join(own, 'config', 'scan_sim.yaml')
|
||||
return LaunchDescription([
|
||||
SetEnvironmentVariable('ROS_DOMAIN_ID', '77'),
|
||||
SetEnvironmentVariable('ROS_LOCALHOST_ONLY', '1'),
|
||||
DeclareLaunchArgument('gui', default_value='true'),
|
||||
DeclareLaunchArgument('paused', default_value='false'),
|
||||
DeclareLaunchArgument('x', default_value='-4.5'),
|
||||
DeclareLaunchArgument('y', default_value='4.5'),
|
||||
DeclareLaunchArgument('z', default_value='0.15'),
|
||||
DeclareLaunchArgument('yaw', default_value='0.0'),
|
||||
IncludeLaunchDescription(PythonLaunchDescriptionSource(
|
||||
os.path.join(robot, 'launch', 'robocon_robot.launch.py')),
|
||||
launch_arguments={'gui': LaunchConfiguration('gui'),
|
||||
'paused': LaunchConfiguration('paused'), 'lidar': 'true',
|
||||
'x': LaunchConfiguration('x'), 'y': LaunchConfiguration('y'),
|
||||
'z': LaunchConfiguration('z'), 'yaw': LaunchConfiguration('yaw')}.items()),
|
||||
Node(package='br_sim_bringup', executable='scan_cloud_gate.py',
|
||||
name='scan_cloud_gate', output='screen', parameters=[overrides]),
|
||||
Node(package='scan_planner', executable='scan_planner_node',
|
||||
name='scan_planner_node', output='screen',
|
||||
parameters=[os.path.join(scan, 'config', 'planner_vehicle.yaml'), overrides],
|
||||
remappings=[('body_pose', '/body_odom'),
|
||||
('sensor_pose', '/aft_mapped_to_init'),
|
||||
('cloud', '/cloud_registered_for_scan'),
|
||||
('move_base_simple/goal', '/move_base_simple/goal')]),
|
||||
Node(package='scan_planner', executable='closed_loop_controller',
|
||||
name='closed_loop_controller', output='screen',
|
||||
parameters=[os.path.join(scan, 'config', 'controllers_vehicle.yaml'), overrides],
|
||||
remappings=[('body_pose', '/body_odom'), ('cmd_vel', '/cmd_vel')]),
|
||||
])
|
||||
@@ -0,0 +1,34 @@
|
||||
"""Optional contact-force drive + existing SCAN 3D reference paths, truth mode."""
|
||||
import os
|
||||
from ament_index_python.packages import get_package_share_directory
|
||||
from launch import LaunchDescription
|
||||
from launch.actions import DeclareLaunchArgument,IncludeLaunchDescription,SetEnvironmentVariable
|
||||
from launch.launch_description_sources import PythonLaunchDescriptionSource
|
||||
from launch.substitutions import LaunchConfiguration
|
||||
from launch_ros.actions import Node
|
||||
|
||||
|
||||
def generate_launch_description():
|
||||
own=get_package_share_directory('br_sim_bringup')
|
||||
robot=get_package_share_directory('r2027_robot_description')
|
||||
scan=get_package_share_directory('scan_planner')
|
||||
base=os.path.join(own,'config','scan_sim.yaml')
|
||||
terrain=os.path.join(own,'config','terrain_sim.yaml')
|
||||
return LaunchDescription([
|
||||
SetEnvironmentVariable('ROS_DOMAIN_ID','77'),SetEnvironmentVariable('ROS_LOCALHOST_ONLY','1'),
|
||||
DeclareLaunchArgument('gui',default_value='true'),
|
||||
DeclareLaunchArgument('x',default_value='3.5'),DeclareLaunchArgument('y',default_value='3.5125'),
|
||||
DeclareLaunchArgument('z',default_value='0.15'),
|
||||
DeclareLaunchArgument('yaw',default_value='0.0'),
|
||||
IncludeLaunchDescription(PythonLaunchDescriptionSource(os.path.join(robot,'launch','robocon_robot.launch.py')),
|
||||
launch_arguments={'gui':LaunchConfiguration('gui'),'lidar':'true','drive':'contact',
|
||||
'x':LaunchConfiguration('x'),'y':LaunchConfiguration('y'),'z':LaunchConfiguration('z'),'yaw':LaunchConfiguration('yaw')}.items()),
|
||||
Node(package='br_sim_bringup',executable='scan_cloud_gate.py',name='scan_cloud_gate',parameters=[base,terrain]),
|
||||
Node(package='step_blocker',executable='step_blocker',name='step_blocker',parameters=[terrain]),
|
||||
Node(package='scan_planner',executable='scan_planner_node',name='scan_planner_node',output='screen',
|
||||
parameters=[os.path.join(scan,'config','planner_vehicle.yaml'),base,terrain],
|
||||
remappings=[('body_pose','/body_odom'),('sensor_pose','/aft_mapped_to_init'),('cloud','/sim/terrain_planning_cloud')]),
|
||||
Node(package='scan_planner',executable='closed_loop_controller',name='closed_loop_controller',output='screen',
|
||||
parameters=[os.path.join(scan,'config','controllers_vehicle.yaml'),base,terrain],
|
||||
remappings=[('body_pose','/body_odom'),('cmd_vel','/cmd_vel')]),
|
||||
])
|
||||
@@ -0,0 +1,24 @@
|
||||
<?xml version="1.0"?>
|
||||
<package format="3">
|
||||
<name>br_sim_bringup</name>
|
||||
<version>0.1.0</version>
|
||||
<description>Gazebo Classic integration of existing Point-LIO and SCAN, with isolated truth and estimation modes.</description>
|
||||
<maintainer email="[email protected]">kevin</maintainer>
|
||||
<license>Apache-2.0</license>
|
||||
<buildtool_depend>ament_cmake</buildtool_depend>
|
||||
<exec_depend>r2027_robot_description</exec_depend>
|
||||
<exec_depend>scan_planner</exec_depend>
|
||||
<exec_depend>step_blocker</exec_depend>
|
||||
<exec_depend>point_lio</exec_depend>
|
||||
<exec_depend>launch</exec_depend>
|
||||
<exec_depend>launch_ros</exec_depend>
|
||||
<exec_depend>ament_index_python</exec_depend>
|
||||
<exec_depend>rclpy</exec_depend>
|
||||
<exec_depend>sensor_msgs</exec_depend>
|
||||
<exec_depend>nav_msgs</exec_depend>
|
||||
<exec_depend>std_msgs</exec_depend>
|
||||
<exec_depend>geometry_msgs</exec_depend>
|
||||
<exec_depend>tf2_ros</exec_depend>
|
||||
<exec_depend>python3-numpy</exec_depend>
|
||||
<export><build_type>ament_cmake</build_type></export>
|
||||
</package>
|
||||
+231
@@ -0,0 +1,231 @@
|
||||
#!/usr/bin/python3
|
||||
"""Point-LIO -> SCAN, fixed known-start alignment; no truth/TF input or fallback."""
|
||||
from array import array
|
||||
from collections import deque
|
||||
import copy
|
||||
import json
|
||||
import math
|
||||
|
||||
import numpy as np
|
||||
import rclpy
|
||||
from rclpy.node import Node
|
||||
from rclpy.qos import QoSProfile,DurabilityPolicy,qos_profile_sensor_data
|
||||
from geometry_msgs.msg import TransformStamped
|
||||
from nav_msgs.msg import Odometry
|
||||
from sensor_msgs.msg import PointCloud2,PointField
|
||||
from std_msgs.msg import Bool,String
|
||||
from tf2_ros import TransformBroadcaster,StaticTransformBroadcaster
|
||||
|
||||
|
||||
def quaternion(values):
|
||||
q=np.asarray(values,dtype=float)
|
||||
if q.shape!=(4,) or not np.isfinite(q).all() or abs(np.linalg.norm(q)-1)>.001:
|
||||
raise ValueError('invalid unit quaternion')
|
||||
return q/np.linalg.norm(q)
|
||||
|
||||
|
||||
def multiply(a,b):
|
||||
return np.r_[a[3]*b[:3]+b[3]*a[:3]+np.cross(a[:3],b[:3]),a[3]*b[3]-np.dot(a[:3],b[:3])]
|
||||
|
||||
|
||||
def rotation(q):
|
||||
x,y,z,w=quaternion(q)
|
||||
return np.array([[1-2*(y*y+z*z),2*(x*y-z*w),2*(x*z+y*w)],
|
||||
[2*(x*y+z*w),1-2*(x*x+z*z),2*(y*z-x*w)],
|
||||
[2*(x*z-y*w),2*(y*z+x*w),1-2*(x*x+y*y)]])
|
||||
|
||||
|
||||
def skew(v):
|
||||
x,y,z=v
|
||||
return np.array([[0,-z,y],[z,0,-x],[-y,x,0]])
|
||||
|
||||
|
||||
class FixedAlignment:
|
||||
def __init__(self,prior_base,imu_position_base,position,orientation):
|
||||
self.imu_position_base=np.asarray(imu_position_base)
|
||||
yaw=prior_base[3];prior_q=np.array([0.,0.,math.sin(yaw/2),math.cos(yaw/2)])
|
||||
inverse=quaternion(orientation).copy();inverse[:3]*=-1
|
||||
self.q=quaternion(multiply(prior_q,inverse));self.R=rotation(self.q)
|
||||
self.t=np.array(prior_base[:3])+rotation(prior_q)@self.imu_position_base-self.R@position
|
||||
|
||||
def pose(self,position,orientation,offset_from_imu):
|
||||
q=quaternion(multiply(self.q,quaternion(orientation)))
|
||||
return self.R@position+self.t+rotation(q)@offset_from_imu,q
|
||||
|
||||
|
||||
def shifted_twist(linear,angular,offset_from_imu):
|
||||
# All three model axes are aligned; offset is from IMU to target origin.
|
||||
return np.asarray(linear)+np.cross(angular,offset_from_imu)
|
||||
|
||||
|
||||
def float_fields(msg,names,data=None):
|
||||
fields={f.name:f for f in msg.fields}
|
||||
if any(n not in fields or fields[n].datatype!=PointField.FLOAT32 or fields[n].count!=1 for n in names):
|
||||
raise ValueError('missing float32 point fields: '+','.join(names))
|
||||
if len(msg.data)<msg.row_step*msg.height:raise ValueError('truncated point data')
|
||||
return [np.ndarray((msg.height,msg.width),dtype=('>' if msg.is_bigendian else '<')+'f4',
|
||||
buffer=msg.data if data is None else data,offset=fields[n].offset,
|
||||
strides=(msg.row_step,msg.point_step)) for n in names]
|
||||
|
||||
|
||||
class LioNavigationAdapter(Node):
|
||||
def __init__(self):
|
||||
super().__init__('lio_navigation_adapter')
|
||||
self.prior=np.array(self.declare_parameter('initial_base_pose',[-4.5,4.5,.15,0.]).value)
|
||||
self.imu=np.array(self.declare_parameter('imu_position_base',[.011,.02329,.25588]).value)
|
||||
self.lidar=np.array(self.declare_parameter('lidar_position_base',[0.,0.,.30]).value)
|
||||
if self.prior.shape!=(4,) or self.imu.shape!=(3,) or self.lidar.shape!=(3,) or not all(np.isfinite(a).all() for a in (self.prior,self.imu,self.lidar)):
|
||||
raise ValueError('invalid prior or installation geometry')
|
||||
self.cutoff=float(self.declare_parameter('ground_cutoff_z',.015).value)
|
||||
if not math.isfinite(self.cutoff):raise ValueError('invalid ground cutoff')
|
||||
planes=list(self.declare_parameter('traversable_planes',[0.]*7).value)
|
||||
self.surface_tolerance=float(self.declare_parameter('surface_tolerance',.015).value)
|
||||
if len(planes)%7 or not all(math.isfinite(v) for v in planes) or not math.isfinite(self.surface_tolerance) or not 0<self.surface_tolerance<=.06:
|
||||
raise ValueError('invalid known traversable surfaces or tolerance')
|
||||
self.planes=[planes[i:i+7] for i in range(0,len(planes),7) if planes[i+1]>planes[i] and planes[i+3]>planes[i+2]]
|
||||
self.planning_topic=self.declare_parameter('required_planning_topic','').value
|
||||
self.planning_max_age=float(self.declare_parameter('required_planning_max_age',.3).value)
|
||||
if not math.isfinite(self.planning_max_age) or not 0<self.planning_max_age<=.3:
|
||||
raise ValueError('downstream planning maximum age must be in (0,0.3]')
|
||||
self.downstream_stamp=None
|
||||
self.alignment=None;self.fault='';self.window=deque();self.last=None
|
||||
self.odom_stamp=None;self.cloud_stamp=None;self.cloud_count=0;self.last_status=-1.
|
||||
self.anchor_stamp=None
|
||||
self.body_pub=self.create_publisher(Odometry,'/sim/navigation/body_odom',20)
|
||||
self.sensor_pub=self.create_publisher(Odometry,'/sim/navigation/sensor_odom',20)
|
||||
self.world_pub=self.create_publisher(PointCloud2,'/sim/navigation/cloud_registered',5)
|
||||
self.planning_pub=self.create_publisher(PointCloud2,'/sim/navigation/planning_cloud',5)
|
||||
self.ready_pub=self.create_publisher(Bool,'/planning/perception_ready',QoSProfile(depth=1,durability=DurabilityPolicy.TRANSIENT_LOCAL))
|
||||
self.status_pub=self.create_publisher(String,'/sim/navigation/status',QoSProfile(depth=1,durability=DurabilityPolicy.TRANSIENT_LOCAL))
|
||||
self.tf=TransformBroadcaster(self);self.static_tf=StaticTransformBroadcaster(self)
|
||||
self.create_subscription(Odometry,'/sim/lio/aft_mapped_to_init',self.on_odom,qos_profile_sensor_data)
|
||||
self.create_subscription(PointCloud2,'/sim/lio/cloud_registered_full_lidar',self.on_cloud,qos_profile_sensor_data)
|
||||
if self.planning_topic:
|
||||
if self.planning_topic in ('/sim/navigation/cloud_registered','/sim/navigation/planning_cloud'):
|
||||
raise ValueError('downstream gate must use a separate derived planning topic')
|
||||
self.create_subscription(PointCloud2,self.planning_topic,self.on_planning_cloud,qos_profile_sensor_data)
|
||||
self.create_timer(.05,self.health)
|
||||
|
||||
def on_planning_cloud(self,m):
|
||||
if m.header.frame_id=='world' and m.width*m.height>0:
|
||||
self.downstream_stamp=self.stamp(m)
|
||||
|
||||
@staticmethod
|
||||
def stamp(m):return m.header.stamp.sec+m.header.stamp.nanosec*1e-9
|
||||
|
||||
def now_s(self):return self.get_clock().now().nanoseconds*1e-9
|
||||
|
||||
def fresh(self,stamp,limit):return stamp is not None and 0<=self.now_s()-stamp<=limit
|
||||
|
||||
def reject(self,reason):
|
||||
if not self.fault:self.get_logger().error('Navigation latched stopped: '+reason)
|
||||
self.fault=reason
|
||||
|
||||
@staticmethod
|
||||
def transform(parent,child,stamp,position,orientation):
|
||||
tr=TransformStamped();tr.header.frame_id=parent;tr.child_frame_id=child;tr.header.stamp=stamp
|
||||
tr.transform.translation.x,tr.transform.translation.y,tr.transform.translation.z=map(float,position)
|
||||
tr.transform.rotation.x,tr.transform.rotation.y,tr.transform.rotation.z,tr.transform.rotation.w=map(float,orientation)
|
||||
return tr
|
||||
|
||||
def on_odom(self,m):
|
||||
if self.fault:return
|
||||
try:
|
||||
if m.header.frame_id!='camera_init' or m.child_frame_id!='body':raise ValueError('unexpected LIO odometry frames')
|
||||
p=m.pose.pose.position;q=m.pose.pose.orientation;v=m.twist.twist.linear;w=m.twist.twist.angular
|
||||
pos=np.array([p.x,p.y,p.z]);q=quaternion([q.x,q.y,q.z,q.w]);linear=np.array([v.x,v.y,v.z]);angular=np.array([w.x,w.y,w.z])
|
||||
if not all(np.isfinite(a).all() for a in (pos,linear,angular)):raise ValueError('nonfinite odometry')
|
||||
t=self.stamp(m)
|
||||
if not self.fresh(t,.2):return
|
||||
if self.last is not None:
|
||||
dt=t-self.last[0]
|
||||
if dt==0:return
|
||||
if dt<0:raise ValueError('LIO time moved backwards')
|
||||
if self.alignment and (dt>.5 or np.linalg.norm(pos-self.last[1])>.12+.7*dt or
|
||||
2*math.acos(min(1.,abs(np.dot(q,self.last[2]))))>.20+dt):
|
||||
raise ValueError('LIO gap or pose discontinuity; restart with a known start pose')
|
||||
self.last=(t,pos,q)
|
||||
if self.alignment is None:
|
||||
if np.linalg.norm(linear)>.02 or np.linalg.norm(angular)>.02:self.window.clear();return
|
||||
self.window.append((t,pos,q))
|
||||
while len(self.window)>1 and t-self.window[1][0]>1.:self.window.popleft()
|
||||
if len(self.window)<20 or t-self.window[0][0]<1.:return
|
||||
if max(np.linalg.norm(s[1]-pos) for s in self.window)>.02:return
|
||||
self.alignment=FixedAlignment(self.prior,self.imu,pos,q);self.anchor_stamp=t
|
||||
self.static_tf.sendTransform([
|
||||
self.transform('world','camera_init',m.header.stamp,self.alignment.t,self.alignment.q),
|
||||
self.transform('lio_imu','lio_base_link',m.header.stamp,-self.imu,[0.,0.,0.,1.]),
|
||||
self.transform('lio_base_link','lio_lidar',m.header.stamp,self.lidar,[0.,0.,0.,1.])])
|
||||
self.get_logger().info('Fixed known-start alignment locked; no truth input')
|
||||
for child,offset,pub in [('lio_base_link',-self.imu,self.body_pub),('lio_lidar',self.lidar-self.imu,self.sensor_pub)]:
|
||||
out=copy.deepcopy(m);out.header.frame_id='world';out.child_frame_id=child
|
||||
op,oq=self.alignment.pose(pos,q,offset)
|
||||
out.pose.pose.position.x,out.pose.pose.position.y,out.pose.pose.position.z=map(float,op)
|
||||
out.pose.pose.orientation.x,out.pose.pose.orientation.y,out.pose.pose.orientation.z,out.pose.pose.orientation.w=map(float,oq)
|
||||
ov=shifted_twist(linear,angular,offset)
|
||||
out.twist.twist.linear.x,out.twist.twist.linear.y,out.twist.twist.linear.z=map(float,ov)
|
||||
# Rotate pose covariance into world, then move the reference point.
|
||||
A=np.zeros((6,6));A[:3,:3]=self.alignment.R;A[3:,3:]=self.alignment.R
|
||||
J=np.eye(6);J[:3,3:]=-skew(rotation(oq)@offset)
|
||||
C=np.asarray(m.pose.covariance).reshape(6,6)
|
||||
out.pose.covariance=(J@A@C@A.T@J.T).ravel().tolist()
|
||||
J=np.eye(6);J[:3,3:]=-skew(offset)
|
||||
C=np.asarray(m.twist.covariance).reshape(6,6)
|
||||
out.twist.covariance=(J@C@J.T).ravel().tolist()
|
||||
pub.publish(out)
|
||||
self.tf.sendTransform(self.transform('camera_init','lio_imu',m.header.stamp,pos,q))
|
||||
self.odom_stamp=t
|
||||
except (ValueError,TypeError,KeyError) as exc:self.reject(str(exc))
|
||||
|
||||
def on_cloud(self,m):
|
||||
if self.fault or self.alignment is None:return
|
||||
try:
|
||||
t=self.stamp(m)
|
||||
if m.header.frame_id!='camera_init':raise ValueError('unexpected paired cloud frame')
|
||||
if not self.fresh(t,.25) or not self.fresh(self.odom_stamp,.2):return
|
||||
if self.cloud_stamp is not None and t<=self.cloud_stamp:return
|
||||
names=('x','y','z','lidar_x','lidar_y','lidar_z')
|
||||
values=float_fields(m,names)
|
||||
xyz=np.stack(values[:3],axis=-1)
|
||||
raw=np.stack(values[3:],axis=-1)
|
||||
if np.count_nonzero(np.isfinite(xyz).all(axis=-1))<100:return
|
||||
world=xyz@self.alignment.R.T+self.alignment.t
|
||||
data=bytearray(m.data)
|
||||
for i,v in enumerate(float_fields(m,names[:3],data)):v[:]=world[...,i]
|
||||
out=copy.deepcopy(m);out.header.frame_id='world';out.data=array('B',data)
|
||||
self.world_pub.publish(out)
|
||||
self_hit=(np.abs(raw[...,0])<=.42)&(np.abs(raw[...,1])<=.42)&(raw[...,2]>=-.47)&(raw[...,2]<=-.20)
|
||||
ground=world[...,2]<=self.cutoff
|
||||
for x0,x1,y0,y1,mx,my,b in self.planes:
|
||||
ground|=(world[...,0]>=x0)&(world[...,0]<=x1)&(world[...,1]>=y0)&(world[...,1]<=y1)&(
|
||||
np.abs(world[...,2]-(mx*world[...,0]+my*world[...,1]+b))<=self.surface_tolerance)
|
||||
for v in float_fields(m,names[:3],data):v[self_hit|ground]=np.nan
|
||||
out.data=array('B',data);out.is_dense=False;self.planning_pub.publish(out)
|
||||
self.cloud_stamp=t;self.cloud_count+=1
|
||||
except (ValueError,TypeError,KeyError) as exc:self.reject(str(exc))
|
||||
|
||||
def health(self):
|
||||
ready=not self.fault and self.alignment is not None and self.fresh(self.odom_stamp,.2) and self.fresh(self.cloud_stamp,.25)
|
||||
if self.planning_topic:ready=ready and self.fresh(self.downstream_stamp,self.planning_max_age)
|
||||
self.ready_pub.publish(Bool(data=bool(ready)))
|
||||
if self.now_s()-self.last_status<.5:return
|
||||
self.last_status=self.now_s()
|
||||
status=dict(phase='fault' if self.fault else ('initializing' if self.alignment is None else ('active' if ready else 'stale')),
|
||||
reason=self.fault,ready=bool(ready),stamp=self.now_s(),anchor_stamp=self.anchor_stamp,
|
||||
odom_stamp=self.odom_stamp,cloud_stamp=self.cloud_stamp,cloud_count=self.cloud_count,
|
||||
downstream_stamp=self.downstream_stamp,required_planning_topic=self.planning_topic,
|
||||
known_start_base=self.prior.tolist(),imu_position_base=self.imu.tolist())
|
||||
if self.alignment:status.update(rotation=self.alignment.R.tolist(),translation=self.alignment.t.tolist())
|
||||
self.status_pub.publish(String(data=json.dumps(status)))
|
||||
|
||||
|
||||
def main():
|
||||
rclpy.init();node=LioNavigationAdapter()
|
||||
try:rclpy.spin(node)
|
||||
except KeyboardInterrupt:pass
|
||||
finally:
|
||||
node.destroy_node()
|
||||
if rclpy.ok():rclpy.shutdown()
|
||||
|
||||
|
||||
if __name__=='__main__':main()
|
||||
+139
@@ -0,0 +1,139 @@
|
||||
#!/usr/bin/python3
|
||||
"""SCAN cloud/freshness gate with optional known surfaces; no invented returns or timing."""
|
||||
from array import array
|
||||
import copy
|
||||
import math
|
||||
from collections import OrderedDict
|
||||
|
||||
import numpy as np
|
||||
import rclpy
|
||||
from rclpy.node import Node
|
||||
from rclpy.qos import QoSProfile, DurabilityPolicy, qos_profile_sensor_data
|
||||
from nav_msgs.msg import Odometry
|
||||
from sensor_msgs.msg import PointCloud2, PointField
|
||||
from std_msgs.msg import Bool
|
||||
|
||||
|
||||
class ScanCloudGate(Node):
|
||||
def __init__(self):
|
||||
super().__init__('scan_cloud_gate')
|
||||
self.cutoff = float(self.declare_parameter('ground_cutoff_z', .015).value)
|
||||
if not math.isfinite(self.cutoff):
|
||||
raise ValueError('ground_cutoff_z must be finite')
|
||||
planes=list(self.declare_parameter('traversable_planes', [0.0]*7).value)
|
||||
if len(planes)%7 or not all(math.isfinite(v) for v in planes):
|
||||
raise ValueError('traversable_planes needs groups of xmin,xmax,ymin,ymax,mx,my,b')
|
||||
self.planes=[planes[i:i+7] for i in range(0,len(planes),7) if planes[i+1]>planes[i] and planes[i+3]>planes[i+2]]
|
||||
self.planning_topic=self.declare_parameter('planning_cloud_topic','').value
|
||||
self.stamps = {}
|
||||
self.raw = OrderedDict()
|
||||
self.world = OrderedDict()
|
||||
self.pub = self.create_publisher(PointCloud2, '/cloud_registered_for_scan', 5)
|
||||
self.ready_pub = self.create_publisher(Bool, '/planning/perception_ready',
|
||||
QoSProfile(depth=1, durability=DurabilityPolicy.TRANSIENT_LOCAL))
|
||||
self.create_subscription(PointCloud2, '/cloud_registered', self.on_cloud, 5)
|
||||
self.create_subscription(PointCloud2, '/lidar/points', self.on_raw, qos_profile_sensor_data)
|
||||
self.create_subscription(Odometry, '/body_odom', lambda m: self.on_odom('body', m), 10)
|
||||
self.create_subscription(Odometry, '/aft_mapped_to_init', lambda m: self.on_odom('sensor', m), 10)
|
||||
if self.planning_topic:
|
||||
self.create_subscription(PointCloud2,self.planning_topic,self.on_planning_cloud,qos_profile_sensor_data)
|
||||
self.create_timer(.05, self.publish_ready)
|
||||
|
||||
@staticmethod
|
||||
def stamp(m):
|
||||
return m.header.stamp.sec + m.header.stamp.nanosec * 1e-9
|
||||
|
||||
def on_odom(self, key, m):
|
||||
p, q = m.pose.pose.position, m.pose.pose.orientation
|
||||
child = 'base_link' if key == 'body' else 'lidar'
|
||||
if m.header.frame_id == 'world' and m.child_frame_id == child and all(
|
||||
math.isfinite(v) for v in (p.x, p.y, p.z, q.x, q.y, q.z, q.w)):
|
||||
self.stamps[key] = self.stamp(m)
|
||||
|
||||
def on_planning_cloud(self,m):
|
||||
if m.header.frame_id=='world' and m.width*m.height>0:
|
||||
self.stamps['planning']=self.stamp(m)
|
||||
|
||||
@staticmethod
|
||||
def key(m):
|
||||
return m.header.stamp.sec * 1_000_000_000 + m.header.stamp.nanosec
|
||||
|
||||
def on_raw(self, m):
|
||||
self.raw[self.key(m)] = m
|
||||
self.flush()
|
||||
|
||||
def on_cloud(self, m):
|
||||
self.world[self.key(m)] = m
|
||||
self.flush()
|
||||
|
||||
def flush(self):
|
||||
for key in list(self.world):
|
||||
if key in self.raw:
|
||||
self.publish_cloud(self.world.pop(key), self.raw.pop(key))
|
||||
for queue in (self.raw, self.world):
|
||||
while len(queue) > 20:
|
||||
queue.popitem(last=False)
|
||||
|
||||
@staticmethod
|
||||
def views(m, data):
|
||||
fields = {f.name: f for f in m.fields}
|
||||
if any(n not in fields or fields[n].datatype != PointField.FLOAT32
|
||||
or fields[n].count != 1 for n in ('x', 'y', 'z')):
|
||||
raise ValueError('Expected float32 XYZ from the simulated lidar')
|
||||
return [np.ndarray((m.height, m.width), dtype=('>' if m.is_bigendian else '<')+'f4',
|
||||
buffer=data, offset=fields[n].offset,
|
||||
strides=(m.row_step, m.point_step)) for n in ('x', 'y', 'z')]
|
||||
|
||||
def publish_cloud(self, m, raw):
|
||||
if (m.header.frame_id != 'world' or raw.header.frame_id != 'lidar' or
|
||||
m.width*m.height == 0 or
|
||||
(m.width, m.height, m.point_step, m.row_step, m.fields) !=
|
||||
(raw.width, raw.height, raw.point_step, raw.row_step, raw.fields)):
|
||||
return
|
||||
data = bytearray(m.data)
|
||||
xyz = self.views(m, data)
|
||||
rx, ry, rz = self.views(raw, raw.data)
|
||||
valid = np.isfinite(np.stack(xyz, axis=-1)).all(axis=-1)
|
||||
if np.count_nonzero(valid) < 100:
|
||||
return
|
||||
ground = valid & (xyz[2] <= self.cutoff)
|
||||
for x0,x1,y0,y1,mx,my,b in self.planes:
|
||||
surface_z=mx*xyz[0]+my*xyz[1]+b
|
||||
ground |= valid & (xyz[0]>=x0)&(xyz[0]<=x1)&(xyz[1]>=y0)&(xyz[1]<=y1)&(np.abs(xyz[2]-surface_z)<.015)
|
||||
# Exact same point indices and acquisition stamp; no latest-pose approximation.
|
||||
# Body envelope in lidar coordinates: mount z=.30, body z=[-.15,.08].
|
||||
# 2 cm numerical margin includes the fixed support wheels and roof returns.
|
||||
self_hit = ((np.abs(rx) <= .42) & (np.abs(ry) <= .42) &
|
||||
(rz >= -.47) & (rz <= -.20))
|
||||
for v in xyz:
|
||||
v[ground | self_hit] = np.nan
|
||||
out = copy.deepcopy(m)
|
||||
out.data = array('B', data)
|
||||
out.is_dense = False
|
||||
self.pub.publish(out)
|
||||
self.stamps['cloud'] = self.stamp(m)
|
||||
|
||||
def publish_ready(self):
|
||||
now = self.get_clock().now().nanoseconds * 1e-9
|
||||
ready = all(k in self.stamps and 0 <= now-self.stamps[k] <= limit
|
||||
for k, limit in (('body', .2), ('sensor', .2), ('cloud', .25)))
|
||||
if self.planning_topic:
|
||||
ready=ready and 'planning' in self.stamps and 0<=now-self.stamps['planning']<=.3
|
||||
self.ready_pub.publish(Bool(data=ready))
|
||||
|
||||
|
||||
def main():
|
||||
rclpy.init()
|
||||
node = ScanCloudGate()
|
||||
try:
|
||||
rclpy.spin(node)
|
||||
except KeyboardInterrupt:
|
||||
pass
|
||||
finally:
|
||||
node.destroy_node()
|
||||
if rclpy.ok():
|
||||
rclpy.shutdown()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
@@ -0,0 +1,49 @@
|
||||
cmake_minimum_required(VERSION 3.8)
|
||||
project(r2027_robot_description)
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
|
||||
find_package(ament_cmake REQUIRED)
|
||||
find_package(gazebo REQUIRED)
|
||||
find_package(gazebo_ros REQUIRED)
|
||||
find_package(rclcpp REQUIRED)
|
||||
find_package(nav_msgs REQUIRED)
|
||||
find_package(geometry_msgs REQUIRED)
|
||||
find_package(gazebo_msgs REQUIRED)
|
||||
find_package(tf2_ros REQUIRED)
|
||||
find_package(livox_ros_driver2 REQUIRED)
|
||||
find_package(sensor_msgs REQUIRED)
|
||||
find_package(std_msgs REQUIRED)
|
||||
|
||||
add_library(br_contact_drive SHARED src/contact_drive.cpp)
|
||||
target_include_directories(br_contact_drive PRIVATE ${GAZEBO_INCLUDE_DIRS})
|
||||
target_link_libraries(br_contact_drive ${GAZEBO_LIBRARIES})
|
||||
ament_target_dependencies(br_contact_drive gazebo_ros rclcpp nav_msgs geometry_msgs gazebo_msgs tf2_ros)
|
||||
install(TARGETS br_contact_drive LIBRARY DESTINATION lib)
|
||||
|
||||
add_library(br_mid360_sensor SHARED src/mid360_sensor.cpp)
|
||||
target_include_directories(br_mid360_sensor PRIVATE ${GAZEBO_INCLUDE_DIRS})
|
||||
target_link_libraries(br_mid360_sensor ${GAZEBO_LIBRARIES})
|
||||
ament_target_dependencies(br_mid360_sensor gazebo_ros rclcpp livox_ros_driver2 sensor_msgs std_msgs)
|
||||
install(TARGETS br_mid360_sensor LIBRARY DESTINATION lib)
|
||||
|
||||
add_library(br_mid360_imu SHARED src/mid360_imu.cpp)
|
||||
target_include_directories(br_mid360_imu PRIVATE ${GAZEBO_INCLUDE_DIRS})
|
||||
target_link_libraries(br_mid360_imu ${GAZEBO_LIBRARIES})
|
||||
ament_target_dependencies(br_mid360_imu gazebo_ros rclcpp sensor_msgs)
|
||||
install(TARGETS br_mid360_imu LIBRARY DESTINATION lib)
|
||||
|
||||
# SIM-P2-001: 只装本包自己的资源。
|
||||
# 外部 /home/kevin/r2027_gazebo_model/src/r2027_robot_description 只作**只读参考**,
|
||||
# 不复制它的 ros2_control 配置、controllers.yaml、rviz 配置和 launch 逻辑。
|
||||
install(DIRECTORY launch sdf config
|
||||
DESTINATION share/${PROJECT_NAME}
|
||||
PATTERN "__pycache__" EXCLUDE
|
||||
PATTERN "*.pyc" EXCLUDE)
|
||||
|
||||
install(PROGRAMS scripts/cmd_vel_timeout.py scripts/sim_data_adapter.py
|
||||
DESTINATION lib/${PROJECT_NAME})
|
||||
|
||||
install(FILES SOURCE_PROVENANCE.md
|
||||
DESTINATION share/${PROJECT_NAME})
|
||||
|
||||
ament_package()
|
||||
@@ -0,0 +1,122 @@
|
||||
# 来源说明(SIM-P2-001 / -R1)
|
||||
|
||||
## 1. 本包新增内容
|
||||
|
||||
| 文件 | 性质 | 说明 |
|
||||
|---|---|---|
|
||||
| `sdf/r2027_omni_robot.sdf.xacro` | 本任务新写 | 参数化简化全向车体(**SDF**,不是 URDF,原因见 §5) |
|
||||
| `launch/robocon_robot.launch.py` | 本任务新写 | 统一启动入口 |
|
||||
| `scripts/cmd_vel_timeout.py` | 本任务新写 | 单一命令转发节点 `/cmd_vel → /sim/cmd_vel` |
|
||||
| `CMakeLists.txt`、`package.xml` | 本任务新写 | 构建/安装本包驱动与资源 |
|
||||
| `scripts/sim_data_adapter.py` | P3 新写 | 精确时间 TF 的真值与世界点云适配 |
|
||||
| `src/contact_drive.cpp` | P5 新写 | 可选接触支撑全向力驱动,不复制算法或外部轮控 |
|
||||
| `src/mid360_sensor.cpp` | P6 新写 | 物理步实时射线、真实批次时间、原 Livox 消息;扫描轨迹为近似 |
|
||||
| `src/mid360_imu.cpp` | P6 新写 | 原生 ImuSensor 的带时间戳比力/角速度包装,姿态标为不可用 |
|
||||
|
||||
> **R1 修正**:早期版本有一份 `urdf/r2027_omni_robot.urdf.xacro`,已删除并整体改为
|
||||
> `sdf/r2027_omni_robot.sdf.xacro`。**本包与文档中不再存在任何 `urdf/` 路径**;
|
||||
> 若在别处看到 `urdf/r2027_omni_robot.urdf.xacro`,那是过期引用,请以本节为准。
|
||||
|
||||
## 2. 只读参考(未复制)
|
||||
|
||||
外部包:`/home/kevin/r2027_gazebo_model/src/r2027_robot_description/`(只读)。
|
||||
|
||||
参考了什么:
|
||||
|
||||
- 四个圆柱支撑轮的尺寸语义:半径 **0.10 m**、轮心相对车体中心 **z = −0.05 m**、
|
||||
轮宽 0.06 m(本任务按自己的车体重新布置轮位,见 §3)。
|
||||
- 车体箱体高度 **0.16 m**、车体质量 **5.51 kg**、轮质量 **1.2 kg**(建模假设,见 §4)。
|
||||
|
||||
**没有复制**(任务明确禁止):
|
||||
|
||||
- `config/controllers.yaml` 与 `ros2_control` 相关配置;
|
||||
- 它的 `launch/robocon_robot.launch.py` 启动逻辑;
|
||||
- 它的 `rviz/robot.rviz`、`scripts/cmd_vel_watchdog.py`
|
||||
(本包的 `cmd_vel_timeout.py` 是独立实现:输入输出话题分离、仿真时间超时、退出补零);
|
||||
- 它的插件参数写法(本包按本机 `.so` 的实测行为核对,见 §5)。
|
||||
|
||||
外部包**未被修改**:哈希记录见 `sim_ws/log/p2_001/deliver/MANIFEST.txt`。
|
||||
|
||||
## 3. 尺寸与几何(本任务决定,R1 未改动)
|
||||
|
||||
| 项 | 取值 | 依据 |
|
||||
|---|---|---|
|
||||
| 水平外包络 | **0.80 × 0.80 m** | `minco_ws/src/scan/plan_manage/config/planner_vehicle.yaml` 记录的整车最大外包络 |
|
||||
| 车体箱体 | 0.80 × 0.80 × 0.16 m | 外包络即箱体 XY;高度沿用外部模型的 0.16 |
|
||||
| 支撑轮 | 4 × 圆柱,r = 0.10 m,宽 0.06 m | 半径沿用外部模型;**轮位重新布置** |
|
||||
| 轮心位置 | x = ±0.30 m,y = ±0.30 m,z = −0.05 m | 使轮外缘与箱体边沿齐平(max\|x\| = 0.40),外包络正好 0.80 |
|
||||
| `base_link` | 箱体几何中心 | 模型原点与它重合 |
|
||||
| 名义触地面 | base_link 下方 **0.15 m** | = 轮半径 0.10 − 轮心偏移 (−0.05) |
|
||||
|
||||
轮心位置是**本任务的设计决定**,不是外部模型的数值(外部为 x=±0.18、y=±0.22,配 0.53×0.56 车体)。
|
||||
改车体尺寸只需改 xacro 顶部四个 property。
|
||||
|
||||
## 4. 质量、质心与惯量(R1 修正为绕质心)
|
||||
|
||||
| 项 | 取值 | 说明 |
|
||||
|---|---|---|
|
||||
| 车体质量 | 5.51 kg | 沿用外部简化模型(建模假设) |
|
||||
| 轮质量 | 1.2 kg × 4 | 沿用外部简化模型 |
|
||||
| 总质量 M | **10.31 kg** | 5.51 + 4×1.2 |
|
||||
| 质心(相对 base_link) | **(0, 0, −0.023278370514) m** | `com_z = 4·m_w·wheel_z / M`;x/y 因对称性为 0 |
|
||||
| Ixx / Iyy / Izz(绕质心、轴向与 base_link 平行) | **0.757474524410 / 0.768034524410 / 1.465173333333 kg·m²** | 平行轴定理逐体累加 |
|
||||
| 非对角项 | **0** | 4 轮关于 x/y 对称,Σ m·dᵢdⱼ 相互抵消 |
|
||||
|
||||
**R1 改了什么**:惯性参考系从 base_link 原点移到组合质心
|
||||
(`<inertial><pose>0 0 com_z 0 0 0</pose>`),张量改为绕质心。
|
||||
**base_link、模型原点、collision、visual、TF 坐标一律未动**——
|
||||
`log/p2_001_r1/INERTIA_CHECK.md` 里有「修改前后几何签名一致」的核对。
|
||||
|
||||
> 改前那组值(ixx=iyy=0.7630613、izz=1.4651733)是**绕 base_link 原点**的,
|
||||
> 不是绕质心,**不能与上表混用**。
|
||||
|
||||
这些仍然是**建模假设**:真车质量、重心高度、轮组、雷达位置均未确认。
|
||||
P2 只验证平地运动学接口。后续 P5 接触模式与坡道实测见 `sim_ws/docs/P5_SLOPE.md`,
|
||||
仍不据此评价真实轮组牵引、打滑或实车制动距离。
|
||||
|
||||
## 5. 插件与本机实测行为
|
||||
|
||||
`libgazebo_ros_planar_move.so` 实际读取的参数:`update_rate`、`publish_rate`、
|
||||
`odometry_frame`、`robot_base_frame`、`publish_odom`、`publish_odom_tf`、
|
||||
`covariance_x/y/yaw`。
|
||||
|
||||
两点实测结论(不是照抄外部配置):
|
||||
|
||||
1. **`<cmd_vel>` 参数不被读取。** 写 `<cmd_vel>/sim/cmd_vel</cmd_vel>` 后
|
||||
`ros2 topic info /sim/cmd_vel` 显示**订阅者 0**,插件仍订阅 `/cmd_vel`,转发节点被绕过。
|
||||
改用官方 ROS remapping `<ros><remapping>cmd_vel:=sim/cmd_vel</remapping></ros>` 后生效
|
||||
(`/sim/cmd_vel` 订阅者为 `planar_move`)。
|
||||
2. **接触参数必须放在原生 SDF 里。** 同样的 `<mu1>/<mu2>/<kp>/<kd>` 写在 URDF 的
|
||||
`<gazebo reference>` 下不会进入物理引擎(证据见 `docs/P2_OMNI.md` §4.1)。
|
||||
|
||||
**频率口径**:`update_rate=100`、`publish_rate=50` 是**插件参数配置值**;
|
||||
实测 `/odom` 约 50 Hz(与 `publish_rate` 一致)。转发节点的发布率 100 Hz 同样是
|
||||
**配置值**,本轮没有逐条统计它的实测频率,不能互相替代。
|
||||
|
||||
## 6. 世界文件
|
||||
|
||||
`robocon_gazebo/worlds/robocon_robot.world` = 本包 `robocon_track_full.world` **原样** +
|
||||
一个 `libgazebo_ros_state.so`(WorldPlugin)声明。
|
||||
场地几何、物理、光照、`model://robocon_ground_full` 引用全部不变;
|
||||
原 `robocon_track_full.world` **未改动**(R1 亦未动)。
|
||||
|
||||
## 7. P5 可选接触驱动
|
||||
|
||||
`drive:=planar` 保持默认;`drive:=contact` 加载本包 `libbr_contact_drive.so`。
|
||||
只施加世界水平力和 Z 力矩,重力、真实碰撞决定 Z/roll/pitch;空中不施加推进力。
|
||||
坡面法线来自求解器接触,含理想重力补偿,不是轮子扭矩/真实摩擦模型。
|
||||
几何、质量、质心、惯量与上表一致,没有引入独立轮 link 或球形替代支撑。
|
||||
完整真值 odom 的线/角速度转为 base_link 系,TF 与 odom 由同一插件发布。
|
||||
场地包的坡道碰撞面朝向修复另见该包的 SOURCE_PROVENANCE.md;地图顶点与外部源不变。
|
||||
|
||||
## 8. P6 可选 MID360 兼容模式
|
||||
|
||||
`lidar:=true sensor_model:=mid360` 采用物理步射线和 200 Hz 原生 ImuSensor。
|
||||
光学原点仍为 base_link+(0,0,0.30) m;内置 IMU 相对光学原点的偏置按官方手册
|
||||
设为 (0.011,0.02329,−0.04412) m,轴向一致。车体安装仍是假设,未测量实车位置。
|
||||
采用非重复近似方向序列,不声称复现厂家光学轨迹;默认 ideal 无注入噪声,无材质反射率模型。
|
||||
可选 mild/stress 在物理观测后增加径向白噪声、丢点及 IMU 白噪声/固定偏置;
|
||||
参数来自本项目工程压力配置,不是厂家规格或实车标定,时间字段保持真实采样时刻。
|
||||
射线在每个真实 1 ms 物理步求交、每 100 ms 打包,时间字段没有人为细分到物理步之内。
|
||||
复用仓库原 Livox 消息定义,不运行硬件驱动;MID360 模式停用原瞬时点云适配器。
|
||||
默认 generic 模式保持原 P3 入口,详细语义与对照证据见 `sim_ws/docs/P6_LOCALIZATION.md`。
|
||||
@@ -0,0 +1,5 @@
|
||||
gazebo:
|
||||
ros__parameters:
|
||||
# 10 Hz makes 50/100 Hz ROS control timers advance in coarse bursts.
|
||||
# This affects only the robot launch; the historical field baseline stays intact.
|
||||
publish_rate: 100.0
|
||||
@@ -0,0 +1,25 @@
|
||||
# Engineering stress inputs, NOT calibrated specifications for a real MID360.
|
||||
ideal:
|
||||
range_stddev: 0.0
|
||||
dropout: 0.0
|
||||
accel_stddev: 0.0
|
||||
gyro_stddev: 0.0
|
||||
accel_bias: [0.0, 0.0, 0.0]
|
||||
gyro_bias: [0.0, 0.0, 0.0]
|
||||
seed: 2027
|
||||
mild:
|
||||
range_stddev: 0.005
|
||||
dropout: 0.01
|
||||
accel_stddev: 0.01
|
||||
gyro_stddev: 0.0005
|
||||
accel_bias: [0.005, -0.005, 0.01]
|
||||
gyro_bias: [0.0001, -0.0001, 0.0002]
|
||||
seed: 2027
|
||||
stress:
|
||||
range_stddev: 0.015
|
||||
dropout: 0.05
|
||||
accel_stddev: 0.04
|
||||
gyro_stddev: 0.0015
|
||||
accel_bias: [0.02, 0.01, 0.03]
|
||||
gyro_bias: [0.0005, -0.0005, 0.001]
|
||||
seed: 2027
|
||||
@@ -0,0 +1,236 @@
|
||||
"""启动简化全向机器人(SIM-P2-001)。
|
||||
|
||||
入口:
|
||||
ros2 launch r2027_robot_description robocon_robot.launch.py
|
||||
ros2 launch r2027_robot_description robocon_robot.launch.py gui:=false paused:=true
|
||||
|
||||
参数:
|
||||
drive planar(默认平地)或 contact(重力/接触决定高度和倾斜)
|
||||
gui 是否启动 gzclient(默认 true)
|
||||
paused 是否以暂停状态启动 gzserver(默认 false)
|
||||
verbose gzserver 详细日志(默认 false)
|
||||
world 覆盖 world(默认 robocon_gazebo/worlds/robocon_robot.world)
|
||||
x / y / z / yaw 出生位姿(默认 -4.5 / 4.5 / 0.17 / 0.0)
|
||||
entity 模型名(默认 r2027_omni)
|
||||
|
||||
启动的节点:
|
||||
gzserver(官方 gazebo_ros gzserver.launch.py,init/factory 各一次,force_system:=false)
|
||||
spawn_entity.py(-file,插入 xacro 展开后的 SDF 模型)
|
||||
static_transform_publisher(world -> odom,单位变换)
|
||||
cmd_vel_timeout(/cmd_vel -> /sim/cmd_vel,仿真时间超时零速)
|
||||
|
||||
为什么模型是 SDF 而不是 URDF:
|
||||
URDF 的 <gazebo reference="link"><mu1>/<mu2>/<kp>/<kd> 在本机链路上**不会**进入物理引擎
|
||||
(`gz sdf -p` 转换出的 collision 没有 <surface>,且 μ=0.05 与 μ=0.0 实测位移完全相同)。
|
||||
轮子因此退回默认 μ=1.0,planar_move 设定的速度每 10 ms 被摩擦拉低,2 s 只走出 0.31 m。
|
||||
改原生 SDF 后接触参数真正生效。代价是不再有 robot_state_publisher 的 URDF 关节树,
|
||||
而任务要求的 TF 只有 world->odom(静态)与 odom->base_link(插件发布),
|
||||
不含轮子帧,因此不需要 robot_state_publisher。
|
||||
|
||||
设计约束:
|
||||
1. 只起一个 gzserver;不启动 ros_gz_bridge、不加载 Fortress。
|
||||
2. odom->base_link 只由插件发布,world->odom 只由静态变换发布,没有第二处重复。
|
||||
3. 世界文件只比 robocon_track_full.world 多一个 libgazebo_ros_state.so world 插件。
|
||||
4. GAZEBO_MASTER_URI=11355、ROS_DOMAIN_ID=77、ROS_LOCALHOST_ONLY=1 与已验收基线一致。
|
||||
"""
|
||||
|
||||
import os
|
||||
import tempfile
|
||||
import math
|
||||
import yaml
|
||||
|
||||
import xacro
|
||||
from ament_index_python.packages import get_package_share_directory, get_package_prefix
|
||||
from launch import LaunchDescription
|
||||
from launch.actions import (
|
||||
DeclareLaunchArgument,
|
||||
IncludeLaunchDescription,
|
||||
SetEnvironmentVariable,
|
||||
OpaqueFunction,
|
||||
)
|
||||
from launch.conditions import IfCondition
|
||||
from launch.launch_description_sources import PythonLaunchDescriptionSource
|
||||
from launch.substitutions import LaunchConfiguration, PythonExpression, EnvironmentVariable
|
||||
from launch_ros.actions import Node
|
||||
|
||||
GAZEBO_MASTER_URI = 'http://127.0.0.1:11355'
|
||||
|
||||
DEFAULT_X = '-4.5'
|
||||
DEFAULT_Y = '4.5'
|
||||
DEFAULT_Z = '0.17'
|
||||
DEFAULT_YAW = '0.0'
|
||||
|
||||
|
||||
def generate_launch_description():
|
||||
gz_share = get_package_share_directory('robocon_gazebo')
|
||||
robot_share = get_package_share_directory('r2027_robot_description')
|
||||
gazebo_ros_share = get_package_share_directory('gazebo_ros')
|
||||
|
||||
sdf_xacro = os.path.join(robot_share, 'sdf', 'r2027_omni_robot.sdf.xacro')
|
||||
# 展开期就确定下来,写成一个文件交给 spawn_entity(-file),
|
||||
# 这样"实际插入的模型"是一个可直接复查的文件,而不是只在内存里的字符串。
|
||||
# Expand after launch arguments are resolved; no second physical sensor link.
|
||||
def expand_model(context):
|
||||
drive = LaunchConfiguration('drive').perform(context)
|
||||
if drive not in ('planar', 'contact'):
|
||||
raise ValueError('drive must be planar or contact')
|
||||
sensor_model = LaunchConfiguration('sensor_model').perform(context)
|
||||
if sensor_model not in ('generic', 'mid360'):
|
||||
raise ValueError('sensor_model must be generic or mid360')
|
||||
profile_name=LaunchConfiguration('sensor_profile').perform(context)
|
||||
with open(os.path.join(robot_share,'config','sensor_profiles.yaml'),encoding='utf-8') as stream:
|
||||
profiles=yaml.safe_load(stream)
|
||||
if profile_name not in profiles or (sensor_model!='mid360' and profile_name!='ideal'):
|
||||
raise ValueError('Unknown sensor profile or noisy profile with generic lidar')
|
||||
profile=profiles[profile_name]
|
||||
scalars=[profile[k] for k in ('range_stddev','dropout','accel_stddev','gyro_stddev')]
|
||||
if not all(math.isfinite(v) and v>=0 for v in scalars) or profile['dropout']>1:
|
||||
raise ValueError('Invalid sensor noise profile')
|
||||
for key in ('accel_bias','gyro_bias'):
|
||||
if len(profile[key])!=3 or not all(math.isfinite(v) for v in profile[key]):
|
||||
raise ValueError('Invalid IMU bias vector')
|
||||
if type(profile['seed']) is not int or not 0<=profile['seed']<2**32:
|
||||
raise ValueError('Invalid noise seed')
|
||||
noise={k:str(profile[k]) for k in ('range_stddev','dropout','accel_stddev','gyro_stddev')}
|
||||
noise.update({k:' '.join(map(str,profile[k])) for k in ('accel_bias','gyro_bias')})
|
||||
noise['noise_seed']=str(profile['seed'])
|
||||
model_xml = xacro.process_file(sdf_xacro, mappings={
|
||||
'lidar': LaunchConfiguration('lidar').perform(context), 'drive': drive,
|
||||
'sensor_model': sensor_model,**noise}).toxml()
|
||||
fd, path = tempfile.mkstemp(prefix='r2027_omni_', suffix='.sdf')
|
||||
with os.fdopen(fd, 'w', encoding='utf-8') as stream:
|
||||
stream.write(model_xml)
|
||||
context.launch_configurations['expanded_model'] = path
|
||||
return []
|
||||
|
||||
default_world = os.path.join(gz_share, 'worlds', 'robocon_robot.world')
|
||||
|
||||
model_path_parts = [os.path.join(gz_share, 'models'),
|
||||
os.path.expanduser('~/.gazebo/models')]
|
||||
if os.environ.get('GAZEBO_MODEL_PATH'):
|
||||
model_path_parts.append(os.environ['GAZEBO_MODEL_PATH'])
|
||||
|
||||
declared_args = [
|
||||
DeclareLaunchArgument('sensor_profile',default_value='ideal'),
|
||||
DeclareLaunchArgument('ros_domain_id',default_value=EnvironmentVariable('ROS_DOMAIN_ID',default_value='77')),
|
||||
DeclareLaunchArgument('ros_localhost_only',default_value=EnvironmentVariable('ROS_LOCALHOST_ONLY',default_value='1')),
|
||||
DeclareLaunchArgument('drive', default_value='planar'),
|
||||
DeclareLaunchArgument('sensor_model', default_value='generic'),
|
||||
DeclareLaunchArgument('lidar', default_value='false',
|
||||
description='Enable generic CPU 3D lidar and truth data adapter'),
|
||||
DeclareLaunchArgument('gui', default_value='true'),
|
||||
DeclareLaunchArgument('paused', default_value='false'),
|
||||
DeclareLaunchArgument('verbose', default_value='false'),
|
||||
DeclareLaunchArgument('world', default_value=default_world),
|
||||
DeclareLaunchArgument('x', default_value=DEFAULT_X),
|
||||
DeclareLaunchArgument('y', default_value=DEFAULT_Y),
|
||||
DeclareLaunchArgument('z', default_value=DEFAULT_Z),
|
||||
DeclareLaunchArgument('yaw', default_value=DEFAULT_YAW),
|
||||
DeclareLaunchArgument('entity', default_value='r2027_omni'),
|
||||
]
|
||||
|
||||
env_actions = [
|
||||
SetEnvironmentVariable('GAZEBO_PLUGIN_PATH', os.pathsep.join([
|
||||
os.path.join(get_package_prefix('r2027_robot_description'), 'lib'),
|
||||
os.environ.get('GAZEBO_PLUGIN_PATH', '')])),
|
||||
SetEnvironmentVariable('GAZEBO_MASTER_URI', GAZEBO_MASTER_URI),
|
||||
SetEnvironmentVariable('ROS_DOMAIN_ID', LaunchConfiguration('ros_domain_id')),
|
||||
SetEnvironmentVariable('ROS_LOCALHOST_ONLY', LaunchConfiguration('ros_localhost_only')),
|
||||
SetEnvironmentVariable('GAZEBO_MODEL_PATH', os.pathsep.join(model_path_parts)),
|
||||
# /usr/bin 放最前:本机 `python3` 可能先命中别的解释器(例如 3.13),
|
||||
# 而 rclpy / numpy 只装在系统 3.10 下。spawn_entity.py 用的是
|
||||
# `#!/usr/bin/env python3`,不固定 PATH 会 ImportError。
|
||||
SetEnvironmentVariable('PATH', '/usr/bin:' + os.environ.get('PATH', '')),
|
||||
]
|
||||
|
||||
gzserver = IncludeLaunchDescription(
|
||||
PythonLaunchDescriptionSource(
|
||||
os.path.join(gazebo_ros_share, 'launch', 'gzserver.launch.py')),
|
||||
launch_arguments={
|
||||
'world': LaunchConfiguration('world'),
|
||||
'verbose': LaunchConfiguration('verbose'),
|
||||
'pause': LaunchConfiguration('paused'),
|
||||
'init': 'true',
|
||||
'factory': 'true',
|
||||
'force_system': 'false',
|
||||
'params_file': os.path.join(robot_share, 'config', 'gazebo.yaml'),
|
||||
'server_required': 'true',
|
||||
}.items(),
|
||||
)
|
||||
|
||||
gzclient = IncludeLaunchDescription(
|
||||
PythonLaunchDescriptionSource(
|
||||
os.path.join(gazebo_ros_share, 'launch', 'gzclient.launch.py')),
|
||||
condition=IfCondition(LaunchConfiguration('gui')),
|
||||
)
|
||||
|
||||
spawn = Node(
|
||||
package='gazebo_ros',
|
||||
executable='spawn_entity.py',
|
||||
name='spawn_entity',
|
||||
output='screen',
|
||||
parameters=[{'use_sim_time': True}],
|
||||
arguments=[
|
||||
'-file', LaunchConfiguration('expanded_model'),
|
||||
'-entity', LaunchConfiguration('entity'),
|
||||
'-x', LaunchConfiguration('x'),
|
||||
'-y', LaunchConfiguration('y'),
|
||||
'-z', LaunchConfiguration('z'),
|
||||
'-Y', LaunchConfiguration('yaw'),
|
||||
'-timeout', '120',
|
||||
],
|
||||
)
|
||||
|
||||
# world -> odom:单位变换(真值模式,odom 与世界同源同向)
|
||||
world_to_odom = Node(
|
||||
package='tf2_ros',
|
||||
executable='static_transform_publisher',
|
||||
name='world_to_odom',
|
||||
output='screen',
|
||||
parameters=[{'use_sim_time': True}],
|
||||
arguments=['--frame-id', 'world',
|
||||
'--child-frame-id', 'odom',
|
||||
'--x', '0', '--y', '0', '--z', '0',
|
||||
'--roll', '0', '--pitch', '0', '--yaw', '0'],
|
||||
)
|
||||
|
||||
cmd_timeout = Node(
|
||||
package='r2027_robot_description',
|
||||
executable='cmd_vel_timeout.py',
|
||||
name='cmd_vel_timeout',
|
||||
output='screen',
|
||||
parameters=[{'use_sim_time': True,
|
||||
'input_topic': '/cmd_vel',
|
||||
'output_topic': '/sim/cmd_vel',
|
||||
'timeout': 0.5,
|
||||
'publish_rate': 100.0}],
|
||||
)
|
||||
|
||||
lidar_tf = Node(
|
||||
package='tf2_ros', executable='static_transform_publisher',
|
||||
name='base_to_lidar', condition=IfCondition(LaunchConfiguration('lidar')),
|
||||
parameters=[{'use_sim_time': True}],
|
||||
arguments=['--frame-id', 'base_link', '--child-frame-id', 'lidar',
|
||||
'--x', '0', '--y', '0', '--z', '0.30',
|
||||
'--roll', '0', '--pitch', '0', '--yaw', '0'])
|
||||
adapter = Node(
|
||||
package='r2027_robot_description', executable='sim_data_adapter.py',
|
||||
name='sim_data_adapter', condition=IfCondition(PythonExpression([
|
||||
"'", LaunchConfiguration('lidar'), "'.lower() == 'true' and '",
|
||||
LaunchConfiguration('sensor_model'), "' == 'generic'"])),
|
||||
parameters=[{'use_sim_time': True}])
|
||||
|
||||
imu_tf = Node(
|
||||
package='tf2_ros', executable='static_transform_publisher',name='base_to_mid360_imu',
|
||||
condition=IfCondition(PythonExpression([
|
||||
"'", LaunchConfiguration('lidar'), "'.lower() == 'true' and '",
|
||||
LaunchConfiguration('sensor_model'), "' == 'mid360'"])),
|
||||
parameters=[{'use_sim_time': True}],
|
||||
arguments=['--frame-id','base_link','--child-frame-id','mid360_imu',
|
||||
'--x','0.011','--y','0.02329','--z','0.25588',
|
||||
'--roll','0','--pitch','0','--yaw','0'])
|
||||
|
||||
return LaunchDescription(
|
||||
declared_args + env_actions
|
||||
+ [OpaqueFunction(function=expand_model), gzserver, gzclient, spawn,
|
||||
world_to_odom, cmd_timeout, lidar_tf, adapter, imu_tf])
|
||||
@@ -0,0 +1,42 @@
|
||||
<?xml version="1.0"?>
|
||||
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
|
||||
<package format="3">
|
||||
<name>r2027_robot_description</name>
|
||||
<version>0.1.0</version>
|
||||
<description>Gazebo Classic 11 / ROS 2 Humble simplified omni robot: planar or optional contact-force drive, command timeout guard, generic 3D lidar and truth adaptation.</description>
|
||||
<maintainer email="[email protected]">xie</maintainer>
|
||||
<license>Apache-2.0</license>
|
||||
|
||||
<buildtool_depend>ament_cmake</buildtool_depend>
|
||||
<build_depend>gazebo_dev</build_depend>
|
||||
<build_depend>gazebo_ros</build_depend>
|
||||
<build_depend>rclcpp</build_depend>
|
||||
<build_depend>nav_msgs</build_depend>
|
||||
<build_depend>geometry_msgs</build_depend>
|
||||
<build_depend>gazebo_msgs</build_depend>
|
||||
<build_depend>tf2_ros</build_depend>
|
||||
<depend>livox_ros_driver2</depend>
|
||||
<build_depend>sensor_msgs</build_depend>
|
||||
<depend>std_msgs</depend>
|
||||
|
||||
<exec_depend>gazebo_ros</exec_depend>
|
||||
<exec_depend>gazebo_plugins</exec_depend>
|
||||
<exec_depend>gazebo_msgs</exec_depend>
|
||||
<exec_depend>geometry_msgs</exec_depend>
|
||||
<exec_depend>nav_msgs</exec_depend>
|
||||
<exec_depend>sensor_msgs</exec_depend>
|
||||
<exec_depend>python3-numpy</exec_depend>
|
||||
<exec_depend>python3-yaml</exec_depend>
|
||||
<exec_depend>launch</exec_depend>
|
||||
<exec_depend>launch_ros</exec_depend>
|
||||
<exec_depend>ament_index_python</exec_depend>
|
||||
<exec_depend>rclpy</exec_depend>
|
||||
<exec_depend>rclcpp</exec_depend>
|
||||
<exec_depend>tf2_ros</exec_depend>
|
||||
<exec_depend>xacro</exec_depend>
|
||||
<exec_depend>robocon_gazebo</exec_depend>
|
||||
|
||||
<export>
|
||||
<build_type>ament_cmake</build_type>
|
||||
</export>
|
||||
</package>
|
||||
@@ -0,0 +1,121 @@
|
||||
#!/usr/bin/python3
|
||||
# -*- coding: utf-8 -*-
|
||||
"""单一命令转发节点(SIM-P2-001)。
|
||||
|
||||
职责边界(只做这一件事,不做运动学、不发布里程计):
|
||||
/cmd_vel ──► 本节点 ──► /sim/cmd_vel ──► libgazebo_ros_planar_move.so
|
||||
|
||||
为什么要它:planar_move 会把最近一次速度一直保持下去,本身没有超时保护。
|
||||
这里做三件事:
|
||||
1. 输入输出话题分开(订阅 /cmd_vel,发布 /sim/cmd_vel),插件只订阅后者,
|
||||
**不存在「订阅与发布同一话题」的反馈回路**;
|
||||
2. 指令静默超过 `timeout` 秒**仿真时间**后持续输出零速度;
|
||||
从未收到指令时也一直输出零;
|
||||
3. 正常退出前补发若干帧零速度,避免插件停在最后一帧非零速度上。
|
||||
|
||||
时间口径:全部用 ROS 仿真时间(`use_sim_time=true`)。暂停时时钟不前进,定时器不触发,
|
||||
所以暂停期间不会因为「墙钟超时」而擅自发零——这是有意的。
|
||||
"""
|
||||
|
||||
import rclpy
|
||||
from geometry_msgs.msg import Twist
|
||||
from rclpy.node import Node
|
||||
|
||||
|
||||
def _zero():
|
||||
return Twist()
|
||||
|
||||
|
||||
class CmdVelTimeout(Node):
|
||||
def __init__(self):
|
||||
super().__init__('cmd_vel_timeout')
|
||||
|
||||
self.declare_parameter('input_topic', '/cmd_vel')
|
||||
self.declare_parameter('output_topic', '/sim/cmd_vel')
|
||||
self.declare_parameter('timeout', 0.5) # 秒(仿真时间)
|
||||
self.declare_parameter('publish_rate', 50.0) # Hz(仿真时间)
|
||||
self.declare_parameter('shutdown_zero_frames', 5)
|
||||
|
||||
in_topic = self.get_parameter('input_topic').value
|
||||
out_topic = self.get_parameter('output_topic').value
|
||||
self.timeout = float(self.get_parameter('timeout').value)
|
||||
rate = float(self.get_parameter('publish_rate').value)
|
||||
self.shutdown_zero_frames = int(self.get_parameter('shutdown_zero_frames').value)
|
||||
|
||||
self.last_cmd_sim = None # 最近一次收到指令的仿真时刻
|
||||
self.last_cmd = _zero()
|
||||
self.is_stale = False # 当前是否处于「已超时、正在发零」
|
||||
self.count_in = 0
|
||||
self.count_out = 0
|
||||
self.count_zero_by_timeout = 0
|
||||
self.events = [] # [(sim_time, event)]
|
||||
|
||||
self.sub = self.create_subscription(Twist, in_topic, self._on_cmd, 10)
|
||||
self.pub = self.create_publisher(Twist, out_topic, 10)
|
||||
self.timer = self.create_timer(1.0 / max(rate, 1e-3), self._tick)
|
||||
|
||||
self.get_logger().info(
|
||||
'命令转发已启动:%s -> %s,超时 %.2f s(仿真时间),输出 %.0f Hz'
|
||||
% (in_topic, out_topic, self.timeout, rate))
|
||||
|
||||
# ------------------------------------------------------------------ 回调
|
||||
def _now_sim(self):
|
||||
return self.get_clock().now().nanoseconds * 1e-9
|
||||
|
||||
def _on_cmd(self, msg):
|
||||
self.count_in += 1
|
||||
self.last_cmd_sim = self._now_sim()
|
||||
self.last_cmd = msg
|
||||
if self.is_stale:
|
||||
self.is_stale = False
|
||||
self.events.append((self.last_cmd_sim, 'resume_from_timeout'))
|
||||
self.get_logger().info('收到新指令,结束超时零速(t=%.3f)' % self.last_cmd_sim)
|
||||
|
||||
def _tick(self):
|
||||
now = self._now_sim()
|
||||
if self.last_cmd_sim is None:
|
||||
self._publish(_zero())
|
||||
return
|
||||
if now - self.last_cmd_sim > self.timeout:
|
||||
if not self.is_stale:
|
||||
self.is_stale = True
|
||||
self.events.append((now, 'timeout_zero_start'))
|
||||
self.get_logger().info(
|
||||
'指令静默 %.3f s > %.2f s,开始持续输出零速度(t=%.3f)'
|
||||
% (now - self.last_cmd_sim, self.timeout, now))
|
||||
self.count_zero_by_timeout += 1
|
||||
self._publish(_zero())
|
||||
return
|
||||
self._publish(self.last_cmd)
|
||||
|
||||
def _publish(self, msg):
|
||||
self.pub.publish(msg)
|
||||
self.count_out += 1
|
||||
|
||||
# ------------------------------------------------------------------ 退出
|
||||
def shutdown_zero(self):
|
||||
"""正常退出前补发零速度,别让插件停在最后一帧非零上。"""
|
||||
for _ in range(max(self.shutdown_zero_frames, 1)):
|
||||
self.pub.publish(_zero())
|
||||
rclpy.spin_once(self, timeout_sec=0.01)
|
||||
|
||||
|
||||
def main():
|
||||
rclpy.init()
|
||||
node = CmdVelTimeout()
|
||||
try:
|
||||
rclpy.spin(node)
|
||||
except KeyboardInterrupt:
|
||||
pass
|
||||
finally:
|
||||
try:
|
||||
node.shutdown_zero()
|
||||
except Exception: # noqa: BLE001 - 退出阶段不再抛
|
||||
pass
|
||||
node.destroy_node()
|
||||
if rclpy.ok():
|
||||
rclpy.shutdown()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
@@ -0,0 +1,140 @@
|
||||
#!/usr/bin/python3
|
||||
"""Truth-mode SCAN inputs. No localization, command integration or invented timing.
|
||||
|
||||
The instantaneous lidar cloud is transformed with TF at its acquisition stamp.
|
||||
Pose is in world; Odometry twist stays in the stated child frame. The virtual
|
||||
lidar's 0.30 m mount is shared with the SDF and static TF in the robot launch.
|
||||
"""
|
||||
from array import array
|
||||
from collections import deque
|
||||
import copy
|
||||
|
||||
import numpy as np
|
||||
import rclpy
|
||||
from rclpy.duration import Duration
|
||||
from rclpy.node import Node
|
||||
from rclpy.qos import qos_profile_sensor_data
|
||||
from rclpy.time import Time
|
||||
from nav_msgs.msg import Odometry
|
||||
from sensor_msgs.msg import PointCloud2, PointField
|
||||
from tf2_ros import Buffer, TransformException, TransformListener
|
||||
|
||||
|
||||
def rotation(q):
|
||||
v = np.array([q.x, q.y, q.z, q.w], dtype=float)
|
||||
norm = np.linalg.norm(v)
|
||||
if not np.isfinite(norm) or norm < 1e-9:
|
||||
raise ValueError('invalid quaternion')
|
||||
x, y, z, w = v / norm
|
||||
return np.array([[1-2*(y*y+z*z), 2*(x*y-z*w), 2*(x*z+y*w)],
|
||||
[2*(x*y+z*w), 1-2*(x*x+z*z), 2*(y*z-x*w)],
|
||||
[2*(x*z-y*w), 2*(y*z+x*w), 1-2*(x*x+y*y)]])
|
||||
|
||||
|
||||
def xyz_views(msg, data=None):
|
||||
"""Respect PointCloud2 endianness, field offsets and row padding."""
|
||||
fields = {f.name: f for f in msg.fields}
|
||||
prefix = '>' if msg.is_bigendian else '<'
|
||||
result = []
|
||||
for name in ('x', 'y', 'z'):
|
||||
f = fields[name]
|
||||
if f.count != 1 or f.datatype not in (PointField.FLOAT32, PointField.FLOAT64):
|
||||
raise ValueError('unsupported XYZ layout')
|
||||
dt = prefix + ('f4' if f.datatype == PointField.FLOAT32 else 'f8')
|
||||
result.append(np.ndarray((msg.height, msg.width), dtype=dt,
|
||||
buffer=msg.data if data is None else data, offset=f.offset,
|
||||
strides=(msg.row_step, msg.point_step)))
|
||||
return result
|
||||
|
||||
|
||||
class SimDataAdapter(Node):
|
||||
def __init__(self):
|
||||
super().__init__('sim_data_adapter')
|
||||
self.tf = Buffer(cache_time=Duration(seconds=10))
|
||||
self.listener = TransformListener(self.tf, self)
|
||||
self.cloud_pub = self.create_publisher(PointCloud2, '/cloud_registered', 5)
|
||||
self.body_pub = self.create_publisher(Odometry, '/body_odom', 10)
|
||||
self.sensor_pub = self.create_publisher(Odometry, '/aft_mapped_to_init', 10)
|
||||
self.pending_cloud = deque(maxlen=10)
|
||||
self.pending_odom = deque(maxlen=50)
|
||||
self.create_subscription(PointCloud2, '/lidar/points',
|
||||
self.pending_cloud.append, qos_profile_sensor_data)
|
||||
self.create_subscription(Odometry, '/odom', self.pending_odom.append, 50)
|
||||
self.create_timer(0.02, self.flush)
|
||||
self.mount = np.array([0., 0., .30])
|
||||
self.clouds = 0
|
||||
self.odoms = 0
|
||||
|
||||
def flush(self):
|
||||
# Nonblocking TF queries: allow this executor to receive the next TF.
|
||||
for queue, handler in ((self.pending_odom, self.publish_odom),
|
||||
(self.pending_cloud, self.publish_cloud)):
|
||||
for _ in range(len(queue)):
|
||||
msg = queue.popleft()
|
||||
try:
|
||||
handler(msg)
|
||||
except TransformException:
|
||||
age = (self.get_clock().now() - Time.from_msg(msg.header.stamp)).nanoseconds
|
||||
if age < 2_000_000_000:
|
||||
queue.append(msg)
|
||||
else:
|
||||
self.get_logger().warning('Dropped sample: exact-stamp TF unavailable')
|
||||
except (ValueError, KeyError, TypeError) as exc:
|
||||
self.get_logger().error('Invalid input: %s' % exc)
|
||||
|
||||
def publish_cloud(self, msg):
|
||||
tr = self.tf.lookup_transform('world', msg.header.frame_id,
|
||||
Time.from_msg(msg.header.stamp))
|
||||
xyz = np.stack(xyz_views(msg), axis=-1)
|
||||
t = tr.transform.translation
|
||||
transformed = xyz @ rotation(tr.transform.rotation).T + [t.x, t.y, t.z]
|
||||
out = copy.deepcopy(msg)
|
||||
data = bytearray(msg.data)
|
||||
for i, v in enumerate(xyz_views(msg, data)):
|
||||
v[:] = transformed[..., i]
|
||||
out.data = array('B', data)
|
||||
out.header.frame_id = 'world'
|
||||
# Acquisition timestamp and every non-XYZ field stay unchanged.
|
||||
self.cloud_pub.publish(out)
|
||||
self.clouds += 1
|
||||
|
||||
def publish_odom(self, msg):
|
||||
tr = self.tf.lookup_transform('world', msg.header.frame_id,
|
||||
Time.from_msg(msg.header.stamp))
|
||||
# The current contract is an explicit identity world->odom static TF.
|
||||
# Reject a changed contract instead of silently relabelling coordinates.
|
||||
t = tr.transform.translation
|
||||
if np.linalg.norm([t.x, t.y, t.z]) > 1e-8 or not np.allclose(
|
||||
rotation(tr.transform.rotation), np.eye(3), atol=1e-8):
|
||||
raise ValueError('world->odom must be identity in truth mode')
|
||||
body = copy.deepcopy(msg)
|
||||
body.header.frame_id = 'world'
|
||||
self.body_pub.publish(body)
|
||||
sensor = copy.deepcopy(body)
|
||||
sensor.child_frame_id = 'lidar'
|
||||
p = body.pose.pose.position
|
||||
sensor_pos = np.array([p.x, p.y, p.z]) + rotation(body.pose.pose.orientation) @ self.mount
|
||||
sensor.pose.pose.position.x, sensor.pose.pose.position.y, sensor.pose.pose.position.z = map(float, sensor_pos)
|
||||
v = sensor.twist.twist.linear
|
||||
w = sensor.twist.twist.angular
|
||||
shifted = np.array([v.x, v.y, v.z]) + np.cross([w.x, w.y, w.z], self.mount)
|
||||
v.x, v.y, v.z = map(float, shifted)
|
||||
self.sensor_pub.publish(sensor)
|
||||
self.odoms += 1
|
||||
|
||||
|
||||
def main():
|
||||
rclpy.init()
|
||||
node = SimDataAdapter()
|
||||
try:
|
||||
rclpy.spin(node)
|
||||
except KeyboardInterrupt:
|
||||
pass
|
||||
finally:
|
||||
node.destroy_node()
|
||||
if rclpy.ok():
|
||||
rclpy.shutdown()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
@@ -0,0 +1,246 @@
|
||||
<?xml version="1.0"?>
|
||||
<!--
|
||||
SIM-P2-001 / -R1 简化全向机器人(Gazebo Classic 11 + ROS 2 Humble)—— 原生 SDF
|
||||
|
||||
为什么是 SDF 而不是 URDF(实测结论,不是偏好):
|
||||
URDF 的 <gazebo reference="link"><mu1>/<mu2>/<kp>/<kd> 在本机这条链路上**没有生效**。
|
||||
证据:μ 改 0.05 与改 0.0 测得的 2 s 位移完全一致(均 0.3137 m),
|
||||
且 `gz sdf -p`(gazebo 11.10.2 自带工具)转换 URDF 时输出的 collision **没有 <surface>**。
|
||||
改成原生 SDF 后 <surface> 直接进入物理引擎。
|
||||
|
||||
单刚体:四个支撑轮以 collision/visual 的形式并在 base_link 内。做成一个刚体而不是
|
||||
5 个 link + fixed joint,是实测驱动的选择(见 docs/P2_OMNI.md §4.2)。
|
||||
注意:那只解释了「当时观察到转向只有指令的 0.386 倍」这一现象,**内部机理尚未完全定位**,
|
||||
不能推广成「独立轮 link 必然如此」。
|
||||
|
||||
几何(R1 未改动):
|
||||
- 水平外包络 0.80 × 0.80 m(含四个支撑轮),与 planner_vehicle.yaml 一致;
|
||||
- 车体箱体 0.80 × 0.80 × 0.16 m,mass 5.51 kg(建模假设);
|
||||
- 四个圆柱支撑轮 r=0.10 m、宽 0.06 m、mass 1.2 kg,轮心相对车体中心 z=-0.05 m;
|
||||
- base_link 位于箱体几何中心,模型原点与它重合,名义触地面在 base_link 下方 0.15 m。
|
||||
|
||||
惯量(R1 修正):惯性参考系移到**组合质心**(z = com_z),张量绕质心、轴向与 base_link 平行。
|
||||
只改惯性参考系与张量;base_link、模型原点、collision、visual 和 TF 坐标一律不移动。
|
||||
-->
|
||||
<sdf version="1.6" xmlns:xacro="http://www.ros.org/wiki/xacro">
|
||||
<xacro:arg name="lidar" default="false"/>
|
||||
<xacro:arg name="drive" default="planar"/>
|
||||
<xacro:arg name="sensor_model" default="generic"/>
|
||||
<xacro:arg name="range_stddev" default="0"/>
|
||||
<xacro:arg name="dropout" default="0"/>
|
||||
<xacro:arg name="accel_stddev" default="0"/>
|
||||
<xacro:arg name="gyro_stddev" default="0"/>
|
||||
<xacro:arg name="accel_bias" default="0 0 0"/>
|
||||
<xacro:arg name="gyro_bias" default="0 0 0"/>
|
||||
<xacro:arg name="noise_seed" default="2027"/>
|
||||
<xacro:property name="body_length" value="0.80"/>
|
||||
<xacro:property name="body_width" value="0.80"/>
|
||||
<xacro:property name="body_height" value="0.16"/>
|
||||
|
||||
<xacro:property name="body_mass" value="5.51"/>
|
||||
<xacro:property name="wheel_mass" value="1.2"/>
|
||||
|
||||
<xacro:property name="wheel_radius" value="0.10"/>
|
||||
<xacro:property name="wheel_width" value="0.06"/>
|
||||
<xacro:property name="wheel_x" value="0.30"/>
|
||||
<xacro:property name="wheel_y" value="0.30"/>
|
||||
<xacro:property name="wheel_z" value="-0.05"/>
|
||||
|
||||
<!-- 各刚体绕自身 COM 的惯量(按简化几何算,不是实车惯量) -->
|
||||
<xacro:property name="body_ixx"
|
||||
value="${body_mass * (body_width*body_width + body_height*body_height) / 12.0}"/>
|
||||
<xacro:property name="body_iyy"
|
||||
value="${body_mass * (body_length*body_length + body_height*body_height) / 12.0}"/>
|
||||
<xacro:property name="body_izz"
|
||||
value="${body_mass * (body_length*body_length + body_width*body_width) / 12.0}"/>
|
||||
<!-- 圆柱轴沿 Y(绕 X 转 90°):轴向 = Y,径向 = X/Z -->
|
||||
<xacro:property name="wheel_i_axis"
|
||||
value="${0.5 * wheel_mass * wheel_radius * wheel_radius}"/>
|
||||
<xacro:property name="wheel_i_perp"
|
||||
value="${wheel_mass * (3.0*wheel_radius*wheel_radius + wheel_width*wheel_width) / 12.0}"/>
|
||||
|
||||
<!-- 组合刚体:总质量、质心、绕质心的惯量(全部由参数算,不写近似常数)。
|
||||
车体箱体 COM 在 base_link 原点 (0,0,0);四个轮子 COM 在 (±wheel_x, ±wheel_y, wheel_z),
|
||||
关于 x/y 对称 ⇒ 质心只在 z 上偏移:com_z = 4·m_w·wheel_z / M。
|
||||
绕质心用平行轴:自身 COM 惯量 + m·|d|²,d 为自身 COM 指向系统质心的向量。
|
||||
z 向偏移只进 Ixx/Iyy(含 dz²),不进 Izz(只含 dx²+dy²)。 -->
|
||||
<xacro:property name="total_mass" value="${body_mass + 4.0*wheel_mass}"/>
|
||||
<xacro:property name="com_z" value="${4.0*wheel_mass*wheel_z / total_mass}"/>
|
||||
<xacro:property name="dz_body" value="${0.0 - com_z}"/>
|
||||
<xacro:property name="dz_wheel" value="${wheel_z - com_z}"/>
|
||||
<xacro:property name="tot_ixx"
|
||||
value="${body_ixx + body_mass*dz_body*dz_body + 4.0*(wheel_i_perp + wheel_mass*(wheel_y*wheel_y + dz_wheel*dz_wheel))}"/>
|
||||
<xacro:property name="tot_iyy"
|
||||
value="${body_iyy + body_mass*dz_body*dz_body + 4.0*(wheel_i_axis + wheel_mass*(wheel_x*wheel_x + dz_wheel*dz_wheel))}"/>
|
||||
<xacro:property name="tot_izz"
|
||||
value="${body_izz + 4.0*(wheel_i_perp + wheel_mass*(wheel_x*wheel_x + wheel_y*wheel_y))}"/>
|
||||
|
||||
<!-- 支撑轮:碰撞 + 显示,作为单刚体的一部分(不是独立 link) -->
|
||||
<xacro:macro name="omni_wheel" params="name x_sign y_sign">
|
||||
<collision name="${name}_wheel_collision">
|
||||
<pose>${x_sign * wheel_x} ${y_sign * wheel_y} ${wheel_z} 1.5707963267948966 0 0</pose>
|
||||
<geometry>
|
||||
<cylinder>
|
||||
<radius>${wheel_radius}</radius>
|
||||
<length>${wheel_width}</length>
|
||||
</cylinder>
|
||||
</geometry>
|
||||
<!-- 轮子是**固定支撑件**,不是被驱动的摩擦轮:planar_move 每 10 ms 直接设定车体速度,
|
||||
接触摩擦按 μ=1.0 会把这个速度每周期拉低三成(实测 0.19→0.12 m/s)。
|
||||
μ=0.01 是建模选择,让运动学接口不被轮胎摩擦掩盖;**不代表实车轮组摩擦**,
|
||||
也不用于评价爬坡/制动。 -->
|
||||
<surface>
|
||||
<friction>
|
||||
<ode>
|
||||
<mu>0.01</mu>
|
||||
<mu2>0.01</mu2>
|
||||
<slip1>0.0</slip1>
|
||||
<slip2>0.0</slip2>
|
||||
</ode>
|
||||
</friction>
|
||||
<contact>
|
||||
<ode>
|
||||
<soft_cfm>0</soft_cfm>
|
||||
<soft_erp>0.2</soft_erp>
|
||||
<kp>1000000.0</kp>
|
||||
<kd>100.0</kd>
|
||||
<max_vel>0.1</max_vel>
|
||||
<min_depth>0.001</min_depth>
|
||||
</ode>
|
||||
</contact>
|
||||
</surface>
|
||||
</collision>
|
||||
<visual name="${name}_wheel_visual">
|
||||
<pose>${x_sign * wheel_x} ${y_sign * wheel_y} ${wheel_z} 1.5707963267948966 0 0</pose>
|
||||
<geometry>
|
||||
<cylinder>
|
||||
<radius>${wheel_radius}</radius>
|
||||
<length>${wheel_width}</length>
|
||||
</cylinder>
|
||||
</geometry>
|
||||
<material>
|
||||
<ambient>0.18 0.18 0.18 1</ambient>
|
||||
<diffuse>0.18 0.18 0.18 1</diffuse>
|
||||
</material>
|
||||
</visual>
|
||||
</xacro:macro>
|
||||
|
||||
<model name="r2027_omni">
|
||||
<static>false</static>
|
||||
<allow_auto_disable>false</allow_auto_disable>
|
||||
|
||||
<!-- ===== 车体:base_link 即箱体几何中心,模型原点与它重合 ===== -->
|
||||
<link name="base_link">
|
||||
<pose>0 0 0 0 0 0</pose>
|
||||
<inertial>
|
||||
<!-- 惯性参考系在组合质心(z = com_z),不是 base_link 原点 -->
|
||||
<pose>0 0 ${com_z} 0 0 0</pose>
|
||||
<mass>${total_mass}</mass>
|
||||
<inertia>
|
||||
<ixx>${tot_ixx}</ixx>
|
||||
<ixy>0</ixy>
|
||||
<ixz>0</ixz>
|
||||
<iyy>${tot_iyy}</iyy>
|
||||
<iyz>0</iyz>
|
||||
<izz>${tot_izz}</izz>
|
||||
</inertia>
|
||||
</inertial>
|
||||
<collision name="body_collision">
|
||||
<pose>0 0 0 0 0 0</pose>
|
||||
<geometry>
|
||||
<box><size>${body_length} ${body_width} ${body_height}</size></box>
|
||||
</geometry>
|
||||
</collision>
|
||||
<visual name="body_visual">
|
||||
<pose>0 0 0 0 0 0</pose>
|
||||
<geometry>
|
||||
<box><size>${body_length} ${body_width} ${body_height}</size></box>
|
||||
</geometry>
|
||||
<material>
|
||||
<ambient>0.206 0.396 0.831 1</ambient>
|
||||
<diffuse>0.206 0.396 0.831 1</diffuse>
|
||||
<specular>0.1 0.1 0.1 1</specular>
|
||||
</material>
|
||||
</visual>
|
||||
|
||||
<xacro:omni_wheel name="front_left" x_sign="1" y_sign="1"/>
|
||||
<xacro:omni_wheel name="front_right" x_sign="1" y_sign="-1"/>
|
||||
<xacro:omni_wheel name="rear_left" x_sign="-1" y_sign="1"/>
|
||||
<xacro:omni_wheel name="rear_right" x_sign="-1" y_sign="-1"/>
|
||||
<!-- Generic instantaneous 3D ray sensor; this is not a MID360 timing model.
|
||||
Mount is a simulation assumption: 0.30 m above base_link, axes aligned. -->
|
||||
<xacro:if value="$(arg lidar)">
|
||||
<xacro:if value="${'$(arg sensor_model)' == 'generic'}">
|
||||
<sensor name="lidar" type="ray">
|
||||
<pose>0 0 0.30 0 0 0</pose>
|
||||
<always_on>true</always_on>
|
||||
<visualize>false</visualize>
|
||||
<update_rate>10</update_rate>
|
||||
<ray>
|
||||
<scan>
|
||||
<horizontal><samples>720</samples><resolution>1</resolution>
|
||||
<min_angle>-3.141592653589793</min_angle><max_angle>3.141592653589793</max_angle>
|
||||
</horizontal>
|
||||
<vertical><samples>32</samples><resolution>1</resolution>
|
||||
<min_angle>-0.523598775598299</min_angle><max_angle>0.523598775598299</max_angle>
|
||||
</vertical>
|
||||
</scan>
|
||||
<range><min>0.15</min><max>20</max><resolution>0.01</resolution></range>
|
||||
</ray>
|
||||
<plugin name="lidar_ros" filename="libgazebo_ros_ray_sensor.so">
|
||||
<ros><remapping>~/out:=/lidar/points</remapping></ros>
|
||||
<output_type>sensor_msgs/PointCloud2</output_type>
|
||||
<frame_name>lidar</frame_name>
|
||||
</plugin>
|
||||
</sensor>
|
||||
</xacro:if>
|
||||
<xacro:if value="${'$(arg sensor_model)' == 'mid360'}">
|
||||
<!-- Official manual: IMU is (11,23.29,-44.12) mm in optical coordinates. -->
|
||||
<sensor name="mid360_imu" type="imu">
|
||||
<pose>0.011 0.02329 0.25588 0 0 0</pose>
|
||||
<always_on>true</always_on><update_rate>200</update_rate>
|
||||
<imu/>
|
||||
<plugin name="mid360_imu" filename="libbr_mid360_imu.so">
|
||||
<accel_stddev>$(arg accel_stddev)</accel_stddev><gyro_stddev>$(arg gyro_stddev)</gyro_stddev>
|
||||
<accel_bias>$(arg accel_bias)</accel_bias><gyro_bias>$(arg gyro_bias)</gyro_bias>
|
||||
<noise_seed>$(arg noise_seed)</noise_seed>
|
||||
</plugin>
|
||||
</sensor>
|
||||
</xacro:if>
|
||||
</xacro:if>
|
||||
</link>
|
||||
<xacro:if value="$(arg lidar)">
|
||||
<xacro:if value="${'$(arg sensor_model)' == 'mid360'}">
|
||||
<plugin name="mid360_sensor" filename="libbr_mid360_sensor.so">
|
||||
<range_stddev>$(arg range_stddev)</range_stddev><dropout>$(arg dropout)</dropout>
|
||||
<noise_seed>$(arg noise_seed)</noise_seed>
|
||||
</plugin>
|
||||
</xacro:if>
|
||||
</xacro:if>
|
||||
|
||||
<!-- ===== 运动插件:只订阅 /sim/cmd_vel,发 /odom 与 odom→base_link ===== -->
|
||||
<xacro:if value="${'$(arg drive)' == 'planar'}">
|
||||
<plugin filename="libgazebo_ros_planar_move.so" name="planar_move">
|
||||
<update_rate>100</update_rate>
|
||||
<publish_rate>50</publish_rate>
|
||||
<!-- 命令话题用官方 ROS remapping 指定,不用 <cmd_vel> 参数:
|
||||
本机实测 <cmd_vel>/sim/cmd_vel</cmd_vel> 会被忽略,插件仍订阅 /cmd_vel
|
||||
(`ros2 topic info /sim/cmd_vel` 订阅者数 = 0),转发节点因此被绕过。
|
||||
remapping 是 gazebo_ros 官方支持的方式,实测生效。 -->
|
||||
<ros>
|
||||
<remapping>cmd_vel:=sim/cmd_vel</remapping>
|
||||
</ros>
|
||||
<odometry_frame>odom</odometry_frame>
|
||||
<robot_base_frame>base_link</robot_base_frame>
|
||||
<publish_odom>true</publish_odom>
|
||||
<publish_odom_tf>true</publish_odom_tf>
|
||||
<covariance_x>0.0</covariance_x>
|
||||
<covariance_y>0.0</covariance_y>
|
||||
<covariance_yaw>0.0</covariance_yaw>
|
||||
</plugin>
|
||||
</xacro:if>
|
||||
<xacro:if value="${'$(arg drive)' == 'contact'}">
|
||||
<plugin filename="libbr_contact_drive.so" name="contact_drive"/>
|
||||
</xacro:if>
|
||||
</model>
|
||||
</sdf>
|
||||
@@ -0,0 +1,160 @@
|
||||
// Simplified contact-supported omnidirectional actuator, not a wheel traction model.
|
||||
// No SetPose/SetLinearVel/SetAngularVel: z, roll and pitch belong to the physics solver.
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include <functional>
|
||||
#include <mutex>
|
||||
#include <gazebo/gazebo.hh>
|
||||
#include <gazebo/physics/physics.hh>
|
||||
#include <gazebo_ros/node.hpp>
|
||||
#include <gazebo_ros/conversions/builtin_interfaces.hpp>
|
||||
#include <geometry_msgs/msg/twist.hpp>
|
||||
#include <geometry_msgs/msg/wrench_stamped.hpp>
|
||||
#include <gazebo_msgs/msg/contacts_state.hpp>
|
||||
#include <nav_msgs/msg/odometry.hpp>
|
||||
#include <tf2_ros/transform_broadcaster.h>
|
||||
|
||||
namespace br_sim {
|
||||
class ContactDrive : public gazebo::ModelPlugin {
|
||||
public:
|
||||
void Load(gazebo::physics::ModelPtr model, sdf::ElementPtr sdf) override {
|
||||
model_ = model;
|
||||
world_ = model->GetWorld();
|
||||
link_ = model->GetLink("base_link");
|
||||
if (!link_) { gzerr << "ContactDrive requires base_link\n"; return; }
|
||||
node_ = gazebo_ros::Node::Get(sdf);
|
||||
manager_ = world_->Physics()->GetContactManager();
|
||||
// Request real ODE contact geometry even without a separate contact sensor.
|
||||
manager_->SetNeverDropContacts(true);
|
||||
sub_ = node_->create_subscription<geometry_msgs::msg::Twist>("/sim/cmd_vel", 1,
|
||||
[this](geometry_msgs::msg::Twist::SharedPtr m) {
|
||||
if (!std::isfinite(m->linear.x) || !std::isfinite(m->linear.y) ||
|
||||
!std::isfinite(m->angular.z)) return;
|
||||
std::lock_guard<std::mutex> guard(mutex_);
|
||||
cmd_ = *m; received_ = world_->SimTime().Double();
|
||||
});
|
||||
odom_pub_ = node_->create_publisher<nav_msgs::msg::Odometry>("/odom", 10);
|
||||
contact_pub_ = node_->create_publisher<gazebo_msgs::msg::ContactsState>("/sim/drive_contacts", 10);
|
||||
force_pub_ = node_->create_publisher<geometry_msgs::msg::WrenchStamped>("/sim/drive_wrench", 10);
|
||||
tf_ = std::make_shared<tf2_ros::TransformBroadcaster>(node_);
|
||||
begin_ = gazebo::event::Events::ConnectWorldUpdateBegin(
|
||||
std::bind(&ContactDrive::Actuate, this));
|
||||
end_ = gazebo::event::Events::ConnectWorldUpdateEnd(
|
||||
std::bind(&ContactDrive::Publish, this));
|
||||
RCLCPP_INFO(node_->get_logger(), "Contact force drive: gravity/contact control z/R/P; odom at base_link");
|
||||
}
|
||||
|
||||
private:
|
||||
bool Own(gazebo::physics::Collision *c) const { return c && c->GetLink() == link_; }
|
||||
void Actuate() {
|
||||
ignition::math::Vector3d normal(0,0,0);
|
||||
for (unsigned i=0; i<manager_->GetContactCount(); ++i) {
|
||||
const auto *c = manager_->GetContact(i);
|
||||
if (!Own(c->collision1) && !Own(c->collision2)) continue;
|
||||
for (int j=0; j<c->count; ++j) {
|
||||
auto n = c->normals[j]; if (n.Z()<0) n=-n;
|
||||
if (n.Z()>.5) normal += n;
|
||||
}
|
||||
}
|
||||
applied_force_.Set(0,0,0); applied_torque_.Set(0,0,0);
|
||||
if (normal.Length()<1e-6) return; // No ground support => no flight actuator.
|
||||
normal.Normalize();
|
||||
geometry_msgs::msg::Twist cmd;
|
||||
{
|
||||
std::lock_guard<std::mutex> guard(mutex_);
|
||||
if (world_->SimTime().Double()-received_ >= 0 &&
|
||||
world_->SimTime().Double()-received_ <= .5) cmd=cmd_;
|
||||
}
|
||||
const auto desired=link_->WorldPose().Rot().RotateVector(ignition::math::Vector3d(
|
||||
std::clamp(cmd.linear.x,-.5,.5),std::clamp(cmd.linear.y,-.5,.5),0));
|
||||
const double vx=desired.X(),vy=desired.Y();
|
||||
const auto v=link_->WorldLinearVel();
|
||||
const double ax=std::clamp(40*(vx-v.X()),-4.,4.);
|
||||
const double ay=std::clamp(40*(vy-v.Y()),-4.,4.);
|
||||
// Project dynamics into the measured contact tangent plane. Solve the 2x2
|
||||
// horizontal block for force; its z component remains exactly zero.
|
||||
const auto g=world_->Gravity();
|
||||
const auto gt=g-normal*normal.Dot(g);
|
||||
const double nx=normal.X(), ny=normal.Y(), nz=normal.Z();
|
||||
const double bx=ax-gt.X(), by=ay-gt.Y();
|
||||
const double mass=link_->GetInertial()->Mass();
|
||||
const double det=nz*nz;
|
||||
applied_force_.Set(mass*((1-ny*ny)*bx+nx*ny*by)/det,
|
||||
mass*(nx*ny*bx+(1-nx*nx)*by)/det,0);
|
||||
if (applied_force_.Length()>150.) applied_force_ *= 150./applied_force_.Length();
|
||||
const double wz=std::clamp(cmd.angular.z,-.5,.5);
|
||||
const double alpha=std::clamp(40*(wz-link_->WorldAngularVel().Z()),-5.,5.);
|
||||
applied_torque_.Z(link_->GetInertial()->IZZ()*alpha);
|
||||
link_->AddForce(applied_force_);
|
||||
link_->AddTorque(applied_torque_);
|
||||
}
|
||||
|
||||
void Publish() {
|
||||
const double now=world_->SimTime().Double();
|
||||
if (now-last_pub_<.02-1e-9 && now>=last_pub_) return;
|
||||
last_pub_=now;
|
||||
const auto stamp=gazebo_ros::Convert<builtin_interfaces::msg::Time>(world_->SimTime());
|
||||
const auto pose=link_->WorldPose();
|
||||
const auto linear=pose.Rot().RotateVectorReverse(link_->WorldLinearVel());
|
||||
const auto angular=pose.Rot().RotateVectorReverse(link_->WorldAngularVel());
|
||||
nav_msgs::msg::Odometry od;
|
||||
od.header.stamp=stamp; od.header.frame_id="odom"; od.child_frame_id="base_link";
|
||||
auto &p=od.pose.pose.position; p.x=pose.Pos().X();p.y=pose.Pos().Y();p.z=pose.Pos().Z();
|
||||
auto &q=od.pose.pose.orientation;q.x=pose.Rot().X();q.y=pose.Rot().Y();q.z=pose.Rot().Z();q.w=pose.Rot().W();
|
||||
auto &v=od.twist.twist.linear;v.x=linear.X();v.y=linear.Y();v.z=linear.Z();
|
||||
auto &w=od.twist.twist.angular;w.x=angular.X();w.y=angular.Y();w.z=angular.Z();
|
||||
odom_pub_->publish(od);
|
||||
geometry_msgs::msg::TransformStamped tf;
|
||||
tf.header=od.header;tf.child_frame_id=od.child_frame_id;tf.transform.rotation=q;
|
||||
tf.transform.translation.x=p.x;tf.transform.translation.y=p.y;tf.transform.translation.z=p.z;
|
||||
tf_->sendTransform(tf);
|
||||
geometry_msgs::msg::WrenchStamped force;
|
||||
force.header.stamp=stamp;force.header.frame_id="world";
|
||||
force.wrench.force.x=applied_force_.X();force.wrench.force.y=applied_force_.Y();
|
||||
force.wrench.torque.z=applied_torque_.Z();force_pub_->publish(force);
|
||||
gazebo_msgs::msg::ContactsState contacts;
|
||||
contacts.header.stamp=stamp;contacts.header.frame_id="world";
|
||||
for (unsigned i=0; i<manager_->GetContactCount(); ++i) {
|
||||
const auto *c=manager_->GetContact(i);
|
||||
const bool first=Own(c->collision1);
|
||||
if (!first && !Own(c->collision2)) continue;
|
||||
gazebo_msgs::msg::ContactState state;
|
||||
state.collision1_name=c->collision1->GetScopedName();
|
||||
state.collision2_name=c->collision2->GetScopedName();
|
||||
for(int j=0;j<c->count;++j) {
|
||||
geometry_msgs::msg::Vector3 n;geometry_msgs::msg::Vector3 pos;
|
||||
n.x=c->normals[j].X();n.y=c->normals[j].Y();n.z=c->normals[j].Z();
|
||||
pos.x=c->positions[j].X();pos.y=c->positions[j].Y();pos.z=c->positions[j].Z();
|
||||
state.contact_positions.push_back(pos);state.contact_normals.push_back(n);
|
||||
state.depths.push_back(c->depths[j]);
|
||||
geometry_msgs::msg::Wrench wr;
|
||||
const auto f=first?c->wrench[j].body1Force:c->wrench[j].body2Force;
|
||||
const auto t=first?c->wrench[j].body1Torque:c->wrench[j].body2Torque;
|
||||
wr.force.x=f.X();wr.force.y=f.Y();wr.force.z=f.Z();
|
||||
wr.torque.x=t.X();wr.torque.y=t.Y();wr.torque.z=t.Z();
|
||||
state.wrenches.push_back(wr);
|
||||
state.total_wrench.force.x+=wr.force.x;state.total_wrench.force.y+=wr.force.y;state.total_wrench.force.z+=wr.force.z;
|
||||
state.total_wrench.torque.x+=wr.torque.x;state.total_wrench.torque.y+=wr.torque.y;state.total_wrench.torque.z+=wr.torque.z;
|
||||
}
|
||||
contacts.states.push_back(state);
|
||||
}
|
||||
contact_pub_->publish(contacts);
|
||||
}
|
||||
gazebo::physics::ModelPtr model_;
|
||||
gazebo::physics::WorldPtr world_;
|
||||
gazebo::physics::LinkPtr link_;
|
||||
gazebo::physics::ContactManager *manager_{};
|
||||
gazebo_ros::Node::SharedPtr node_;
|
||||
gazebo::event::ConnectionPtr begin_,end_;
|
||||
rclcpp::Subscription<geometry_msgs::msg::Twist>::SharedPtr sub_;
|
||||
rclcpp::Publisher<nav_msgs::msg::Odometry>::SharedPtr odom_pub_;
|
||||
rclcpp::Publisher<gazebo_msgs::msg::ContactsState>::SharedPtr contact_pub_;
|
||||
rclcpp::Publisher<geometry_msgs::msg::WrenchStamped>::SharedPtr force_pub_;
|
||||
std::shared_ptr<tf2_ros::TransformBroadcaster> tf_;
|
||||
std::mutex mutex_;
|
||||
geometry_msgs::msg::Twist cmd_;
|
||||
double received_{-1},last_pub_{-1};
|
||||
ignition::math::Vector3d applied_force_,applied_torque_;
|
||||
};
|
||||
GZ_REGISTER_MODEL_PLUGIN(ContactDrive)
|
||||
} // namespace br_sim
|
||||
@@ -0,0 +1,65 @@
|
||||
// Thin ROS wrapper over Gazebo's physical ImuSensor, with no attitude oracle.
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <random>
|
||||
#include <cmath>
|
||||
#include <stdexcept>
|
||||
#include <gazebo/gazebo.hh>
|
||||
#include <gazebo/sensors/ImuSensor.hh>
|
||||
#include <gazebo_ros/node.hpp>
|
||||
#include <gazebo_ros/conversions/builtin_interfaces.hpp>
|
||||
#include <sensor_msgs/msg/imu.hpp>
|
||||
|
||||
namespace br_sim {
|
||||
class Mid360Imu : public gazebo::SensorPlugin {
|
||||
public:
|
||||
void Load(gazebo::sensors::SensorPtr sensor,sdf::ElementPtr sdf) override {
|
||||
sensor_=std::dynamic_pointer_cast<gazebo::sensors::ImuSensor>(sensor);
|
||||
if(!sensor_) {gzerr << "Mid360Imu requires a physical ImuSensor\n";return;}
|
||||
accel_stddev_=sdf->Get<double>("accel_stddev",0.).first;
|
||||
gyro_stddev_=sdf->Get<double>("gyro_stddev",0.).first;
|
||||
accel_bias_=sdf->Get<ignition::math::Vector3d>("accel_bias",{}).first;
|
||||
gyro_bias_=sdf->Get<ignition::math::Vector3d>("gyro_bias",{}).first;
|
||||
if(!std::isfinite(accel_stddev_) || accel_stddev_<0 || !std::isfinite(gyro_stddev_) || gyro_stddev_<0 ||
|
||||
!accel_bias_.IsFinite() || !gyro_bias_.IsFinite()) throw std::invalid_argument("Invalid IMU noise/bias");
|
||||
rng_.seed(sdf->Get<unsigned>("noise_seed",2027u).first+1u);
|
||||
node_=gazebo_ros::Node::Get(sdf);
|
||||
pub_=node_->create_publisher<sensor_msgs::msg::Imu>("/sim/mid360/imu",rclcpp::SensorDataQoS().reliable());
|
||||
update_=sensor_->ConnectUpdated(std::bind(&Mid360Imu::Publish,this));
|
||||
}
|
||||
private:
|
||||
void Publish() {
|
||||
// One synchronized sensor reading, including its actual link-data timestamp.
|
||||
const auto reading=sensor_->ImuMessage();
|
||||
sensor_msgs::msg::Imu msg;
|
||||
msg.header.stamp=gazebo_ros::Convert<builtin_interfaces::msg::Time>(gazebo::msgs::Convert(reading.stamp()));
|
||||
msg.header.frame_id="mid360_imu";
|
||||
msg.orientation.w=1.;msg.orientation_covariance[0]=-1.; // MID360 has no attitude solution.
|
||||
msg.angular_velocity.x=reading.angular_velocity().x();
|
||||
msg.angular_velocity.y=reading.angular_velocity().y();
|
||||
msg.angular_velocity.z=reading.angular_velocity().z();
|
||||
msg.linear_acceleration.x=reading.linear_acceleration().x();
|
||||
msg.linear_acceleration.y=reading.linear_acceleration().y();
|
||||
msg.linear_acceleration.z=reading.linear_acceleration().z();
|
||||
// Perturb physical SI observations only, never their acquisition times.
|
||||
double *accel[]={&msg.linear_acceleration.x,&msg.linear_acceleration.y,&msg.linear_acceleration.z};
|
||||
double *gyro[]={&msg.angular_velocity.x,&msg.angular_velocity.y,&msg.angular_velocity.z};
|
||||
for(int i=0;i<3;++i) {
|
||||
*accel[i]+=accel_bias_[i]+accel_stddev_*normal_(rng_);
|
||||
*gyro[i]+=gyro_bias_[i]+gyro_stddev_*normal_(rng_);
|
||||
msg.linear_acceleration_covariance[4*i]=accel_stddev_*accel_stddev_;
|
||||
msg.angular_velocity_covariance[4*i]=gyro_stddev_*gyro_stddev_;
|
||||
}
|
||||
pub_->publish(msg);
|
||||
}
|
||||
double accel_stddev_{0},gyro_stddev_{0};
|
||||
ignition::math::Vector3d accel_bias_,gyro_bias_;
|
||||
std::mt19937 rng_;
|
||||
std::normal_distribution<double> normal_{0.,1.};
|
||||
gazebo::sensors::ImuSensorPtr sensor_;
|
||||
gazebo_ros::Node::SharedPtr node_;
|
||||
rclcpp::Publisher<sensor_msgs::msg::Imu>::SharedPtr pub_;
|
||||
gazebo::event::ConnectionPtr update_;
|
||||
};
|
||||
GZ_REGISTER_SENSOR_PLUGIN(Mid360Imu)
|
||||
} // namespace br_sim
|
||||
@@ -0,0 +1,137 @@
|
||||
// MID360-compatible ideal sensor, not a reconstruction of Livox's optical pattern.
|
||||
// Rays are cast at the current physical state. A physics-step batch shares its
|
||||
// actual acquisition stamp; no fictitious sub-step times or instantaneous scans.
|
||||
#include <cmath>
|
||||
#include <functional>
|
||||
#include <sstream>
|
||||
#include <random>
|
||||
#include <stdexcept>
|
||||
#include <gazebo/gazebo.hh>
|
||||
#include <gazebo/physics/physics.hh>
|
||||
#include <gazebo/physics/RayShape.hh>
|
||||
#include <gazebo_ros/node.hpp>
|
||||
#include <gazebo_ros/conversions/builtin_interfaces.hpp>
|
||||
#include <livox_ros_driver2/msg/custom_msg.hpp>
|
||||
#include <sensor_msgs/msg/point_cloud2.hpp>
|
||||
#include <sensor_msgs/point_cloud2_iterator.hpp>
|
||||
#include <std_msgs/msg/string.hpp>
|
||||
|
||||
namespace br_sim {
|
||||
class Mid360Sensor : public gazebo::ModelPlugin {
|
||||
public:
|
||||
void Load(gazebo::physics::ModelPtr model, sdf::ElementPtr sdf) override {
|
||||
world_=model->GetWorld();link_=model->GetLink("base_link");
|
||||
if (!link_) { gzerr << "Mid360Sensor needs base_link\n";return; }
|
||||
step_ns_=std::llround(world_->Physics()->GetMaxStepSize()*1e9);
|
||||
if(step_ns_!=1000000) {
|
||||
gzerr << "Mid360Sensor requires the validated 1 ms physics step\n";return;
|
||||
}
|
||||
range_stddev_=sdf->Get<double>("range_stddev",0.).first;
|
||||
dropout_=sdf->Get<double>("dropout",0.).first;
|
||||
seed_=sdf->Get<unsigned>("noise_seed",2027u).first;
|
||||
if(!std::isfinite(range_stddev_) || range_stddev_<0 || !std::isfinite(dropout_) || dropout_<0 || dropout_>1)
|
||||
throw std::invalid_argument("Invalid MID360 range noise/dropout");
|
||||
rng_.seed(seed_);
|
||||
node_=gazebo_ros::Node::Get(sdf);
|
||||
ray_=boost::dynamic_pointer_cast<gazebo::physics::RayShape>(
|
||||
world_->Physics()->CreateShape("ray",gazebo::physics::CollisionPtr()));
|
||||
if(!ray_) { gzerr << "Physics engine does not provide RayShape\n";return; }
|
||||
cloud_pub_=node_->create_publisher<livox_ros_driver2::msg::CustomMsg>("/sim/mid360/lidar",10);
|
||||
view_pub_=node_->create_publisher<sensor_msgs::msg::PointCloud2>("/sim/mid360/points",5);
|
||||
status_pub_=node_->create_publisher<std_msgs::msg::String>("/sim/mid360/status",10);
|
||||
update_=gazebo::event::Events::ConnectWorldUpdateEnd(std::bind(&Mid360Sensor::Sample,this));
|
||||
RCLCPP_INFO(node_->get_logger(),
|
||||
"MID360-compatible sensor: 200 rays/1 ms, 100 ms frames, actual acquisition stamps; optional noise/dropout");
|
||||
}
|
||||
|
||||
private:
|
||||
static double Fraction(double x) { return x-std::floor(x); }
|
||||
void Begin(int64_t now) {
|
||||
frame_=livox_ros_driver2::msg::CustomMsg();
|
||||
frame_.header.frame_id="lidar";
|
||||
frame_.header.stamp=gazebo_ros::Convert<builtin_interfaces::msg::Time>(world_->SimTime());
|
||||
frame_.timebase=now;frame_.lidar_id=0;
|
||||
frame_.points.reserve(20000);first_=now;last_sample_=now;rays_=0;hits_=0;dropped_=0;rejected_=0;
|
||||
}
|
||||
void Sample() {
|
||||
const int64_t now=world_->SimTime().sec*int64_t(1000000000)+world_->SimTime().nsec;
|
||||
if(first_<0) Begin(now);
|
||||
if(last_>=0 && now-last_!=step_ns_) {
|
||||
RCLCPP_WARN(node_->get_logger(),"Simulation time discontinuity: discard partial sensor frame");
|
||||
Begin(now);
|
||||
}
|
||||
if(now-first_>=100000000) { Publish();Begin(now); }
|
||||
last_=now;last_sample_=now;
|
||||
const auto body=link_->WorldPose();
|
||||
const auto origin=body.Pos()+body.Rot().RotateVector({0,0,.30});
|
||||
constexpr double pi=3.14159265358979323846;
|
||||
for(unsigned i=0;i<200;++i,++index_,++rays_) {
|
||||
// Documented quasi-uniform, non-repeating approximation; channels are
|
||||
// software groups for the Livox interface, not measured emitter identities.
|
||||
const double az=2*pi*Fraction(index_*.6180339887498948482);
|
||||
const double el=(-7+59*Fraction(.5+index_*.7548776662466927600))*pi/180;
|
||||
const ignition::math::Vector3d direction(std::cos(el)*std::cos(az),
|
||||
std::cos(el)*std::sin(az),std::sin(el));
|
||||
const auto world_dir=body.Rot().RotateVector(direction);
|
||||
ray_->SetPoints(origin,origin+40*world_dir);
|
||||
double distance;std::string entity;
|
||||
ray_->GetIntersection(distance,entity);
|
||||
if(entity.empty() || !std::isfinite(distance) || distance<.1 || distance>40) continue;
|
||||
++hits_;
|
||||
if(dropout_>0 && uniform_(rng_)<dropout_) { ++dropped_;continue; }
|
||||
if(range_stddev_>0) distance+=range_stddev_*normal_(rng_);
|
||||
if(distance<.1 || distance>40) { ++rejected_;continue; }
|
||||
livox_ros_driver2::msg::CustomPoint point;
|
||||
point.x=direction.X()*distance;point.y=direction.Y()*distance;point.z=direction.Z()*distance;
|
||||
point.offset_time=static_cast<uint32_t>(now-first_);
|
||||
point.line=index_%4;point.tag=0x10;
|
||||
point.reflectivity=100; // Ideal constant return strength; no material model.
|
||||
frame_.points.push_back(point);
|
||||
}
|
||||
}
|
||||
void Publish() {
|
||||
frame_.point_num=frame_.points.size();cloud_pub_->publish(frame_);
|
||||
sensor_msgs::msg::PointCloud2 view;
|
||||
view.header=frame_.header;
|
||||
sensor_msgs::PointCloud2Modifier modifier(view);
|
||||
modifier.setPointCloud2Fields(7,"x",1,sensor_msgs::msg::PointField::FLOAT32,
|
||||
"y",1,sensor_msgs::msg::PointField::FLOAT32,"z",1,sensor_msgs::msg::PointField::FLOAT32,
|
||||
"intensity",1,sensor_msgs::msg::PointField::FLOAT32,
|
||||
"offset_time",1,sensor_msgs::msg::PointField::UINT32,
|
||||
"line",1,sensor_msgs::msg::PointField::UINT8,"tag",1,sensor_msgs::msg::PointField::UINT8);
|
||||
modifier.resize(frame_.point_num);
|
||||
sensor_msgs::PointCloud2Iterator<float> x(view,"x"),y(view,"y"),z(view,"z"),intensity(view,"intensity");
|
||||
sensor_msgs::PointCloud2Iterator<uint32_t> t(view,"offset_time");
|
||||
sensor_msgs::PointCloud2Iterator<uint8_t> line(view,"line"),tag(view,"tag");
|
||||
for(const auto &p:frame_.points) {
|
||||
*x=p.x;*y=p.y;*z=p.z;*intensity=p.reflectivity;*t=p.offset_time;*line=p.line;*tag=p.tag;
|
||||
++x;++y;++z;++intensity;++t;++line;++tag;
|
||||
}
|
||||
view.is_dense=true;view_pub_->publish(view);
|
||||
std::ostringstream text;
|
||||
text << "{\"first_sample_ns\":" << first_ << ",\"last_sample_ns\":" << last_sample_
|
||||
<< ",\"rays\":" << rays_ << ",\"returns\":" << frame_.point_num
|
||||
<< ",\"step_ns\":" << step_ns_ << ",\"idealized_pattern\":true"
|
||||
<< ",\"range_stddev_m\":" << range_stddev_ << ",\"dropout_probability\":" << dropout_
|
||||
<< ",\"candidate_hits\":" << hits_ << ",\"dropped\":" << dropped_
|
||||
<< ",\"range_rejected\":" << rejected_ << ",\"seed\":" << seed_ << "}";
|
||||
std_msgs::msg::String status;status.data=text.str();status_pub_->publish(status);
|
||||
}
|
||||
gazebo::physics::WorldPtr world_;
|
||||
gazebo::physics::LinkPtr link_;
|
||||
gazebo::physics::RayShapePtr ray_;
|
||||
gazebo_ros::Node::SharedPtr node_;
|
||||
rclcpp::Publisher<livox_ros_driver2::msg::CustomMsg>::SharedPtr cloud_pub_;
|
||||
rclcpp::Publisher<sensor_msgs::msg::PointCloud2>::SharedPtr view_pub_;
|
||||
rclcpp::Publisher<std_msgs::msg::String>::SharedPtr status_pub_;
|
||||
livox_ros_driver2::msg::CustomMsg frame_;
|
||||
int64_t first_{-1},last_{-1},last_sample_{-1},step_ns_{};
|
||||
uint64_t index_{0};unsigned rays_{0},hits_{0},dropped_{0},rejected_{0},seed_{2027};
|
||||
double range_stddev_{0},dropout_{0};
|
||||
std::mt19937 rng_;
|
||||
std::normal_distribution<double> normal_{0.,1.};
|
||||
std::uniform_real_distribution<double> uniform_{0.,1.};
|
||||
gazebo::event::ConnectionPtr update_;
|
||||
};
|
||||
GZ_REGISTER_MODEL_PLUGIN(Mid360Sensor)
|
||||
} // namespace br_sim
|
||||
@@ -0,0 +1,21 @@
|
||||
cmake_minimum_required(VERSION 3.8)
|
||||
project(robocon_gazebo)
|
||||
|
||||
find_package(ament_cmake REQUIRED)
|
||||
|
||||
# SIM-P1-004-C: 只安装包内资源。
|
||||
# 原 CMakeLists 依赖仓库克隆目录 ../../gazebo_models,并强制校验
|
||||
# ${ROBOCON_MODELS_DIR}/robocon_track.world 存在;本任务要求资源路径
|
||||
# 不依赖 /home/kevin/r2027_gazebo_model,故该依赖与校验全部去掉。
|
||||
#
|
||||
# 包内自带:
|
||||
# launch/ 启动入口
|
||||
# worlds/ robocon_track_full.world(仅移除两个错位的 ROS 系统插件声明)
|
||||
# models/ robocon_ground_full(model.config + model.sdf + meshes/)
|
||||
|
||||
install(DIRECTORY launch worlds models
|
||||
DESTINATION share/${PROJECT_NAME}
|
||||
PATTERN "__pycache__" EXCLUDE
|
||||
PATTERN "*.pyc" EXCLUDE)
|
||||
|
||||
ament_package()
|
||||
@@ -0,0 +1,92 @@
|
||||
# 来源清单(SIM-P1-004-C)
|
||||
|
||||
本包把 `/home/kevin/r2027_gazebo_model/src/robocon_gazebo/` 里的**完整场地**正式纳入
|
||||
本项目。包名保持 `robocon_gazebo`,但**只导入完整场地所需资源**,不复制外部工作区的
|
||||
`build/`、`install/`、缓存、`gazebo_models/` 克隆目录,也不复制 MuJoCo 或机器人包。
|
||||
|
||||
## 1. 导入来源
|
||||
|
||||
| 项 | 路径 |
|
||||
|---|---|
|
||||
| 源工作区 | `/home/kevin/r2027_gazebo_model/` |
|
||||
| 源包 | `/home/kevin/r2027_gazebo_model/src/robocon_gazebo/` |
|
||||
| 导入目标 | `sim_ws/src/robocon_gazebo/` |
|
||||
| 导入时间 | 2026-11-07 |
|
||||
|
||||
**未导入**:`src/r2027_robot_description/`(机器人描述)、`gazebo_models/`(上游克隆目录)、
|
||||
`urdf/`、`scripts/`、`build/`、`install/`、`log/`、`.cache/`、`.Trash-0/`。
|
||||
|
||||
## 2. 导入时四个模型文件字节一致;当前坡道有面朝向修复
|
||||
|
||||
| 文件 | 上游原始 SHA256(导入时与目标一致) |
|
||||
|---|---|
|
||||
| `models/robocon_ground_full/model.sdf` | `f7bb3481dfb626ee87a05347c51c64b2075479383a3cd255af50cc587844cc4a` |
|
||||
| `models/robocon_ground_full/model.config` | `9a6e197fad5a32a48f7055e3bd7cd3147e65c21b08d1530d69264921e5990864` |
|
||||
| `models/robocon_ground_full/meshes/Untitled.dae` | `f69ef7a035924a9eac48e53df4e2fbd9eeb22312712f8e4f2e78f935b9d007bb` |
|
||||
| `models/robocon_ground_full/meshes/ramp.obj` | `5344932eae23391872e371758bbe9a70a6b5b9979fa53d3862b3183bee331f13` |
|
||||
|
||||
2026-11-08 坡道行驶测试发现 `ramp.obj` 的 8 个三角面全部朝内(有向体积 −1.04475 m³)。
|
||||
原圆柱支撑不能从坡脚建立坡面支撑接触;改球形支撑也未解决。仅反转面索引后,同一驱动和
|
||||
原圆柱支撑完成上坡、坡中停车、顶部落脚区、下坡,且实际点云与坡面几何一致。
|
||||
|
||||
**当前修复**:仅反转 `ramp.obj` 所有面顶点顺序;6 个顶点坐标、尺寸、模型位姿和连接关系不变。
|
||||
模型仍闭合,有向体积 +1.04475 m³。修复后 SHA256:
|
||||
`c53e36c47838b79d93de6d6119e5089ace361808af9a6fff48b9952885894dcd`。
|
||||
其余三个模型文件继续与上游逐字节一致,外部源文件未改动。
|
||||
|
||||
修复可用 `sim_ws/tools/repair_ramp_winding.py` 重现,该脚本只接受上述固定上游哈希,
|
||||
资源检查独立验证“顶点不变、全部面恰好反向、修复前后闭合、修复后体积为正”。
|
||||
证据:`sim_ws/log/codex_p5_slope_20261108/winding_diagnostic/`、`ramp_flipped/`、
|
||||
`winding_repair.json`;本改动不沿用旧“所有文件仍与源一致”的结论。
|
||||
|
||||
## 3. world:只删了两个错位的插件声明
|
||||
|
||||
| 项 | SHA256 |
|
||||
|---|---|
|
||||
| 源 `worlds/robocon_track_full.world` | `d611b2974b90d42d62537b277be6330786458e42c694119d9b0342e09b55e3af` |
|
||||
| 包内 `worlds/robocon_track_full.world` | `e26310e8e0e7e9e97c352b197129cbeb4c88f45a14f4e388e68ba8adaa080055` |
|
||||
|
||||
删除的两行(位于 `</world>` 前):
|
||||
|
||||
```xml
|
||||
<plugin name="gazebo_ros_init" filename="libgazebo_ros_init.so"/>
|
||||
<plugin name="gazebo_ros_factory" filename="libgazebo_ros_factory.so"/>
|
||||
```
|
||||
|
||||
原因:本机头文件确认 `libgazebo_ros_init.so` 与 `libgazebo_ros_factory.so` 都是
|
||||
`gazebo::SystemPlugin`,**不是 world plugin**,写在世界里加载方式不对。
|
||||
改由官方 `gazebo_ros/gzserver.launch.py` 的 `init:=true` / `factory:=true`
|
||||
通过 `-s` 命令行各加载一次。
|
||||
|
||||
删除位置只替换为一段说明注释。**物理、光照、场景、`<include>` 模型与位姿全部保持原样**,
|
||||
`world name="robocon_world"` 不变。
|
||||
|
||||
## 4. 未导入的上游 world
|
||||
|
||||
`worlds/robocon_track_ros.world` 未导入:它是同一场地的早期版本(碰撞不完整),
|
||||
本任务只以 `robocon_track_full.world` 为几何基准。
|
||||
|
||||
## 5. 新地图为几何基准
|
||||
|
||||
按任务要求,**不再按旧 Blender 场地修正尺寸**。此前 `br_gazebo`(Fortress 路线)
|
||||
的场地几何不作为 Classic 验收依据。2026-11-08 按用户清理要求删除了旧包及专用导出工具,
|
||||
过期调查说明已移出源码树,`sim_ws/docs/archive/fortress/` 仅保留退役说明;
|
||||
旧文档备份、测量和接触日志在本机忽略的 log/ 中保留,原始外部资源未改动。
|
||||
|
||||
## 6. 碰撞体清点(静态核对 model.sdf)
|
||||
|
||||
| 项 | 数量 |
|
||||
|---|---|
|
||||
| link | 1(`link`,模型 `static=true`) |
|
||||
| collision 合计 | **50** |
|
||||
| ├ box | **46** |
|
||||
| ├ cylinder | **2**(`Cylinder`、`Cylinder.001`) |
|
||||
| └ mesh | **2**(`ramp_north`、`ramp_south`,同一 `ramp.obj`) |
|
||||
| visual | 1(`Untitled.dae`,整场共用一张视觉网格) |
|
||||
|
||||
与任务给出的「实际 50 个碰撞体:46 box、2 cylinder、2 mesh」一致。
|
||||
|
||||
`ramp.obj` 是 6 顶点楔形(局部 x∈[−0.8, 2.7]、y∈[0,1]、z∈[0,0.597]),
|
||||
坡面在 x=−0.8 处高 0.597 m,向 +X 降到 0,即**坡道下降方向为 +X**。
|
||||
`ramp_north` pose=(0, 3, 0) → 世界 y∈[3,4](红方 +Y 侧);
|
||||
`ramp_south` pose=(0, −4, 0) → 世界 y∈[−4,−3](蓝方)。
|
||||
@@ -0,0 +1,94 @@
|
||||
"""启动 ROBOCON 2027 完整场地(Gazebo Classic 11 + ROS 2 Humble)。
|
||||
|
||||
入口统一为:
|
||||
ros2 launch robocon_gazebo robocon_gazebo.launch.py
|
||||
ros2 launch robocon_gazebo robocon_gazebo.launch.py gui:=false paused:=true verbose:=true
|
||||
|
||||
参数:
|
||||
gui 是否启动一个 gzclient(默认 true)
|
||||
paused 是否以暂停状态启动 gzserver(默认 false)
|
||||
verbose gzserver 是否输出详细日志(默认 false)
|
||||
world 可覆盖 world 路径(默认包内 worlds/robocon_track_full.world)
|
||||
|
||||
设计要点(SIM-P1-004-C):
|
||||
1. 只通过**官方 gazebo_ros 的 gzserver.launch.py** 加载 libgazebo_ros_init.so 与
|
||||
libgazebo_ros_factory.so,各一次(对应其 init:= / factory:= 参数,最终落到
|
||||
gzserver 的 `-s` 命令行选项)。这两个插件在本机头文件中属于 SystemPlugin,
|
||||
不能写在 world 的 <plugin> 里,源 world 的那两行已在包内 world 中移除。
|
||||
2. force_system:=false,避免额外加载第三个插件,保证「init、factory 各一次」。
|
||||
3. 不启动 ros_gz_bridge,不加载 Fortress(ignition)任何组件。
|
||||
4. GAZEBO_MASTER_URI 固定到 127.0.0.1:11355(与默认 11345 隔离),
|
||||
server / client / 采集工具共用同一 master;ROS_DOMAIN_ID=77、ROS_LOCALHOST_ONLY=1。
|
||||
5. 不接入机器人、TF、里程计、点云或 /cmd_vel。
|
||||
"""
|
||||
|
||||
import os
|
||||
|
||||
from ament_index_python.packages import get_package_share_directory
|
||||
from launch import LaunchDescription
|
||||
from launch.actions import (
|
||||
DeclareLaunchArgument,
|
||||
IncludeLaunchDescription,
|
||||
SetEnvironmentVariable,
|
||||
)
|
||||
from launch.conditions import IfCondition
|
||||
from launch.launch_description_sources import PythonLaunchDescriptionSource
|
||||
from launch.substitutions import LaunchConfiguration
|
||||
|
||||
# 与采集工具、手动 gzclient 保持一致(改这里就要同步改 tools/check_classic_baseline.py)
|
||||
GAZEBO_MASTER_URI = 'http://127.0.0.1:11355'
|
||||
ROS_DOMAIN_ID = '77'
|
||||
|
||||
|
||||
def generate_launch_description():
|
||||
share = get_package_share_directory('robocon_gazebo')
|
||||
models_dir = os.path.join(share, 'models')
|
||||
default_world = os.path.join(share, 'worlds', 'robocon_track_full.world')
|
||||
gazebo_ros_share = get_package_share_directory('gazebo_ros')
|
||||
|
||||
# 模型查找路径:本包安装的模型在前,其余沿用环境与 ~/.gazebo/models
|
||||
model_path_parts = [models_dir, os.path.expanduser('~/.gazebo/models')]
|
||||
if os.environ.get('GAZEBO_MODEL_PATH'):
|
||||
model_path_parts.append(os.environ['GAZEBO_MODEL_PATH'])
|
||||
model_path = os.pathsep.join(model_path_parts)
|
||||
|
||||
declared_args = [
|
||||
DeclareLaunchArgument('gui', default_value='true',
|
||||
description='是否启动 gzclient'),
|
||||
DeclareLaunchArgument('paused', default_value='false',
|
||||
description='以暂停状态启动'),
|
||||
DeclareLaunchArgument('verbose', default_value='false',
|
||||
description='gzserver 详细日志'),
|
||||
DeclareLaunchArgument('world', default_value=default_world,
|
||||
description='world 文件(默认完整场地)'),
|
||||
]
|
||||
|
||||
# 环境隔离:master 端口、ROS 域、仅本机通信、模型路径
|
||||
env_actions = [
|
||||
SetEnvironmentVariable('GAZEBO_MASTER_URI', GAZEBO_MASTER_URI),
|
||||
SetEnvironmentVariable('ROS_DOMAIN_ID', ROS_DOMAIN_ID),
|
||||
SetEnvironmentVariable('ROS_LOCALHOST_ONLY', '1'),
|
||||
SetEnvironmentVariable('GAZEBO_MODEL_PATH', model_path),
|
||||
]
|
||||
|
||||
gzserver = IncludeLaunchDescription(
|
||||
PythonLaunchDescriptionSource(
|
||||
os.path.join(gazebo_ros_share, 'launch', 'gzserver.launch.py')),
|
||||
launch_arguments={
|
||||
'world': LaunchConfiguration('world'),
|
||||
'verbose': LaunchConfiguration('verbose'),
|
||||
'pause': LaunchConfiguration('paused'),
|
||||
'init': 'true', # -s libgazebo_ros_init.so
|
||||
'factory': 'true', # -s libgazebo_ros_factory.so
|
||||
'force_system': 'false', # 不再多加载一个系统插件
|
||||
'server_required': 'true', # 关掉 launch 时一起收掉 gzserver
|
||||
}.items(),
|
||||
)
|
||||
|
||||
gzclient = IncludeLaunchDescription(
|
||||
PythonLaunchDescriptionSource(
|
||||
os.path.join(gazebo_ros_share, 'launch', 'gzclient.launch.py')),
|
||||
condition=IfCondition(LaunchConfiguration('gui')),
|
||||
)
|
||||
|
||||
return LaunchDescription(env_actions + declared_args + [gzserver, gzclient])
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,18 @@
|
||||
# 楔形坡道碰撞网格 (视觉 Cube.001/Cube.006 的归一化形状)
|
||||
# 坡面: x=-0.8 处高 0.597m, 向 +x 降到 x=2.7 处 0m; 宽度沿 y 1m
|
||||
# 北坡道 pose=(0,3,0), 南坡道 pose=(0,-4,0)
|
||||
o ramp
|
||||
v -0.8 0 0.597
|
||||
v -0.8 1 0.597
|
||||
v -0.8 0 0
|
||||
v -0.8 1 0
|
||||
v 2.7 0 0
|
||||
v 2.7 1 0
|
||||
f 4 3 1
|
||||
f 2 4 1
|
||||
f 6 5 3
|
||||
f 4 6 3
|
||||
f 6 2 1
|
||||
f 5 6 1
|
||||
f 3 5 1
|
||||
f 6 4 2
|
||||
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0"?>
|
||||
<model>
|
||||
<name>robocon_ground_full</name>
|
||||
<version>1.1</version>
|
||||
<sdf version="1.6">model.sdf</sdf>
|
||||
<author>
|
||||
<name>xie (collision rebuilt from visual DAE)</name>
|
||||
</author>
|
||||
<description>ROBOCON ground with complete collision: solid L1/L2, ramps, stairs, rails, pillar bases. Visual mesh shared with robocon_ground.</description>
|
||||
</model>
|
||||
@@ -0,0 +1,462 @@
|
||||
<?xml version="1.0"?>
|
||||
<!-- 由 scripts/gen_full_collision.py 从视觉 DAE 自动生成, 请勿手改 -->
|
||||
<sdf version="1.6">
|
||||
<model name="robocon_ground_full">
|
||||
<static>true</static>
|
||||
<link name="link">
|
||||
<visual name="visual">
|
||||
<geometry><mesh><uri>model://robocon_ground_full/meshes/Untitled.dae</uri></mesh></geometry>
|
||||
</visual>
|
||||
<!-- ground (z=0 顶面) -->
|
||||
<collision name="ground">
|
||||
<geometry><box><size>11 11 0.02</size></box></geometry>
|
||||
<pose>0 0 -0.01 0 0 0</pose>
|
||||
<surface>
|
||||
<friction><ode><mu>0.8</mu><mu2>0.8</mu2></ode></friction>
|
||||
<contact><ode><max_vel>0.1</max_vel><min_depth>0.001</min_depth></ode></contact>
|
||||
</surface>
|
||||
</collision>
|
||||
<!-- center_divider -->
|
||||
<collision name="center_divider">
|
||||
<geometry><box><size>11 0.08 0.08</size></box></geometry>
|
||||
<pose>0 0 0.04 0 0 0</pose>
|
||||
<surface>
|
||||
<friction><ode><mu>0.8</mu><mu2>0.8</mu2></ode></friction>
|
||||
<contact><ode><max_vel>0.1</max_vel><min_depth>0.001</min_depth></ode></contact>
|
||||
</surface>
|
||||
</collision>
|
||||
<!-- Boundary_Wall_Back -->
|
||||
<collision name="Boundary_Wall_Back">
|
||||
<geometry><box><size>0.1 11 0.08</size></box></geometry>
|
||||
<pose>5.55 0 0 0 0 0</pose>
|
||||
<surface>
|
||||
<friction><ode><mu>0.8</mu><mu2>0.8</mu2></ode></friction>
|
||||
<contact><ode><max_vel>0.1</max_vel><min_depth>0.001</min_depth></ode></contact>
|
||||
</surface>
|
||||
</collision>
|
||||
<!-- Boundary_Wall_Front -->
|
||||
<collision name="Boundary_Wall_Front">
|
||||
<geometry><box><size>0.1 11 0.08</size></box></geometry>
|
||||
<pose>-5.55 0 0 0 0 0</pose>
|
||||
<surface>
|
||||
<friction><ode><mu>0.8</mu><mu2>0.8</mu2></ode></friction>
|
||||
<contact><ode><max_vel>0.1</max_vel><min_depth>0.001</min_depth></ode></contact>
|
||||
</surface>
|
||||
</collision>
|
||||
<!-- Boundary_Wall_Left -->
|
||||
<collision name="Boundary_Wall_Left">
|
||||
<geometry><box><size>11 0.1 0.08</size></box></geometry>
|
||||
<pose>0 5.55 0 0 0 0</pose>
|
||||
<surface>
|
||||
<friction><ode><mu>0.8</mu><mu2>0.8</mu2></ode></friction>
|
||||
<contact><ode><max_vel>0.1</max_vel><min_depth>0.001</min_depth></ode></contact>
|
||||
</surface>
|
||||
</collision>
|
||||
<!-- Boundary_Wall_Right -->
|
||||
<collision name="Boundary_Wall_Right">
|
||||
<geometry><box><size>11 0.1 0.08</size></box></geometry>
|
||||
<pose>0 -5.55 0 0 0 0</pose>
|
||||
<surface>
|
||||
<friction><ode><mu>0.8</mu><mu2>0.8</mu2></ode></friction>
|
||||
<contact><ode><max_vel>0.1</max_vel><min_depth>0.001</min_depth></ode></contact>
|
||||
</surface>
|
||||
</collision>
|
||||
<!-- Cube -->
|
||||
<collision name="Cube">
|
||||
<geometry><box><size>6 6 0.6</size></box></geometry>
|
||||
<pose>0 0 0.3 0 0 0</pose>
|
||||
<surface>
|
||||
<friction><ode><mu>0.8</mu><mu2>0.8</mu2></ode></friction>
|
||||
<contact><ode><max_vel>0.1</max_vel><min_depth>0.001</min_depth></ode></contact>
|
||||
</surface>
|
||||
</collision>
|
||||
<!-- Cube.001 -->
|
||||
<collision name="ramp_north">
|
||||
<geometry><mesh><uri>meshes/ramp.obj</uri></mesh></geometry>
|
||||
<pose>0 3 0 0 0 0</pose>
|
||||
<surface>
|
||||
<friction><ode><mu>0.9</mu><mu2>0.9</mu2></ode></friction>
|
||||
<contact><ode><max_vel>0.1</max_vel><min_depth>0.001</min_depth></ode></contact>
|
||||
</surface>
|
||||
</collision>
|
||||
<!-- Cube.002 -->
|
||||
<collision name="Cube.002">
|
||||
<geometry><box><size>1.9 1 0.15</size></box></geometry>
|
||||
<pose>-1.75 3.5 0.075 0 0 0</pose>
|
||||
<surface>
|
||||
<friction><ode><mu>0.8</mu><mu2>0.8</mu2></ode></friction>
|
||||
<contact><ode><max_vel>0.1</max_vel><min_depth>0.001</min_depth></ode></contact>
|
||||
</surface>
|
||||
</collision>
|
||||
<!-- Cube.003 -->
|
||||
<collision name="Cube.003">
|
||||
<geometry><box><size>1.6 1 0.15</size></box></geometry>
|
||||
<pose>-1.6 3.5 0.225 0 0 0</pose>
|
||||
<surface>
|
||||
<friction><ode><mu>0.8</mu><mu2>0.8</mu2></ode></friction>
|
||||
<contact><ode><max_vel>0.1</max_vel><min_depth>0.001</min_depth></ode></contact>
|
||||
</surface>
|
||||
</collision>
|
||||
<!-- Cube.004 -->
|
||||
<collision name="Cube.004">
|
||||
<geometry><box><size>1.3 1 0.15</size></box></geometry>
|
||||
<pose>-1.45 3.5 0.375 0 0 0</pose>
|
||||
<surface>
|
||||
<friction><ode><mu>0.8</mu><mu2>0.8</mu2></ode></friction>
|
||||
<contact><ode><max_vel>0.1</max_vel><min_depth>0.001</min_depth></ode></contact>
|
||||
</surface>
|
||||
</collision>
|
||||
<!-- Cube.005 -->
|
||||
<collision name="Cube.005">
|
||||
<geometry><box><size>1 1 0.15</size></box></geometry>
|
||||
<pose>-1.3 3.5 0.525 0 0 0</pose>
|
||||
<surface>
|
||||
<friction><ode><mu>0.8</mu><mu2>0.8</mu2></ode></friction>
|
||||
<contact><ode><max_vel>0.1</max_vel><min_depth>0.001</min_depth></ode></contact>
|
||||
</surface>
|
||||
</collision>
|
||||
<!-- Cube.006 -->
|
||||
<collision name="ramp_south">
|
||||
<geometry><mesh><uri>meshes/ramp.obj</uri></mesh></geometry>
|
||||
<pose>0 -4 0 0 0 0</pose>
|
||||
<surface>
|
||||
<friction><ode><mu>0.9</mu><mu2>0.9</mu2></ode></friction>
|
||||
<contact><ode><max_vel>0.1</max_vel><min_depth>0.001</min_depth></ode></contact>
|
||||
</surface>
|
||||
</collision>
|
||||
<!-- Cube.007 -->
|
||||
<collision name="Cube.007">
|
||||
<geometry><box><size>1.9 1 0.15</size></box></geometry>
|
||||
<pose>-1.75 -3.5 0.075 0 0 0</pose>
|
||||
<surface>
|
||||
<friction><ode><mu>0.8</mu><mu2>0.8</mu2></ode></friction>
|
||||
<contact><ode><max_vel>0.1</max_vel><min_depth>0.001</min_depth></ode></contact>
|
||||
</surface>
|
||||
</collision>
|
||||
<!-- Cube.008 -->
|
||||
<collision name="Cube.008">
|
||||
<geometry><box><size>1.6 1 0.15</size></box></geometry>
|
||||
<pose>-1.6 -3.5 0.225 0 0 0</pose>
|
||||
<surface>
|
||||
<friction><ode><mu>0.8</mu><mu2>0.8</mu2></ode></friction>
|
||||
<contact><ode><max_vel>0.1</max_vel><min_depth>0.001</min_depth></ode></contact>
|
||||
</surface>
|
||||
</collision>
|
||||
<!-- Cube.009 -->
|
||||
<collision name="Cube.009">
|
||||
<geometry><box><size>1.3 1 0.15</size></box></geometry>
|
||||
<pose>-1.45 -3.5 0.375 0 0 0</pose>
|
||||
<surface>
|
||||
<friction><ode><mu>0.8</mu><mu2>0.8</mu2></ode></friction>
|
||||
<contact><ode><max_vel>0.1</max_vel><min_depth>0.001</min_depth></ode></contact>
|
||||
</surface>
|
||||
</collision>
|
||||
<!-- Cube.010 -->
|
||||
<collision name="Cube.010">
|
||||
<geometry><box><size>1 1 0.15</size></box></geometry>
|
||||
<pose>-1.3 -3.5 0.525 0 0 0</pose>
|
||||
<surface>
|
||||
<friction><ode><mu>0.8</mu><mu2>0.8</mu2></ode></friction>
|
||||
<contact><ode><max_vel>0.1</max_vel><min_depth>0.001</min_depth></ode></contact>
|
||||
</surface>
|
||||
</collision>
|
||||
<!-- Cube.011 -->
|
||||
<collision name="Cube.011">
|
||||
<geometry><box><size>0.05 6 0.05</size></box></geometry>
|
||||
<pose>-3 0 0.625 0 0 0</pose>
|
||||
<surface>
|
||||
<friction><ode><mu>0.8</mu><mu2>0.8</mu2></ode></friction>
|
||||
<contact><ode><max_vel>0.1</max_vel><min_depth>0.001</min_depth></ode></contact>
|
||||
</surface>
|
||||
</collision>
|
||||
<!-- Cube.012 -->
|
||||
<collision name="Cube.012">
|
||||
<geometry><box><size>0.05 6 0.05</size></box></geometry>
|
||||
<pose>3 0 0.625 0 0 0</pose>
|
||||
<surface>
|
||||
<friction><ode><mu>0.8</mu><mu2>0.8</mu2></ode></friction>
|
||||
<contact><ode><max_vel>0.1</max_vel><min_depth>0.001</min_depth></ode></contact>
|
||||
</surface>
|
||||
</collision>
|
||||
<!-- Cube.013 -->
|
||||
<collision name="Cube.013">
|
||||
<geometry><box><size>3.8 0.05 0.05</size></box></geometry>
|
||||
<pose>1.1 3 0.625 0 0 0</pose>
|
||||
<surface>
|
||||
<friction><ode><mu>0.8</mu><mu2>0.8</mu2></ode></friction>
|
||||
<contact><ode><max_vel>0.1</max_vel><min_depth>0.001</min_depth></ode></contact>
|
||||
</surface>
|
||||
</collision>
|
||||
<!-- Cube.014 -->
|
||||
<collision name="Cube.014">
|
||||
<geometry><box><size>1.2 0.05 0.05</size></box></geometry>
|
||||
<pose>-2.4 3 0.625 0 0 0</pose>
|
||||
<surface>
|
||||
<friction><ode><mu>0.8</mu><mu2>0.8</mu2></ode></friction>
|
||||
<contact><ode><max_vel>0.1</max_vel><min_depth>0.001</min_depth></ode></contact>
|
||||
</surface>
|
||||
</collision>
|
||||
<!-- Cube.015 -->
|
||||
<collision name="Cube.015">
|
||||
<geometry><box><size>3.8 0.05 0.05</size></box></geometry>
|
||||
<pose>1.1 -3 0.625 0 0 0</pose>
|
||||
<surface>
|
||||
<friction><ode><mu>0.8</mu><mu2>0.8</mu2></ode></friction>
|
||||
<contact><ode><max_vel>0.1</max_vel><min_depth>0.001</min_depth></ode></contact>
|
||||
</surface>
|
||||
</collision>
|
||||
<!-- Cube.016 -->
|
||||
<collision name="Cube.016">
|
||||
<geometry><box><size>1.2 0.05 0.05</size></box></geometry>
|
||||
<pose>-2.4 -3 0.625 0 0 0</pose>
|
||||
<surface>
|
||||
<friction><ode><mu>0.8</mu><mu2>0.8</mu2></ode></friction>
|
||||
<contact><ode><max_vel>0.1</max_vel><min_depth>0.001</min_depth></ode></contact>
|
||||
</surface>
|
||||
</collision>
|
||||
<!-- Cube.017 -->
|
||||
<collision name="Cube.017">
|
||||
<geometry><box><size>3 3 0.3</size></box></geometry>
|
||||
<pose>0 0 0.75 0 0 0</pose>
|
||||
<surface>
|
||||
<friction><ode><mu>0.8</mu><mu2>0.8</mu2></ode></friction>
|
||||
<contact><ode><max_vel>0.1</max_vel><min_depth>0.001</min_depth></ode></contact>
|
||||
</surface>
|
||||
</collision>
|
||||
<!-- Cube.020 -->
|
||||
<collision name="Cube.020">
|
||||
<geometry><box><size>0.2 0.1 0.2</size></box></geometry>
|
||||
<pose>-3.8 -0.5 0.13 0 0 0</pose>
|
||||
<surface>
|
||||
<friction><ode><mu>0.8</mu><mu2>0.8</mu2></ode></friction>
|
||||
<contact><ode><max_vel>0.1</max_vel><min_depth>0.001</min_depth></ode></contact>
|
||||
</surface>
|
||||
</collision>
|
||||
<!-- Cube.021 -->
|
||||
<collision name="Cube.021">
|
||||
<geometry><box><size>0.2 0.1 0.2</size></box></geometry>
|
||||
<pose>-3.8 -0.4 0.13 0 0 0</pose>
|
||||
<surface>
|
||||
<friction><ode><mu>0.8</mu><mu2>0.8</mu2></ode></friction>
|
||||
<contact><ode><max_vel>0.1</max_vel><min_depth>0.001</min_depth></ode></contact>
|
||||
</surface>
|
||||
</collision>
|
||||
<!-- Cube.022 -->
|
||||
<collision name="Cube.022">
|
||||
<geometry><box><size>0.2 0.1 0.2</size></box></geometry>
|
||||
<pose>-3.8 0.05 0.13 0 0 0</pose>
|
||||
<surface>
|
||||
<friction><ode><mu>0.8</mu><mu2>0.8</mu2></ode></friction>
|
||||
<contact><ode><max_vel>0.1</max_vel><min_depth>0.001</min_depth></ode></contact>
|
||||
</surface>
|
||||
</collision>
|
||||
<!-- Cube.023 -->
|
||||
<collision name="Cube.023">
|
||||
<geometry><box><size>0.2 0.1 0.2</size></box></geometry>
|
||||
<pose>-3.8 -0.05 0.13 0 0 0</pose>
|
||||
<surface>
|
||||
<friction><ode><mu>0.8</mu><mu2>0.8</mu2></ode></friction>
|
||||
<contact><ode><max_vel>0.1</max_vel><min_depth>0.001</min_depth></ode></contact>
|
||||
</surface>
|
||||
</collision>
|
||||
<!-- Cube.024 -->
|
||||
<collision name="Cube.024">
|
||||
<geometry><box><size>0.2 0.1 0.2</size></box></geometry>
|
||||
<pose>-3.8 0.5 0.13 0 0 0</pose>
|
||||
<surface>
|
||||
<friction><ode><mu>0.8</mu><mu2>0.8</mu2></ode></friction>
|
||||
<contact><ode><max_vel>0.1</max_vel><min_depth>0.001</min_depth></ode></contact>
|
||||
</surface>
|
||||
</collision>
|
||||
<!-- Cube.025 -->
|
||||
<collision name="Cube.025">
|
||||
<geometry><box><size>0.2 0.1 0.2</size></box></geometry>
|
||||
<pose>-3.8 0.4 0.13 0 0 0</pose>
|
||||
<surface>
|
||||
<friction><ode><mu>0.8</mu><mu2>0.8</mu2></ode></friction>
|
||||
<contact><ode><max_vel>0.1</max_vel><min_depth>0.001</min_depth></ode></contact>
|
||||
</surface>
|
||||
</collision>
|
||||
<!-- Cube.026 -->
|
||||
<collision name="Cube.026">
|
||||
<geometry><box><size>0.2 0.1 0.2</size></box></geometry>
|
||||
<pose>-4 0.275 0.13 0 0 0</pose>
|
||||
<surface>
|
||||
<friction><ode><mu>0.8</mu><mu2>0.8</mu2></ode></friction>
|
||||
<contact><ode><max_vel>0.1</max_vel><min_depth>0.001</min_depth></ode></contact>
|
||||
</surface>
|
||||
</collision>
|
||||
<!-- Cube.027 -->
|
||||
<collision name="Cube.027">
|
||||
<geometry><box><size>0.2 0.1 0.2</size></box></geometry>
|
||||
<pose>-4 0.175 0.13 0 0 0</pose>
|
||||
<surface>
|
||||
<friction><ode><mu>0.8</mu><mu2>0.8</mu2></ode></friction>
|
||||
<contact><ode><max_vel>0.1</max_vel><min_depth>0.001</min_depth></ode></contact>
|
||||
</surface>
|
||||
</collision>
|
||||
<!-- Cube.028 -->
|
||||
<collision name="Cube.028">
|
||||
<geometry><box><size>0.2 0.1 0.2</size></box></geometry>
|
||||
<pose>-4 -0.175 0.13 0 0 0</pose>
|
||||
<surface>
|
||||
<friction><ode><mu>0.8</mu><mu2>0.8</mu2></ode></friction>
|
||||
<contact><ode><max_vel>0.1</max_vel><min_depth>0.001</min_depth></ode></contact>
|
||||
</surface>
|
||||
</collision>
|
||||
<!-- Cube.029 -->
|
||||
<collision name="Cube.029">
|
||||
<geometry><box><size>0.2 0.1 0.2</size></box></geometry>
|
||||
<pose>-4 -0.275 0.13 0 0 0</pose>
|
||||
<surface>
|
||||
<friction><ode><mu>0.8</mu><mu2>0.8</mu2></ode></friction>
|
||||
<contact><ode><max_vel>0.1</max_vel><min_depth>0.001</min_depth></ode></contact>
|
||||
</surface>
|
||||
</collision>
|
||||
<!-- Cube.030 -->
|
||||
<collision name="Cube.030">
|
||||
<geometry><box><size>0.2 0.1 0.2</size></box></geometry>
|
||||
<pose>-4.2 0.5 0.13 0 0 0</pose>
|
||||
<surface>
|
||||
<friction><ode><mu>0.8</mu><mu2>0.8</mu2></ode></friction>
|
||||
<contact><ode><max_vel>0.1</max_vel><min_depth>0.001</min_depth></ode></contact>
|
||||
</surface>
|
||||
</collision>
|
||||
<!-- Cube.031 -->
|
||||
<collision name="Cube.031">
|
||||
<geometry><box><size>0.2 0.1 0.2</size></box></geometry>
|
||||
<pose>-4.2 0.4 0.13 0 0 0</pose>
|
||||
<surface>
|
||||
<friction><ode><mu>0.8</mu><mu2>0.8</mu2></ode></friction>
|
||||
<contact><ode><max_vel>0.1</max_vel><min_depth>0.001</min_depth></ode></contact>
|
||||
</surface>
|
||||
</collision>
|
||||
<!-- Cube.032 -->
|
||||
<collision name="Cube.032">
|
||||
<geometry><box><size>0.2 0.1 0.2</size></box></geometry>
|
||||
<pose>-4.2 -0.4 0.13 0 0 0</pose>
|
||||
<surface>
|
||||
<friction><ode><mu>0.8</mu><mu2>0.8</mu2></ode></friction>
|
||||
<contact><ode><max_vel>0.1</max_vel><min_depth>0.001</min_depth></ode></contact>
|
||||
</surface>
|
||||
</collision>
|
||||
<!-- Cube.033 -->
|
||||
<collision name="Cube.033">
|
||||
<geometry><box><size>0.2 0.1 0.2</size></box></geometry>
|
||||
<pose>-4.2 -0.5 0.13 0 0 0</pose>
|
||||
<surface>
|
||||
<friction><ode><mu>0.8</mu><mu2>0.8</mu2></ode></friction>
|
||||
<contact><ode><max_vel>0.1</max_vel><min_depth>0.001</min_depth></ode></contact>
|
||||
</surface>
|
||||
</collision>
|
||||
<!-- Cube.034 -->
|
||||
<collision name="Cube.034">
|
||||
<geometry><box><size>0.2 0.1 0.2</size></box></geometry>
|
||||
<pose>-4.4 0.275 0.13 0 0 0</pose>
|
||||
<surface>
|
||||
<friction><ode><mu>0.8</mu><mu2>0.8</mu2></ode></friction>
|
||||
<contact><ode><max_vel>0.1</max_vel><min_depth>0.001</min_depth></ode></contact>
|
||||
</surface>
|
||||
</collision>
|
||||
<!-- Cube.035 -->
|
||||
<collision name="Cube.035">
|
||||
<geometry><box><size>0.2 0.1 0.2</size></box></geometry>
|
||||
<pose>-4.4 0.175 0.13 0 0 0</pose>
|
||||
<surface>
|
||||
<friction><ode><mu>0.8</mu><mu2>0.8</mu2></ode></friction>
|
||||
<contact><ode><max_vel>0.1</max_vel><min_depth>0.001</min_depth></ode></contact>
|
||||
</surface>
|
||||
</collision>
|
||||
<!-- Cube.036 -->
|
||||
<collision name="Cube.036">
|
||||
<geometry><box><size>0.2 0.1 0.2</size></box></geometry>
|
||||
<pose>-4.4 -0.175 0.13 0 0 0</pose>
|
||||
<surface>
|
||||
<friction><ode><mu>0.8</mu><mu2>0.8</mu2></ode></friction>
|
||||
<contact><ode><max_vel>0.1</max_vel><min_depth>0.001</min_depth></ode></contact>
|
||||
</surface>
|
||||
</collision>
|
||||
<!-- Cube.037 -->
|
||||
<collision name="Cube.037">
|
||||
<geometry><box><size>0.2 0.1 0.2</size></box></geometry>
|
||||
<pose>-4.4 -0.275 0.13 0 0 0</pose>
|
||||
<surface>
|
||||
<friction><ode><mu>0.8</mu><mu2>0.8</mu2></ode></friction>
|
||||
<contact><ode><max_vel>0.1</max_vel><min_depth>0.001</min_depth></ode></contact>
|
||||
</surface>
|
||||
</collision>
|
||||
<!-- Cube.038 -->
|
||||
<collision name="Cube.038">
|
||||
<geometry><box><size>0.2 0.1 0.2</size></box></geometry>
|
||||
<pose>-4.6 0.5 0.13 0 0 0</pose>
|
||||
<surface>
|
||||
<friction><ode><mu>0.8</mu><mu2>0.8</mu2></ode></friction>
|
||||
<contact><ode><max_vel>0.1</max_vel><min_depth>0.001</min_depth></ode></contact>
|
||||
</surface>
|
||||
</collision>
|
||||
<!-- Cube.039 -->
|
||||
<collision name="Cube.039">
|
||||
<geometry><box><size>0.2 0.1 0.2</size></box></geometry>
|
||||
<pose>-4.6 0.4 0.13 0 0 0</pose>
|
||||
<surface>
|
||||
<friction><ode><mu>0.8</mu><mu2>0.8</mu2></ode></friction>
|
||||
<contact><ode><max_vel>0.1</max_vel><min_depth>0.001</min_depth></ode></contact>
|
||||
</surface>
|
||||
</collision>
|
||||
<!-- Cube.040 -->
|
||||
<collision name="Cube.040">
|
||||
<geometry><box><size>0.2 0.1 0.2</size></box></geometry>
|
||||
<pose>-4.6 0.05 0.13 0 0 0</pose>
|
||||
<surface>
|
||||
<friction><ode><mu>0.8</mu><mu2>0.8</mu2></ode></friction>
|
||||
<contact><ode><max_vel>0.1</max_vel><min_depth>0.001</min_depth></ode></contact>
|
||||
</surface>
|
||||
</collision>
|
||||
<!-- Cube.041 -->
|
||||
<collision name="Cube.041">
|
||||
<geometry><box><size>0.2 0.1 0.2</size></box></geometry>
|
||||
<pose>-4.6 -0.05 0.13 0 0 0</pose>
|
||||
<surface>
|
||||
<friction><ode><mu>0.8</mu><mu2>0.8</mu2></ode></friction>
|
||||
<contact><ode><max_vel>0.1</max_vel><min_depth>0.001</min_depth></ode></contact>
|
||||
</surface>
|
||||
</collision>
|
||||
<!-- Cube.042 -->
|
||||
<collision name="Cube.042">
|
||||
<geometry><box><size>0.2 0.1 0.2</size></box></geometry>
|
||||
<pose>-4.6 -0.4 0.13 0 0 0</pose>
|
||||
<surface>
|
||||
<friction><ode><mu>0.8</mu><mu2>0.8</mu2></ode></friction>
|
||||
<contact><ode><max_vel>0.1</max_vel><min_depth>0.001</min_depth></ode></contact>
|
||||
</surface>
|
||||
</collision>
|
||||
<!-- Cube.043 -->
|
||||
<collision name="Cube.043">
|
||||
<geometry><box><size>0.2 0.1 0.2</size></box></geometry>
|
||||
<pose>-4.6 -0.5 0.13 0 0 0</pose>
|
||||
<surface>
|
||||
<friction><ode><mu>0.8</mu><mu2>0.8</mu2></ode></friction>
|
||||
<contact><ode><max_vel>0.1</max_vel><min_depth>0.001</min_depth></ode></contact>
|
||||
</surface>
|
||||
</collision>
|
||||
<!-- Cylinder -->
|
||||
<collision name="Cylinder">
|
||||
<geometry><cylinder><radius>0.135</radius><length>0.5</length></cylinder></geometry>
|
||||
<pose>4.15 0 0.25 0 0 0</pose>
|
||||
<surface>
|
||||
<friction><ode><mu>0.8</mu><mu2>0.8</mu2></ode></friction>
|
||||
<contact><ode><max_vel>0.1</max_vel><min_depth>0.001</min_depth></ode></contact>
|
||||
</surface>
|
||||
</collision>
|
||||
<!-- Cylinder.001 -->
|
||||
<collision name="Cylinder.001">
|
||||
<geometry><cylinder><radius>0.135</radius><length>0.8</length></cylinder></geometry>
|
||||
<pose>0 0 1.3 0 0 0</pose>
|
||||
<surface>
|
||||
<friction><ode><mu>0.8</mu><mu2>0.8</mu2></ode></friction>
|
||||
<contact><ode><max_vel>0.1</max_vel><min_depth>0.001</min_depth></ode></contact>
|
||||
</surface>
|
||||
</collision>
|
||||
</link>
|
||||
</model>
|
||||
</sdf>
|
||||
@@ -0,0 +1,23 @@
|
||||
<?xml version="1.0"?>
|
||||
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
|
||||
<package format="3">
|
||||
<name>robocon_gazebo</name>
|
||||
<version>0.2.0</version>
|
||||
<description>ROBOCON 2027 完整场地(Gazebo Classic 11 + ROS 2 Humble)。资源自包含,不依赖外部克隆目录。</description>
|
||||
<maintainer email="[email protected]">xie</maintainer>
|
||||
<license>Apache-2.0</license>
|
||||
|
||||
<buildtool_depend>ament_cmake</buildtool_depend>
|
||||
|
||||
<exec_depend>gazebo_ros</exec_depend>
|
||||
<exec_depend>gazebo_plugins</exec_depend>
|
||||
<exec_depend>gazebo_msgs</exec_depend>
|
||||
<exec_depend>launch</exec_depend>
|
||||
<exec_depend>launch_ros</exec_depend>
|
||||
<exec_depend>rclpy</exec_depend>
|
||||
<exec_depend>rosgraph_msgs</exec_depend>
|
||||
|
||||
<export>
|
||||
<build_type>ament_cmake</build_type>
|
||||
</export>
|
||||
</package>
|
||||
@@ -0,0 +1,53 @@
|
||||
<?xml version="1.0"?>
|
||||
<!--
|
||||
ROBOCON 2027 场地 (完整碰撞版)
|
||||
与 robocon_track_ros.world 的区别: 场地模型换成 robocon_ground_full
|
||||
- L1 实体 6×6×0.6、L2 实体 3×3×0.3
|
||||
- 南北侧楔形坡道(网格碰撞) + 阶梯盒
|
||||
- 平台边缘护栏、L1/L2 方块阵列、柱体基座(位置修正为 x=4.15)
|
||||
视觉网格仍复用上游 robocon_ground 的 DAE
|
||||
-->
|
||||
<sdf version="1.6">
|
||||
<world name="robocon_world">
|
||||
<physics type="ode">
|
||||
<max_step_size>0.001</max_step_size>
|
||||
<real_time_factor>1.0</real_time_factor>
|
||||
<real_time_update_rate>1000</real_time_update_rate>
|
||||
</physics>
|
||||
|
||||
<scene>
|
||||
<ambient>0.4 0.4 0.4 1</ambient>
|
||||
<background>0.7 0.7 0.7 1</background>
|
||||
<shadows>true</shadows>
|
||||
</scene>
|
||||
|
||||
<light type="directional" name="sun">
|
||||
<cast_shadows>true</cast_shadows>
|
||||
<pose>0 0 10 0 0 0</pose>
|
||||
<diffuse>0.8 0.8 0.8 1</diffuse>
|
||||
<specular>0.2 0.2 0.2 1</specular>
|
||||
<direction>0.1 0.1 -1</direction>
|
||||
</light>
|
||||
|
||||
<include>
|
||||
<uri>model://robocon_ground_full</uri>
|
||||
<pose>0 0 0 0 0 0</pose>
|
||||
</include>
|
||||
|
||||
<!-- SIM-P1-004-C: 此处原有的 libgazebo_ros_init.so / libgazebo_ros_factory.so
|
||||
world 级 <plugin> 声明已移除。本机头文件确认两者为 SystemPlugin,
|
||||
不能作为 world <plugin> 加载;改由官方 gzserver.launch.py 以
|
||||
`-s libgazebo_ros_init.so -s libgazebo_ros_factory.so` 各加载一次。
|
||||
其余内容与源 world 完全一致。 -->
|
||||
|
||||
<!-- SIM-P2-001: 官方 libgazebo_ros_state.so(WorldPlugin)提供独立真值查询:
|
||||
/gazebo/get_entity_state、/gazebo/set_entity_state、/gazebo/link_states。
|
||||
场地几何、物理与光照与本包 robocon_track_full.world 完全一致。 -->
|
||||
<plugin name="gazebo_ros_state" filename="libgazebo_ros_state.so">
|
||||
<ros>
|
||||
<namespace>/gazebo</namespace>
|
||||
</ros>
|
||||
<update_rate>100</update_rate>
|
||||
</plugin>
|
||||
</world>
|
||||
</sdf>
|
||||
@@ -0,0 +1,43 @@
|
||||
<?xml version="1.0"?>
|
||||
<!--
|
||||
ROBOCON 2027 场地 (完整碰撞版)
|
||||
与 robocon_track_ros.world 的区别: 场地模型换成 robocon_ground_full
|
||||
- L1 实体 6×6×0.6、L2 实体 3×3×0.3
|
||||
- 南北侧楔形坡道(网格碰撞) + 阶梯盒
|
||||
- 平台边缘护栏、L1/L2 方块阵列、柱体基座(位置修正为 x=4.15)
|
||||
视觉网格仍复用上游 robocon_ground 的 DAE
|
||||
-->
|
||||
<sdf version="1.6">
|
||||
<world name="robocon_world">
|
||||
<physics type="ode">
|
||||
<max_step_size>0.001</max_step_size>
|
||||
<real_time_factor>1.0</real_time_factor>
|
||||
<real_time_update_rate>1000</real_time_update_rate>
|
||||
</physics>
|
||||
|
||||
<scene>
|
||||
<ambient>0.4 0.4 0.4 1</ambient>
|
||||
<background>0.7 0.7 0.7 1</background>
|
||||
<shadows>true</shadows>
|
||||
</scene>
|
||||
|
||||
<light type="directional" name="sun">
|
||||
<cast_shadows>true</cast_shadows>
|
||||
<pose>0 0 10 0 0 0</pose>
|
||||
<diffuse>0.8 0.8 0.8 1</diffuse>
|
||||
<specular>0.2 0.2 0.2 1</specular>
|
||||
<direction>0.1 0.1 -1</direction>
|
||||
</light>
|
||||
|
||||
<include>
|
||||
<uri>model://robocon_ground_full</uri>
|
||||
<pose>0 0 0 0 0 0</pose>
|
||||
</include>
|
||||
|
||||
<!-- SIM-P1-004-C: 此处原有的 libgazebo_ros_init.so / libgazebo_ros_factory.so
|
||||
world 级 <plugin> 声明已移除。本机头文件确认两者为 SystemPlugin,
|
||||
不能作为 world <plugin> 加载;改由官方 gzserver.launch.py 以
|
||||
`-s libgazebo_ros_init.so -s libgazebo_ros_factory.so` 各加载一次。
|
||||
其余内容与源 world 完全一致。 -->
|
||||
</world>
|
||||
</sdf>
|
||||
Executable
+26
@@ -0,0 +1,26 @@
|
||||
#!/usr/bin/env bash
|
||||
# Build original algorithms in isolated prefixes. Never installs a device SDK.
|
||||
set -eo pipefail
|
||||
BR_SIM_REPO=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/../.." && pwd)
|
||||
cd "$BR_SIM_REPO"
|
||||
BR_SIM_JOBS=${BR_SIM_BUILD_JOBS:-2}
|
||||
[[ "$BR_SIM_JOBS" =~ ^[1-9][0-9]*$ ]] || { echo 'BR_SIM_BUILD_JOBS must be a positive integer' >&2; exit 2; }
|
||||
source /opt/ros/humble/setup.bash
|
||||
export PATH="/usr/bin:$PATH" MAKEFLAGS="-j$BR_SIM_JOBS" CMAKE_BUILD_PARALLEL_LEVEL="$BR_SIM_JOBS"
|
||||
BR_SIM_CMAKE=(-DPython3_EXECUTABLE=/usr/bin/python3 -DCMAKE_BUILD_TYPE=Release)
|
||||
colcon --log-base sim_ws/log/build_interfaces build --base-paths minco_ws/src/perception/livox_ros_driver2 \
|
||||
--packages-select livox_ros_driver2 --build-base sim_ws/build/localization --install-base sim_ws/install/localization \
|
||||
--executor sequential --cmake-args "${BR_SIM_CMAKE[@]}" -DLIVOX_INTERFACES_ONLY=ON -DBUILD_TESTING=OFF
|
||||
source sim_ws/install/localization/setup.bash
|
||||
colcon --log-base sim_ws/log/build_localization build --base-paths minco_ws/src/perception/Point-LIO \
|
||||
--packages-select point_lio --build-base sim_ws/build/localization --install-base sim_ws/install/localization \
|
||||
--executor sequential --cmake-args "${BR_SIM_CMAKE[@]}" -DBUILD_TESTING=OFF
|
||||
source sim_ws/install/localization/setup.bash
|
||||
colcon --log-base sim_ws/log/build_navigation build --base-paths minco_ws/src/scan \
|
||||
--packages-up-to scan_planner step_blocker --build-base sim_ws/build/navigation --install-base sim_ws/install/navigation \
|
||||
--executor sequential --cmake-args "${BR_SIM_CMAKE[@]}" -DBUILD_TESTING=ON
|
||||
source sim_ws/install/navigation/setup.bash
|
||||
colcon --log-base sim_ws/log/build_classic build --base-paths sim_ws/src \
|
||||
--packages-select robocon_gazebo r2027_robot_description br_sim_bringup \
|
||||
--build-base sim_ws/build/classic --install-base sim_ws/install/classic --symlink-install \
|
||||
--executor sequential --cmake-args "${BR_SIM_CMAKE[@]}" -DBUILD_TESTING=OFF
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,209 @@
|
||||
#!/usr/bin/python3
|
||||
"""SCAN navigation using LIO only; independent physical arrival and fault-stop checks."""
|
||||
import argparse
|
||||
import hashlib
|
||||
import json
|
||||
import math
|
||||
import os
|
||||
from pathlib import Path
|
||||
import signal
|
||||
import sys
|
||||
import time
|
||||
|
||||
import rclpy
|
||||
from geometry_msgs.msg import PoseStamped
|
||||
from nav_msgs.msg import Odometry
|
||||
from sensor_msgs.msg import PointCloud2
|
||||
from std_msgs.msg import String
|
||||
from rclpy.qos import QoSProfile,DurabilityPolicy,qos_profile_sensor_data
|
||||
|
||||
from check_omni_robot import Sim,sim_env
|
||||
from check_scan_navigation import NavProbe,run_goal
|
||||
from check_slope_drive import SlopeProbe
|
||||
|
||||
|
||||
class LioNavProbe(NavProbe):
|
||||
get_state=SlopeProbe.get_state
|
||||
def __init__(self):
|
||||
super().__init__(map_diagnostics=False);self.navigation_status=[];self.nav_odom=[];self.lio_odom=[]
|
||||
# The route/fault checks do not need the full dense 3D visualization maps.
|
||||
# Avoid requesting tens of MB/s merely to save diagnostic point counts.
|
||||
self.create_subscription(String,'/sim/navigation/status',lambda m:self.navigation_status.append(json.loads(m.data)),
|
||||
QoSProfile(depth=1,durability=DurabilityPolicy.TRANSIENT_LOCAL))
|
||||
self.create_subscription(Odometry,'/sim/navigation/body_odom',lambda m:self.nav_odom.append(m),100)
|
||||
self.create_subscription(Odometry,'/sim/lio/aft_mapped_to_init',lambda m:self.lio_odom.append(m),100)
|
||||
for topic in ('/sim/navigation/planning_cloud','/sim/navigation/cloud_registered'):
|
||||
self.create_subscription(PointCloud2,topic,lambda m,topic=topic:self.clouds.update({topic:m}),qos_profile_sensor_data)
|
||||
|
||||
|
||||
def graph_evidence(out,probe,planning_topic='/sim/navigation/planning_cloud',extra_nodes=()):
|
||||
info={}
|
||||
for node in ('/lio_navigation_adapter','/sim/lio/point_lio_sim','/scan_planner_node','/closed_loop_controller')+tuple(extra_nodes):
|
||||
name=node.rsplit('/',1)[1];namespace=node.rsplit('/',1)[0] or '/'
|
||||
deadline=time.monotonic()+15
|
||||
while time.monotonic()<deadline:
|
||||
try:
|
||||
subscribers=probe.get_subscriber_names_and_types_by_node(name,namespace)
|
||||
clients=probe.get_client_names_and_types_by_node(name,namespace)
|
||||
if len(subscribers)>=(2 if node in extra_nodes else 3):break
|
||||
except RuntimeError:pass
|
||||
rclpy.spin_once(probe,timeout_sec=.05)
|
||||
else:raise RuntimeError('graph discovery incomplete: '+node)
|
||||
topics=[topic for topic,_ in subscribers]
|
||||
info[node]=dict(subscribers='\n'.join(topic+': '+','.join(types) for topic,types in subscribers),
|
||||
topics=topics,clients='\n'.join(topic for topic,_ in clients))
|
||||
(out/(node.strip('/').replace('/','_')+'_node.json')).write_text(json.dumps(info[node],indent=2)+'\n')
|
||||
checks=dict(no_truth_input=all(all(t not in d['topics'] for t in (
|
||||
'/odom','/body_odom','/aft_mapped_to_init','/tf','/tf_static','/gazebo/model_states','/gazebo/link_states')) and
|
||||
all(t not in d['clients'] for t in ('get_entity_state','get_model_state')) for d in info.values()),
|
||||
estimator_sensors_only=all(t in info['/sim/lio/point_lio_sim']['topics'] for t in ('/sim/mid360/lidar','/sim/mid360/imu')),
|
||||
adapter_lio_only=all(t in info['/lio_navigation_adapter']['topics'] for t in ('/sim/lio/aft_mapped_to_init','/sim/lio/cloud_registered_full_lidar')),
|
||||
controller_uses_estimate='/sim/navigation/body_odom' in info['/closed_loop_controller']['topics'],
|
||||
planner_uses_estimate=all(t in info['/scan_planner_node']['topics'] for t in ('/sim/navigation/body_odom','/sim/navigation/sensor_odom',planning_topic)))
|
||||
return dict(checks=checks,ok=all(checks.values()),nodes=info)
|
||||
|
||||
|
||||
def fault_stop(p,sim):
|
||||
goal=PoseStamped();goal.header.frame_id='world';goal.header.stamp=p.get_clock().now().to_msg()
|
||||
goal.pose.position.x=-3.6;goal.pose.position.y=4.5;goal.pose.position.z=.15;goal.pose.orientation.w=1.
|
||||
p.goal_pub.publish(goal);deadline=time.monotonic()+60
|
||||
while time.monotonic()<deadline:
|
||||
p.pump(.05);truth=p.get_state()
|
||||
if truth and math.hypot(*truth['twist_world'][:2])>.1:break
|
||||
else:raise RuntimeError('fault case never moved')
|
||||
candidates=[]
|
||||
for pid in sim.known:
|
||||
try:
|
||||
if b'/pointlio_mapping' in Path('/proc/%d/cmdline'%pid).read_bytes():candidates.append(pid)
|
||||
except FileNotFoundError:pass
|
||||
if len(candidates)!=1:raise RuntimeError('no single owned Point-LIO process: '+repr(candidates))
|
||||
pid=candidates[0];samples=[];readiness=[];start_cmd=len(p.commands);t0=p.now()
|
||||
if not sim.owns(pid):raise RuntimeError('Point-LIO ownership marker changed')
|
||||
try:
|
||||
os.kill(pid,signal.SIGSTOP)
|
||||
while p.now()-t0<1.3:
|
||||
p.pump(.05);s=p.get_state()
|
||||
if s is None:raise RuntimeError('missing independent physical state')
|
||||
samples.append(s);readiness.append(dict(t=p.now(),ready=p.ready))
|
||||
finally:
|
||||
last_nav_stamp=(p.nav_odom[-1].header.stamp.sec+p.nav_odom[-1].header.stamp.nanosec*1e-9) if p.nav_odom else None
|
||||
os.kill(pid,signal.SIGCONT)
|
||||
stop=next((s['stamp']-t0 for s in samples if math.hypot(*s['twist_world'][:2])<.01 and abs(s['wz'])<.02),None)
|
||||
late=[s for s in samples if s['stamp']-t0>.7]
|
||||
drift=max(math.dist(s['pos'],late[0]['pos']) for s in late) if late else None
|
||||
checks=dict(started_moving=True,readiness_revoked=any(not s['ready'] for s in readiness),
|
||||
stopped_in_time=stop is not None and 0<=stop<=.5,
|
||||
remained_stopped=bool(late) and drift<.02 and all(math.hypot(*s['twist_world'][:2])<.01 for s in late),
|
||||
no_truth_fallback=last_nav_stamp is not None and last_nav_stamp<t0+.1)
|
||||
resumed=[]
|
||||
for _ in range(8):
|
||||
p.pump(.1);s=p.get_state()
|
||||
if s is None:raise RuntimeError('missing resumed truth')
|
||||
resumed.append(s)
|
||||
checks['restart_latched_stopped']=not p.ready and any(s['phase']=='fault' and s['stamp']>t0 for s in p.navigation_status)
|
||||
checks['no_motion_after_resume']=all(math.hypot(*s['twist_world'][:2])<.01 for s in resumed)
|
||||
return dict(name='lio_loss_stop',checks=checks,ok=all(checks.values()),owned_lio_pid=pid,
|
||||
stop_latency_sim_s=stop,drift_m=drift,samples=samples,resumed_samples=resumed,
|
||||
last_nav_stamp_during_loss=last_nav_stamp,loss_start_stamp=t0,readiness=readiness,commands=p.commands[start_cmd:])
|
||||
|
||||
|
||||
def near_goal_recovery(p,sim):
|
||||
candidates=[]
|
||||
for pid in sim.known:
|
||||
try:
|
||||
if b'/lio_navigation_adapter.py' in Path('/proc/%d/cmdline'%pid).read_bytes() and sim.owns(pid):candidates.append(pid)
|
||||
except FileNotFoundError:pass
|
||||
if len(candidates)!=1:raise RuntimeError('cannot identify one owned navigation adapter')
|
||||
event={};pid=candidates[0]
|
||||
def pause_near_goal(state):
|
||||
distance=math.hypot(state['pos'][0]+3.8,state['pos'][1]-4.5)
|
||||
if event or not (.12<distance<.19) or math.hypot(*state['twist_world'][:2])<.02:return
|
||||
estimated=p.nav_odom[-1].pose.pose.position
|
||||
event.update(start=p.now(),physical_remaining_m=distance,
|
||||
estimated_remaining_m=math.hypot(estimated.x+3.8,estimated.y-4.5),owned_adapter_pid=pid)
|
||||
try:
|
||||
os.kill(pid,signal.SIGSTOP);p.pump(.4)
|
||||
event['paused_final_truth']=p.get_state()
|
||||
finally:
|
||||
os.kill(pid,signal.SIGCONT);event['resumed']=p.now()
|
||||
result=run_goal(p,'near_goal_recovery',-3.8,4.5,0.,goal_z=.15,settle_timeout=.2,sample_hook=pause_near_goal)
|
||||
checks=result['checks']
|
||||
checks['short_distance_hold_exercised']=bool(event) and .08<event['estimated_remaining_m']<.2
|
||||
held=[s for s in result['statuses'] if event and event['start']<=s['t']<=event['resumed'] and
|
||||
s['state']==0 and ('perception' in s['reason'] or 'odometry_stale' in s['reason'])]
|
||||
before=[s['traj_id'] for s in result['statuses'] if event and s['t']<=event['start'] and s['state']==1]
|
||||
stopped=event.get('paused_final_truth')
|
||||
checks['held_before_recovery']=bool(held) and stopped is not None and math.hypot(*stopped['twist_world'][:2])<.01 and abs(stopped['wz'])<.02
|
||||
checks['new_grant_after_recovery']=bool(event and before) and any(
|
||||
s['t']>event['resumed'] and s['state']==1 and s['traj_id']>max(before) for s in result['statuses'])
|
||||
result['event']=event;result['ok']=all(checks.values());return result
|
||||
|
||||
|
||||
def main():
|
||||
ap=argparse.ArgumentParser();ap.add_argument('--out',required=True)
|
||||
group=ap.add_mutually_exclusive_group();group.add_argument('--straight-only',action='store_true');group.add_argument('--fault-only',action='store_true');group.add_argument('--recovery-only',action='store_true')
|
||||
ap.add_argument('--laps',type=int,default=1)
|
||||
ap.add_argument('--sensor-profile',choices=('ideal','mild','stress'),default='ideal')
|
||||
ap.add_argument('--split',action='store_true')
|
||||
args=ap.parse_args()
|
||||
if not 1<=args.laps<=5 or (args.laps>1 and (args.straight_only or args.fault_only or args.recovery_only)):
|
||||
ap.error('laps must be 1..5 and multi-lap mode requires complete navigation')
|
||||
out=Path(args.out).resolve();out.mkdir(parents=True,exist_ok=True)
|
||||
os.environ.update(sim_env());os.environ['ROS_LOG_DIR']=str(out/'ros')
|
||||
source=Path(__file__).read_bytes();(out/'collector_snapshot.py').write_bytes(source)
|
||||
report=dict(status='INVALID',cases=[],sensor_profile=args.sensor_profile,laps=args.laps,split=args.split,collector_sha256=hashlib.sha256(source).hexdigest())
|
||||
sim,p=Sim(str(out/'sim')),None
|
||||
try:
|
||||
ok,why=sim.start(lio_navigation=True,sensor_profile=args.sensor_profile,split=args.split);report['startup']=why
|
||||
if not ok:raise RuntimeError(why)
|
||||
rclpy.init();p=LioNavProbe()
|
||||
if not p.wait_clock():raise RuntimeError('missing clock')
|
||||
deadline=time.monotonic()+90
|
||||
while time.monotonic()<deadline:
|
||||
rclpy.spin_once(p,timeout_sec=.02)
|
||||
if p.ready and p.status and p.goal_pub.get_subscription_count()>=2 and len(p.nav_odom)>20:break
|
||||
else:raise RuntimeError('LIO navigation never became ready')
|
||||
report['graph']=graph_evidence(out,p)
|
||||
if not report['graph']['ok']:
|
||||
report['status']='FAIL';return 30
|
||||
p.pump(1.)
|
||||
if args.fault_only:report['cases'].append(fault_stop(p,sim))
|
||||
elif args.recovery_only:report['cases'].append(near_goal_recovery(p,sim))
|
||||
else:
|
||||
# Keep the whole 8 cm arrival-tolerance region and terminal-turn
|
||||
# envelope clear of the now-observed L1 corner. No margin is reduced.
|
||||
goals=[('straight',-3.8,4.5,0.),('lateral',-3.8,3.5,0.),('return_and_turn',-4.5,4.5,math.pi/2)]
|
||||
if args.straight_only:goals=goals[:1]
|
||||
fixture=False
|
||||
for lap in range(args.laps):
|
||||
lapdir=out if args.laps==1 else out/('lap_%d'%(lap+1));lapdir.mkdir(exist_ok=True)
|
||||
for name,x,y,yaw in goals:
|
||||
result=run_goal(p,name,x,y,yaw,goal_z=.15,settle_timeout=.2)
|
||||
result['lap']=lap+1;report['cases'].append(result)
|
||||
(lapdir/(name+'.json')).write_text(json.dumps(result,indent=2)+'\n')
|
||||
print('lap',lap+1,name,result['checks'],'error',result['position_error_m'],flush=True)
|
||||
if not result['ok']:break
|
||||
if not all(c['ok'] for c in report['cases']):break
|
||||
if not args.straight_only:
|
||||
if not fixture:
|
||||
(out/'test_obstacle.sdf').write_text(p.add_obstacle());fixture=True;p.pump(2.)
|
||||
result=run_goal(p,'detour',-4.5,1.5,math.pi/2,obstacle=True,goal_z=.15,settle_timeout=.2)
|
||||
result['lap']=lap+1;report['cases'].append(result)
|
||||
(lapdir/'detour.json').write_text(json.dumps(result,indent=2)+'\n')
|
||||
print('lap',lap+1,'detour',result['checks'],'error',result['position_error_m'],flush=True)
|
||||
if not result['ok']:break
|
||||
expected=1 if args.straight_only or args.fault_only or args.recovery_only else 4*args.laps
|
||||
report['status']='PASS' if len(report['cases'])==expected and all(c['ok'] for c in report['cases']) else 'FAIL'
|
||||
report['navigation_status']=p.navigation_status
|
||||
report['observed_tf_edges']=p.tf_pairs
|
||||
report['input_reference_frames']=sorted({(m.header.frame_id,m.child_frame_id) for m in p.nav_odom})
|
||||
except Exception as exc:
|
||||
report['error']=repr(exc);print(report['error'],flush=True)
|
||||
finally:
|
||||
if p is not None:p.send(0.,0.,0.);p.destroy_node()
|
||||
if rclpy.ok():rclpy.shutdown()
|
||||
report['teardown']=sim.stop();(out/'result.json').write_text(json.dumps(report,indent=2)+'\n')
|
||||
return {'PASS':0,'FAIL':30,'INVALID':40}[report['status']]
|
||||
|
||||
|
||||
if __name__=='__main__':sys.exit(main())
|
||||
@@ -0,0 +1,194 @@
|
||||
#!/usr/bin/python3
|
||||
"""Independent physical acceptance of LIO reference-path navigation on known ramps."""
|
||||
import argparse,hashlib,json,math,os,signal,sys,time
|
||||
from pathlib import Path
|
||||
import numpy as np
|
||||
import rclpy
|
||||
from gazebo_msgs.msg import ContactsState
|
||||
from gazebo_msgs.srv import SpawnEntity
|
||||
from geometry_msgs.msg import PoseStamped
|
||||
from nav_msgs.msg import Path as NavPath
|
||||
from rclpy.qos import QoSProfile,DurabilityPolicy,qos_profile_sensor_data
|
||||
from sensor_msgs.msg import PointCloud2
|
||||
from check_omni_robot import Sim,sim_env
|
||||
from check_lio_navigation import LioNavProbe,graph_evidence
|
||||
from check_mid360 import interpolate,rotate,json_value
|
||||
from check_sim_lidar import points
|
||||
|
||||
|
||||
def height(x):return 0. if x>=2.7 else (.6 if x<=-.8 else (1.6119-.597*x)/3.5)
|
||||
|
||||
|
||||
class TerrainProbe(LioNavProbe):
|
||||
def __init__(self,out):
|
||||
super().__init__();self.out=out;self.contacts=[];self.snapshots=[];self.next_snapshot=0.
|
||||
self.path_pub=self.create_publisher(NavPath,'/initial_path',QoSProfile(depth=1,durability=DurabilityPolicy.TRANSIENT_LOCAL))
|
||||
self.create_subscription(ContactsState,'/sim/drive_contacts',self.contacts.append,100)
|
||||
def capture(self):
|
||||
if self.now()<self.next_snapshot:return
|
||||
full=self.clouds.get('/sim/navigation/cloud_registered');filtered=self.clouds.get('/sim/navigation/planning_cloud')
|
||||
if full is None or filtered is None or full.header.stamp!=filtered.header.stamp:return
|
||||
self.next_snapshot=self.now()+1.
|
||||
name='cloud_%03d.npz'%len(self.snapshots)
|
||||
np.savez_compressed(self.out/name,world=points(full),filtered=points(filtered))
|
||||
self.snapshots.append(dict(file=name,stamp=full.header.stamp.sec+full.header.stamp.nanosec*1e-9))
|
||||
|
||||
|
||||
def run_path(p,xs,y,blocked=False,fault_sim=None,goal_y=None):
|
||||
old_id=p.status[-1].goal_id if p.status else 0;si=len(p.status);ci=len(p.commands);ki=len(p.contacts);ei=len(p.nav_odom)
|
||||
first=p.get_state()
|
||||
if first is None:raise RuntimeError('missing initial independent truth')
|
||||
msg=NavPath();msg.header.frame_id='world';msg.header.stamp=p.get_clock().now().to_msg()
|
||||
for x in xs:
|
||||
pose=PoseStamped();pose.header=msg.header;pose.pose.position.x=float(x);pose.pose.position.y=y
|
||||
pose.pose.position.z=.15 if blocked and x<-1.8 else height(x);pose.pose.orientation.w=1.;msg.poses.append(pose)
|
||||
if goal_y is not None:msg.poses[-1].pose.position.y=goal_y
|
||||
target_y=msg.poses[-1].pose.position.y
|
||||
p.path_pub.publish(msg);start=p.now();deadline=time.monotonic()+500;states=[first];readiness=[];fault={}
|
||||
while p.now()-start<85 and time.monotonic()<deadline:
|
||||
p.pump(.04);s=p.get_state()
|
||||
if s is None:raise RuntimeError('missing physical state')
|
||||
states.append(s);readiness.append(dict(t=p.now(),ready=p.ready));p.capture()
|
||||
if fault_sim is not None and not fault and 1.2<s['pos'][0]<1.8 and math.hypot(*s['twist_world'][:2])>.08:
|
||||
candidates=[pid for pid in fault_sim.known if fault_sim.owns(pid) and b'/step_blocker' in Path('/proc/%d/cmdline'%pid).read_bytes()]
|
||||
if len(candidates)!=1:raise RuntimeError('cannot identify one owned step_blocker')
|
||||
pid=candidates[0];fault.update(start=p.now(),owned_pid=pid,samples=[],readiness=[])
|
||||
try:
|
||||
os.kill(pid,signal.SIGSTOP)
|
||||
while p.now()-fault['start']<.8:
|
||||
p.pump(.04);held=p.get_state()
|
||||
if held is None:raise RuntimeError('missing independent fault state')
|
||||
states.append(held);fault['samples'].append(held);fault['readiness'].append(dict(t=p.now(),ready=p.ready));p.capture()
|
||||
finally:
|
||||
if fault_sim.owns(pid):os.kill(pid,signal.SIGCONT)
|
||||
fault['resumed']=p.now()
|
||||
status=p.status[-1] if p.status else None
|
||||
if status and status.goal_id>old_id and status.state in (status.SUCCEEDED,status.FAILED):break
|
||||
status=p.status[-1];terminal=status.header.stamp.sec+status.header.stamp.nanosec*1e-9
|
||||
braking=[];latency=None
|
||||
while p.now()-terminal<.2:
|
||||
p.pump(.005);s=p.get_state()
|
||||
if s is None:raise RuntimeError('missing braking state')
|
||||
braking.append(s)
|
||||
if math.hypot(*s['twist_world'][:2])<.01 and abs(s['wz'])<.02:latency=s['stamp']-terminal;break
|
||||
rest=[];t=p.now()
|
||||
while p.now()-t<1.1:
|
||||
p.pump(.04);s=p.get_state()
|
||||
if s is None:raise RuntimeError('missing stopped state')
|
||||
rest.append(s);p.capture()
|
||||
statuses=p.status[si:];commands=p.commands[ci:];contacts=p.contacts[ki:];states+=braking+rest
|
||||
# Align estimated and physical reference points only by their timestamps.
|
||||
ts=[s['stamp'] for s in states];est=[m for m in p.nav_odom[ei:] if ts[0]<=m.header.stamp.sec+m.header.stamp.nanosec*1e-9<=ts[-1]]
|
||||
if len(est)<(20 if blocked else 100):raise RuntimeError('not enough estimator/truth pairs')
|
||||
times=np.array([m.header.stamp.sec+m.header.stamp.nanosec*1e-9 for m in est]);pos,q=interpolate(states,times)
|
||||
estimated=np.array([[m.pose.pose.position.x,m.pose.pose.position.y,m.pose.pose.position.z] for m in est]);errors=estimated-pos
|
||||
matrices=np.stack([rotate(np.broadcast_to(np.array(s['quaternion']),(3,4)),np.eye(3)).T for s in states])
|
||||
extent=np.abs(matrices[:,1,:])@np.array([.4,.4,.15])
|
||||
physical_y=np.array([s['pos'][1] for s in states])
|
||||
clearance=np.minimum(np.abs(physical_y)-3.025-extent,4.-np.abs(physical_y)-extent)
|
||||
xy_error=math.hypot(rest[-1]['pos'][0]-xs[-1],rest[-1]['pos'][1]-target_y)
|
||||
drift=max(math.dist(s['pos'],rest[0]['pos']) for s in rest)
|
||||
mid=[s for s in states if -.35<s['pos'][0]<2.2]
|
||||
checks=dict(acknowledged=status.goal_id>old_id,state_as_expected=status.state==(status.FAILED if blocked else status.SUCCEEDED),
|
||||
perception_fresh=p.ready,original_goal_preserved=abs(status.goal.x-xs[-1])<1e-6 and abs(status.goal.y-target_y)<1e-6 and abs(status.goal.z-(msg.poses[-1].pose.position.z+.15))<1e-6,
|
||||
stopped=drift<.02 and all(math.hypot(*s['twist_world'][:2])<.01 and abs(s['wz'])<.02 for s in rest),
|
||||
bounded_braking=latency is not None and 0<=latency<=.2,
|
||||
estimated_lateral_error=max(abs(errors[:,1]))<.03,estimated_vertical_error=max(abs(errors[:,2]))<.05)
|
||||
if fault_sim is not None:
|
||||
stopped=next((s['stamp']-fault['start'] for s in fault.get('samples',[]) if math.hypot(*s['twist_world'][:2])<.01 and abs(s['wz'])<.02),None)
|
||||
late=[s for s in fault.get('samples',[]) if s['stamp']-fault['start']>.6]
|
||||
fault['stop_latency_sim_s']=stopped
|
||||
checks.update(downstream_hold_exercised=bool(fault.get('samples')),
|
||||
downstream_readiness_revoked=any(not r['ready'] for r in fault.get('readiness',[])),
|
||||
downstream_stop_in_time=stopped is not None and 0<=stopped<=.5,
|
||||
downstream_held_still=bool(late) and all(math.hypot(*s['twist_world'][:2])<.01 and math.dist(s['pos'],late[0]['pos'])<.02 for s in late),
|
||||
downstream_new_grant='resumed' in fault and any(s.header.stamp.sec+s.header.stamp.nanosec*1e-9>fault['resumed'] and s.state==s.ACTIVE for s in statuses))
|
||||
if blocked:
|
||||
checks.update(never_active=not any(s.state==s.ACTIVE for s in statuses),stationary=max(math.dist(s['pos'],first['pos']) for s in states)<.02,
|
||||
zero_commands=bool(commands) and all(max(abs(c[k]) for k in ('vx','vy','wz'))<1e-6 for c in commands))
|
||||
else:
|
||||
checks.update(active=any(s.state==s.ACTIVE for s in statuses),physical_arrival=xy_error<.10,
|
||||
physical_height=abs(rest[-1]['pos'][2]-(height(xs[-1])+.15))<.03,
|
||||
ramp_pitch=bool(mid) and max(abs(s['rpy'][1]-math.atan2(.597,3.5)) for s in mid)<.05,
|
||||
ramp_height=bool(mid) and max(abs(s['pos'][2]-(height(s['pos'][0])+.15)) for s in mid)<.04,
|
||||
lane=max(abs(s['pos'][1]-y) for s in states)<.03,
|
||||
full_body_clearance=float(min(clearance))>.04,
|
||||
real_ramp_contacts=any(('ramp_north' if y>0 else 'ramp_south') in pair for m in contacts for c in m.states for pair in (c.collision1_name,c.collision2_name)),
|
||||
penetration=bool(contacts) and max((d for m in contacts for c in m.states for d in c.depths),default=1)<.005)
|
||||
return dict(checks=checks,ok=all(checks.values()),goal=[xs[-1],target_y,msg.poses[-1].pose.position.z+.15],
|
||||
position_error_m=xy_error,stop_drift_m=drift,braking_latency_sim_s=latency,
|
||||
estimated_max_abs_xyz_error_m=np.max(np.abs(errors),axis=0).tolist(),min_full_body_clearance_m=float(min(clearance)),
|
||||
contact_evidence=dict(messages=len(contacts),
|
||||
maximum_depth_m=max((d for m in contacts for c in m.states for d in c.depths),default=None),
|
||||
collision_pairs=sorted({(c.collision1_name,c.collision2_name) for m in contacts for c in m.states})),
|
||||
fault_event=fault,
|
||||
estimation_pairs=[dict(stamp=float(t),estimate=e.tolist(),truth_interpolated=g.tolist()) for t,e,g in zip(times,estimated,pos)],
|
||||
input_path=[[s.pose.position.x,s.pose.position.y,s.pose.position.z] for s in msg.poses],samples=states,
|
||||
stopped_samples=rest,braking_samples=braking,readiness=readiness,commands=commands,
|
||||
statuses=[dict(t=s.header.stamp.sec+s.header.stamp.nanosec*1e-9,state=s.state,reason=s.reason,traj_id=s.traj_id,goal_id=s.goal_id) for s in statuses])
|
||||
|
||||
|
||||
def main():
|
||||
ap=argparse.ArgumentParser();ap.add_argument('--out',required=True);ap.add_argument('--side',choices=('red','blue'),default='red')
|
||||
group=ap.add_mutually_exclusive_group();group.add_argument('--up-only',action='store_true');group.add_argument('--obstacle-only',action='store_true')
|
||||
ap.add_argument('--planning-loss',action='store_true')
|
||||
ap.add_argument('--sensor-profile',choices=('ideal','mild','stress'),default='ideal')
|
||||
args=ap.parse_args()
|
||||
out=Path(args.out).resolve();out.mkdir(parents=True,exist_ok=True);os.environ.update(sim_env());os.environ['ROS_LOG_DIR']=str(out/'ros')
|
||||
source=Path(__file__).read_bytes();(out/'collector_snapshot.py').write_bytes(source)
|
||||
repo=Path(__file__).resolve().parents[2]
|
||||
for name in ('sim_ws/src/br_sim_bringup/config/lio_terrain.yaml','sim_ws/src/br_sim_bringup/config/point_lio_terrain.yaml','sim_ws/src/br_sim_bringup/scripts/lio_navigation_adapter.py',
|
||||
'sim_ws/src/br_sim_bringup/launch/scan_lio_terrain.launch.py'):
|
||||
(out/Path(name).name).write_bytes((repo/name).read_bytes())
|
||||
report=dict(status='INVALID',cases={},side=args.side,sensor_profile=args.sensor_profile,collector_sha256=hashlib.sha256(source).hexdigest())
|
||||
sim=Sim(str(out/'sim'));p=None;y=3.5125 if args.side=='red' else -3.5125
|
||||
try:
|
||||
ok,why=sim.start(navigation=True,terrain=True,lio_navigation=True,sensor_profile=args.sensor_profile,spawn=(3.5,y,.15,0.));report['startup']=why
|
||||
if not ok:raise RuntimeError(why)
|
||||
rclpy.init();p=TerrainProbe(out)
|
||||
if not p.wait_clock():raise RuntimeError('no clock')
|
||||
deadline=time.monotonic()+100
|
||||
while time.monotonic()<deadline:
|
||||
rclpy.spin_once(p,timeout_sec=.02)
|
||||
if p.ready and p.status and p.path_pub.get_subscription_count()>0 and len(p.nav_odom)>20:break
|
||||
else:raise RuntimeError('terrain LIO pipeline not ready')
|
||||
report['graph']=graph_evidence(out,p,'/sim/navigation/terrain_planning_cloud',extra_nodes=('/step_blocker',))
|
||||
if not report['graph']['ok']:raise RuntimeError('truth input or incorrect estimator wiring')
|
||||
p.pump(1.)
|
||||
cases=[('uphill',[3.5,2.7,-.8,-1.2],False)]
|
||||
if args.obstacle_only:
|
||||
req=SpawnEntity.Request();req.name='p6_terrain_obstacle';req.reference_frame='world'
|
||||
req.initial_pose.position.x=1.;req.initial_pose.position.y=y;req.initial_pose.position.z=height(1.)+.3
|
||||
req.initial_pose.orientation.w=1.
|
||||
req.xml='<sdf version="1.6"><model name="p6_terrain_obstacle"><static>true</static><link name="box"><collision name="box"><geometry><box><size>0.25 0.25 0.6</size></box></geometry></collision><visual name="box"><geometry><box><size>0.25 0.25 0.6</size></box></geometry></visual></link></model></sdf>'
|
||||
response=p._call(p.spawn,req,timeout=15)
|
||||
if not response or not response.success:raise RuntimeError('obstacle fixture not spawned')
|
||||
(out/'obstacle.sdf').write_text(req.xml);p.pump(2.);p.capture()
|
||||
deadline=time.monotonic()+5
|
||||
while p.clouds['/sim/navigation/cloud_registered'].header.stamp!=p.clouds['/sim/navigation/planning_cloud'].header.stamp and time.monotonic()<deadline:p.pump(.02)
|
||||
if p.clouds['/sim/navigation/cloud_registered'].header.stamp!=p.clouds['/sim/navigation/planning_cloud'].header.stamp:raise RuntimeError('no matched obstacle cloud stamps')
|
||||
full=points(p.clouds['/sim/navigation/cloud_registered']);filtered=points(p.clouds['/sim/navigation/planning_cloud'])
|
||||
np.savez_compressed(out/'obstacle_points.npz',world=full,filtered=filtered)
|
||||
if len(full)!=len(filtered):raise RuntimeError('unpaired obstacle point clouds')
|
||||
selected=(np.abs(full[:,0]-1.)<.18)&(np.abs(full[:,1]-y)<.18)&(full[:,2]>height(1.)+.12)&(full[:,2]<height(1.)+.68)
|
||||
count=int(np.count_nonzero(selected));retained=int(np.count_nonzero(np.isfinite(filtered[selected]).all(axis=1)))
|
||||
report['obstacle_returns']=dict(count=count,retained=retained,ok=count>=15 and retained==count)
|
||||
if not report['obstacle_returns']['ok']:raise RuntimeError('obstacle was not observed and preserved')
|
||||
cases=[('ramp_obstacle_rejected',[3.5,2.7,1.],True)]
|
||||
elif not args.up_only:cases.extend([('stairs_rejected',[-1.2,-2.5],True),('edge_rejected',[-1.2,1.],True),('downhill',[-1.2,-.8,2.7,3.5],False)])
|
||||
for name,xs,blocked in cases:
|
||||
result=run_path(p,xs,y,blocked,fault_sim=sim if args.planning_loss and name=='uphill' else None,
|
||||
goal_y=(3.9 if y>0 else -3.9) if name=='edge_rejected' else None);report['cases'][name]=result
|
||||
(out/(name+'.json')).write_text(json.dumps(result,indent=2,default=json_value)+'\n');print(name,result['checks'],flush=True)
|
||||
if not result['ok']:break
|
||||
report['status']='PASS' if len(report['cases'])==len(cases) and all(c['ok'] for c in report['cases'].values()) else 'FAIL'
|
||||
report['cloud_snapshots']=p.snapshots;report['navigation_status']=p.navigation_status
|
||||
except Exception as exc:report['error']=repr(exc);print(report['error'],flush=True)
|
||||
finally:
|
||||
if p is not None:p.send(0.,0.,0.);p.destroy_node()
|
||||
if rclpy.ok():rclpy.shutdown()
|
||||
report['teardown']=sim.stop();(out/'result.json').write_text(json.dumps(report,indent=2,default=json_value)+'\n')
|
||||
return {'PASS':0,'FAIL':30,'INVALID':40}[report['status']]
|
||||
|
||||
|
||||
if __name__=='__main__':sys.exit(main())
|
||||
@@ -0,0 +1,73 @@
|
||||
#!/usr/bin/python3
|
||||
"""Measure physical MID360 lower-FOV limits. PASS characterizes a limitation, not safe navigation."""
|
||||
import argparse,json,os,sys
|
||||
from pathlib import Path
|
||||
import numpy as np
|
||||
import rclpy
|
||||
from gazebo_msgs.srv import SpawnEntity,DeleteEntity,GetEntityState
|
||||
from check_omni_robot import Sim,sim_env
|
||||
from check_mid360 import SensorProbe,rotate,json_value
|
||||
|
||||
|
||||
def main():
|
||||
ap=argparse.ArgumentParser();ap.add_argument('--out',required=True);args=ap.parse_args()
|
||||
out=Path(args.out).resolve();out.mkdir(parents=True,exist_ok=True);os.environ.update(sim_env());os.environ['ROS_LOG_DIR']=str(out/'ros')
|
||||
report=dict(status='INVALID',scope='stationary ideal sensor visibility only; not navigation acceptance',cases=[]);sim=Sim(str(out/'sim'));p=None
|
||||
(out/'collector_snapshot.py').write_bytes(Path(__file__).read_bytes())
|
||||
try:
|
||||
ok,why=sim.start(lidar=True,drive='contact',sensor_model='mid360',spawn=(-4.5,4.5,.15,0.));report['startup']=why
|
||||
if not ok:raise RuntimeError(why)
|
||||
rclpy.init();p=SensorProbe()
|
||||
if not p.wait_clock():raise RuntimeError('no clock')
|
||||
spawn=p.create_client(SpawnEntity,'/spawn_entity');delete=p.create_client(DeleteEntity,'/delete_entity');p.pump(2.)
|
||||
for distance,height in [(1.5,.03),(3.,.03),(1.5,.08),(3.,.08),(1.5,.15),(3.,.15),(.6,.3),(1.5,.3),(1.5,.6)]:
|
||||
state=p.get_state()
|
||||
if state is None:raise RuntimeError('no physical observer pose')
|
||||
center=np.array([state['pos'][0]+distance,state['pos'][1],height/2])
|
||||
# The far TOP face can be visible even if the front face is below
|
||||
# the lower FOV. Include box depth; a point-target approximation
|
||||
# wrongly predicts that the 8 cm / 3 m fixture is invisible.
|
||||
q=np.array(state['quaternion']);origin=np.array(state['pos'])+rotate(q,np.array([0.,0.,.3]))
|
||||
inverse=q.copy();inverse[:3]*=-1
|
||||
corners=np.array([[center[0]+dx,center[1]+dy,height] for dx in (-.125,.125) for dy in (-.125,.125)])
|
||||
local=rotate(inverse,corners-origin)
|
||||
maximum_elevation=float(np.arctan2(local[:,2],np.linalg.norm(local[:,:2],axis=1)).max())
|
||||
visible=maximum_elevation>=np.deg2rad(-7)
|
||||
req=SpawnEntity.Request();req.name='visibility_box_%02d'%len(report['cases']);req.reference_frame='world';req.initial_pose.position.x=float(center[0]);req.initial_pose.position.y=float(center[1]);req.initial_pose.position.z=float(center[2]);req.initial_pose.orientation.w=1.
|
||||
req.xml=f'<sdf version="1.6"><model name="visibility_box"><static>true</static><link name="box"><collision name="box"><geometry><box><size>0.25 0.25 {height}</size></box></geometry></collision><visual name="box"><geometry><box><size>0.25 0.25 {height}</size></box></geometry></visual></link></model></sdf>'
|
||||
response=p._call(spawn,req,timeout=10)
|
||||
if not response or not response.success:raise RuntimeError('box not spawned')
|
||||
query=GetEntityState.Request();query.name=req.name;query.reference_frame='world'
|
||||
p.pump(.2);exists=p._call(p.cli_get,query,timeout=10)
|
||||
if not exists or not exists.success:raise RuntimeError('spawned fixture not independently queryable')
|
||||
p.pump(.2);t=p.now();p.pump(1.5)
|
||||
frames=[f for f in p.frames if t<f['t'] and f['t']+.1<p.now()]
|
||||
if len(frames)<8:raise RuntimeError('insufficient actual scans')
|
||||
q=np.array(state['quaternion']);origin=np.array(state['pos'])+rotate(q,np.array([0.,0.,.3]));all_world=[]
|
||||
for f in frames:all_world.append(rotate(q,f['xyz'])+origin)
|
||||
world=np.concatenate(all_world)
|
||||
in_box=(abs(world[:,0]-center[0])<.126)&(abs(world[:,1]-center[1])<.126)&(world[:,2]>.005)&(world[:,2]<=height+.002)
|
||||
count=int(in_box.sum());ok=count>=5 if visible else count==0
|
||||
case=dict(distance_m=distance,height_m=height,expected_visible=visible,observed_returns=count,frames=len(frames),ok=ok,
|
||||
navigation_capability='visible points only; motion untested' if count else 'UNSUPPORTED: no returns, cannot promise avoidance')
|
||||
report['cases'].append(case);np.savez_compressed(out/('fixture_%02d.npz'%len(report['cases'])),returns=world[in_box],fixture_center=center,observer_position=state['pos'],observer_quaternion=q)
|
||||
print(case,flush=True)
|
||||
remove=DeleteEntity.Request();remove.name=req.name;response=p._call(delete,remove,timeout=10)
|
||||
if response is None:raise RuntimeError('missing delete response')
|
||||
case['fixture_name']=req.name;case['delete_response_success']=response.success;case['delete_response']=response.status_message
|
||||
# Gazebo deletion is asynchronous. Confirm actual absence, using a
|
||||
# unique name so an old deletion cannot affect a subsequent fixture.
|
||||
for _ in range(30):
|
||||
p.pump(.05);exists=p._call(p.cli_get,query,timeout=10)
|
||||
if exists is not None and not exists.success:break
|
||||
else:raise RuntimeError('owned fixture still exists after deletion')
|
||||
p.pump(.2)
|
||||
report['status']='PASS' if all(c['ok'] for c in report['cases']) else 'FAIL'
|
||||
except Exception as e:report['error']=repr(e);print(report['error'],flush=True)
|
||||
finally:
|
||||
if p is not None:p.send(0.,0.,0.);p.destroy_node()
|
||||
if rclpy.ok():rclpy.shutdown()
|
||||
report['teardown']=sim.stop();(out/'result.json').write_text(json.dumps(report,indent=2,default=json_value)+'\n')
|
||||
return dict(PASS=0,FAIL=30,INVALID=40)[report['status']]
|
||||
|
||||
if __name__=='__main__':sys.exit(main())
|
||||
@@ -0,0 +1,256 @@
|
||||
#!/usr/bin/python3
|
||||
"""Independent geometry, acquisition-time and specific-force acceptance, no truth into LIO."""
|
||||
import argparse
|
||||
import hashlib
|
||||
import json
|
||||
import math
|
||||
import os
|
||||
from pathlib import Path
|
||||
import sys
|
||||
import time
|
||||
import xml.etree.ElementTree as ET
|
||||
|
||||
import numpy as np
|
||||
import rclpy
|
||||
from livox_ros_driver2.msg import CustomMsg
|
||||
from sensor_msgs.msg import Imu
|
||||
from std_msgs.msg import String
|
||||
from rclpy.qos import qos_profile_sensor_data
|
||||
from check_omni_robot import Sim,sim_env
|
||||
from check_slope_drive import SlopeProbe
|
||||
|
||||
ROOT=Path(__file__).resolve().parents[2]
|
||||
MOUNT=np.array([0.,0.,.30])
|
||||
|
||||
|
||||
def json_value(value):
|
||||
if isinstance(value,np.generic):return value.item()
|
||||
raise TypeError('unsupported evidence value: '+type(value).__name__)
|
||||
|
||||
|
||||
def rotate(q,v):
|
||||
"""Quaternion xyzw, row vectors, broadcasting allowed."""
|
||||
return v+2*np.cross(q[..., :3],np.cross(q[..., :3],v)+q[...,3,None]*v)
|
||||
|
||||
|
||||
def interpolate(states,times):
|
||||
times=np.asarray(times)
|
||||
ts=np.array([s['stamp'] for s in states])
|
||||
# Duplicate state samples are legal; select distinct independent query times.
|
||||
ts,idx=np.unique(ts,return_index=True);states=[states[i] for i in idx]
|
||||
if np.min(times)<ts[0] or np.max(times)>ts[-1]:raise ValueError('no bracketing independent truth')
|
||||
hi=np.clip(np.searchsorted(ts,times,side='right'),1,len(ts)-1);lo=hi-1
|
||||
if np.max(ts[hi]-ts[lo])>.12:raise ValueError('truth gap exceeds 120 ms')
|
||||
w=(times-ts[lo])/(ts[hi]-ts[lo])
|
||||
pos=np.array([s['pos'] for s in states]);q=np.array([s['quaternion'] for s in states])
|
||||
qa,qb=q[lo],q[hi];qb=np.where(np.sum(qa*qb,axis=-1,keepdims=True)<0,-qb,qb)
|
||||
qq=qa+(qb-qa)*w[:,None];qq/=np.linalg.norm(qq,axis=-1,keepdims=True)
|
||||
return pos[lo]+(pos[hi]-pos[lo])*w[:,None],qq
|
||||
|
||||
|
||||
def scene_shapes():
|
||||
"""Read authoritative static primitives and triangles; independent of ODE ray code."""
|
||||
base=ROOT/'sim_ws/src/robocon_gazebo/models/robocon_ground_full'
|
||||
result=[]
|
||||
for c in ET.parse(base/'model.sdf').findall('.//collision'):
|
||||
p=np.fromstring(c.findtext('pose','0 0 0 0 0 0'),sep=' ')
|
||||
r,pitch,y=p[3:];cx,sx=np.cos(r),np.sin(r);cy,sy=np.cos(pitch),np.sin(pitch);cz,sz=np.cos(y),np.sin(y)
|
||||
R=np.array([[cz*cy,cz*sy*sx-sz*cx,cz*sy*cx+sz*sx],
|
||||
[sz*cy,sz*sy*sx+cz*cx,sz*sy*cx-cz*sx],[-sy,cy*sx,cy*cx]])
|
||||
geom=c.find('geometry');box=geom.find('box');cylinder=geom.find('cylinder');mesh=geom.find('mesh')
|
||||
if box is not None:shape=('box',np.fromstring(box.findtext('size'),sep=' ')/2)
|
||||
elif cylinder is not None:shape=('cylinder',(float(cylinder.findtext('radius')),float(cylinder.findtext('length'))/2))
|
||||
elif mesh is not None:
|
||||
path=base/'meshes'/Path(mesh.findtext('uri')).name
|
||||
vertices=[];faces=[]
|
||||
for line in path.read_text().splitlines():
|
||||
if line.startswith('v '):vertices.append(list(map(float,line.split()[1:])))
|
||||
if line.startswith('f '):faces.append([int(s.split('/')[0])-1 for s in line.split()[1:]])
|
||||
vertices=np.array(vertices)*np.fromstring(mesh.findtext('scale','1 1 1'),sep=' ')
|
||||
shape=('mesh',vertices[np.array(faces)])
|
||||
else:raise ValueError('unhandled scene geometry')
|
||||
result.append((p[:3],R,*shape))
|
||||
return result
|
||||
|
||||
|
||||
def ray_ranges(origins,directions,shapes):
|
||||
best=np.full(len(origins),np.inf)
|
||||
for center,R,kind,value in shapes:
|
||||
o=(origins-center)@R;d=directions@R
|
||||
if kind=='box':
|
||||
safe=np.where(np.abs(d)>1e-12,d,1e-12)
|
||||
a=(-value-o)/safe;b=(value-o)/safe
|
||||
enter=np.max(np.minimum(a,b),axis=1);leave=np.min(np.maximum(a,b),axis=1)
|
||||
hit=np.where((leave>=np.maximum(enter,0))&(enter>0),enter,np.inf)
|
||||
elif kind=='cylinder':
|
||||
radius,height=value
|
||||
A=np.sum(d[:,:2]**2,axis=1);B=2*np.sum(o[:,:2]*d[:,:2],axis=1)
|
||||
C=np.sum(o[:,:2]**2,axis=1)-radius**2;disc=B*B-4*A*C
|
||||
hit=np.full(len(o),np.inf)
|
||||
for sign in (-1,1):
|
||||
t=(-B+sign*np.sqrt(np.maximum(disc,0)))/np.maximum(2*A,1e-20)
|
||||
good=(disc>=0)&(t>0)&(np.abs(o[:,2]+t*d[:,2])<=height)
|
||||
hit=np.minimum(hit,np.where(good,t,np.inf))
|
||||
for z in (-height,height):
|
||||
t=(z-o[:,2])/np.where(np.abs(d[:,2])>1e-12,d[:,2],1e-12)
|
||||
xy=o[:,:2]+t[:,None]*d[:,:2]
|
||||
hit=np.minimum(hit,np.where((t>0)&(np.sum(xy**2,axis=1)<=radius**2),t,np.inf))
|
||||
else:
|
||||
hit=np.full(len(o),np.inf)
|
||||
for a,b,c in value:
|
||||
e1,e2=b-a,c-a;h=np.cross(d,e2);det=h@e1
|
||||
safe=np.where(np.abs(det)>1e-12,det,1e-12);s=o-a
|
||||
u=np.sum(s*h,axis=1)/safe;q=np.cross(s,e1);v=np.sum(d*q,axis=1)/safe
|
||||
t=q@e2/safe
|
||||
good=(np.abs(det)>1e-12)&(u>=0)&(v>=0)&(u+v<=1)&(t>0)
|
||||
hit=np.minimum(hit,np.where(good,t,np.inf))
|
||||
best=np.minimum(best,hit)
|
||||
return best
|
||||
|
||||
|
||||
class SensorProbe(SlopeProbe):
|
||||
def __init__(self):
|
||||
super().__init__();self.frames=[];self.imus=[];self.sensor_status=[]
|
||||
self.create_subscription(CustomMsg,'/sim/mid360/lidar',self.on_frame,qos_profile_sensor_data)
|
||||
self.create_subscription(Imu,'/sim/mid360/imu',self.on_imu,qos_profile_sensor_data)
|
||||
self.create_subscription(String,'/sim/mid360/status',lambda m:self.sensor_status.append(json.loads(m.data)),10)
|
||||
|
||||
def on_frame(self,m):
|
||||
self.frames.append(dict(t=m.header.stamp.sec+m.header.stamp.nanosec*1e-9,
|
||||
timebase=int(m.timebase),frame=m.header.frame_id,point_num=m.point_num,
|
||||
xyz=np.array([[p.x,p.y,p.z] for p in m.points]),
|
||||
offsets=np.array([p.offset_time for p in m.points],dtype=np.uint32),
|
||||
line=np.array([p.line for p in m.points],dtype=np.uint8),
|
||||
tag=np.array([p.tag for p in m.points],dtype=np.uint8)))
|
||||
|
||||
def on_imu(self,m):
|
||||
a=m.linear_acceleration;w=m.angular_velocity
|
||||
self.imus.append(dict(t=m.header.stamp.sec+m.header.stamp.nanosec*1e-9,frame=m.header.frame_id,
|
||||
acc=[a.x,a.y,a.z],gyro=[w.x,w.y,w.z],orientation_covariance_0=m.orientation_covariance[0]))
|
||||
|
||||
|
||||
def phase(p,cmd,duration):
|
||||
t0=p.now();states=[p.get_state()];nxt=t0
|
||||
def sample():
|
||||
nonlocal nxt
|
||||
if p.now()<nxt:return
|
||||
s=p.get_state()
|
||||
if s is None:raise RuntimeError('missing independent Gazebo state')
|
||||
states.append(s);nxt=p.now()+.025
|
||||
p.hold(*cmd,duration,sampler=sample)
|
||||
states.append(p.get_state())
|
||||
if any(s is None for s in states):raise RuntimeError('invalid truth sample')
|
||||
return dict(t0=t0,t1=p.now(),states=states)
|
||||
|
||||
|
||||
def geometry_check(p,record,shapes,out,name):
|
||||
states=record['states'];frames=[f for f in p.frames if f['t']>states[0]['stamp']+.15 and f['t']+.1<states[-1]['stamp']-.05]
|
||||
if len(frames)<4:raise RuntimeError('insufficient complete sensor frames')
|
||||
errors=[];instant_errors=[];saved={}
|
||||
for i,f in enumerate(frames[::max(1,len(frames)//6)]):
|
||||
idx=np.arange(0,len(f['xyz']),max(1,len(f['xyz'])//600))
|
||||
xyz=f['xyz'][idx];ranges=np.linalg.norm(xyz,axis=1);direction=xyz/ranges[:,None]
|
||||
times=f['t']+f['offsets'][idx]*1e-9
|
||||
pos,q=interpolate(states,times)
|
||||
origins=pos+rotate(q,np.broadcast_to(MOUNT,pos.shape));directions=rotate(q,direction)
|
||||
expected=ray_ranges(origins,directions,shapes)
|
||||
errors.extend(np.abs(expected-ranges).tolist())
|
||||
end_pos,end_q=interpolate(states,np.full(len(xyz),f['t']+.099))
|
||||
wrong=ray_ranges(end_pos+rotate(end_q,np.broadcast_to(MOUNT,end_pos.shape)),rotate(end_q,direction),shapes)
|
||||
instant_errors.extend(np.abs(wrong-ranges).tolist())
|
||||
saved[str(i)+'_xyz']=f['xyz'];saved[str(i)+'_offset_ns']=f['offsets']
|
||||
saved[str(i)+'_query_t']=times;saved[str(i)+'_expected_range']=expected
|
||||
np.savez_compressed(out/(name+'_clouds.npz'),**saved)
|
||||
finite=np.isfinite(errors)
|
||||
# At object silhouettes a tiny interpolation error may change occlusion.
|
||||
# Check the distribution and retain all errors instead of removing them.
|
||||
e=np.asarray(errors);wrong=np.asarray(instant_errors)
|
||||
return dict(samples=len(e),finite_fraction=float(np.mean(finite)),
|
||||
p95_range_error_m=float(np.quantile(e,.95)),p99_range_error_m=float(np.quantile(e,.99)),
|
||||
instantaneous_p95_error_m=float(np.quantile(wrong,.95)),
|
||||
ok=bool(np.mean(finite)>.98 and np.quantile(e,.95)<.005 and np.quantile(e,.99)<.02))
|
||||
|
||||
|
||||
def main():
|
||||
ap=argparse.ArgumentParser();ap.add_argument('--out',required=True)
|
||||
ap.add_argument('--case',choices=('flat','slope'),default='flat');args=ap.parse_args()
|
||||
out=Path(args.out).resolve();out.mkdir(parents=True,exist_ok=True)
|
||||
os.environ.update(sim_env());os.environ['ROS_LOG_DIR']=str(out/'ros')
|
||||
sim,p=Sim(str(out/'sim')),None
|
||||
source=Path(__file__).read_bytes();(out/'collector_snapshot.py').write_bytes(source)
|
||||
result=dict(status='INVALID',case=args.case,checks={},collector_sha256=hashlib.sha256(source).hexdigest())
|
||||
wall=time.monotonic()
|
||||
try:
|
||||
spawn=(1.4,3.5125,.6,0.) if args.case=='slope' else (-4.5,4.5,.17,0.)
|
||||
ok,why=sim.start(lidar=True,drive='contact',sensor_model='mid360',spawn=spawn)
|
||||
result['startup']=why
|
||||
if not ok:raise RuntimeError(why)
|
||||
rclpy.init();p=SensorProbe()
|
||||
if not p.wait_clock():raise RuntimeError('no clock')
|
||||
p.pump(1.5)
|
||||
if len(p.frames)<5 or len(p.imus)<100:raise RuntimeError('missing lidar or IMU stream')
|
||||
records={};shapes=scene_shapes()
|
||||
records['stationary']=phase(p,(0.,0.,0.),2.)
|
||||
for name,cmd,duration in ([] if args.case=='slope' else [
|
||||
('forward',(.3,0.,0.),2.5),('lateral',(0.,-.2,0.),1.5),('turn',(0.,0.,.3),2.)]):
|
||||
records[name]=phase(p,cmd,duration)
|
||||
records['stop']=phase(p,(0.,0.,0.),.5)
|
||||
# Finish live collection before CPU-heavy offline ray intersections.
|
||||
# Otherwise the probe's own analysis can overflow its IMU receive queue.
|
||||
if args.case=='flat':
|
||||
if not p.set_state(-4.5,4.5,1.2,0.):raise RuntimeError('drop set failed')
|
||||
drop=phase(p,(.3,0.,0.),.23)
|
||||
free=[m for m in p.imus if drop['t0']+.04<m['t']<drop['t1']-.02]
|
||||
result['free_fall']=dict(samples=free,truth=drop)
|
||||
geometry={}
|
||||
for name in records:
|
||||
if name!='stop':geometry[name]=geometry_check(p,records[name],shapes,out,name)
|
||||
frames=[f for f in p.frames if records['stationary']['t0']<=f['t']<records['stop']['t1']-.1]
|
||||
checks=result['checks']
|
||||
checks['geometry']=all(g['ok'] for g in geometry.values())
|
||||
checks['frame_and_count']=all(f['frame']=='lidar' and f['point_num']==len(f['xyz']) and len(f['xyz'])>500 for f in frames)
|
||||
checks['finite_fov']=all(np.isfinite(f['xyz']).all() and np.min(np.arctan2(f['xyz'][:,2],np.linalg.norm(f['xyz'][:,:2],axis=1)))>=math.radians(-7)-1e-6 and np.max(np.arctan2(f['xyz'][:,2],np.linalg.norm(f['xyz'][:,:2],axis=1)))<=math.radians(52)+1e-6 for f in frames)
|
||||
checks['timebase']=all(abs(f['t']*1e9-f['timebase'])<1 for f in frames)
|
||||
checks['actual_batch_times']=all(np.min(f['offsets'])>=0 and np.max(f['offsets'])<100000000 and len(np.unique(f['offsets']))>50 and np.all(f['offsets']%1000000==0) and np.all(np.diff(f['offsets'].astype(np.int64))>=0) for f in frames)
|
||||
checks['frame_rate']=len(frames)>5 and np.max(np.abs(np.diff([f['t'] for f in frames])-.1))<1e-6
|
||||
checks['livox_flags']=all(np.max(f['line'])<4 and np.all(f['tag']==0x10) for f in frames)
|
||||
checks['ray_budget']=len(p.sensor_status)>5 and all(s['rays']==20000 and s['last_sample_ns']-s['first_sample_ns']==99000000 for s in p.sensor_status)
|
||||
checks['pattern_continues']=not np.allclose(frames[0]['xyz'][:100],frames[1]['xyz'][:100])
|
||||
st=records['stationary'];imu=[m for m in p.imus if st['t0']+.2<m['t']<st['t1']]
|
||||
if len(imu)<100:raise RuntimeError('too few stationary IMUs')
|
||||
pos,q=interpolate(st['states'],np.array([m['t'] for m in imu]));inverse=q.copy();inverse[:,:3]*=-1
|
||||
expected=rotate(inverse,np.broadcast_to([0,0,9.8],pos.shape))
|
||||
acc=np.array([m['acc'] for m in imu]);gyro=np.array([m['gyro'] for m in imu])
|
||||
stationary_error=np.linalg.norm(acc-expected,axis=1)
|
||||
checks['imu_specific_force']=bool(np.quantile(stationary_error,.95)<.05 and np.max(np.linalg.norm(gyro,axis=1))<.01)
|
||||
checks['imu_frame_rate']=all(m['frame']=='mid360_imu' for m in imu) and abs(1/np.median(np.diff([m['t'] for m in imu]))-200)<2
|
||||
checks['no_attitude_oracle']=all(m['orientation_covariance_0']==-1. for m in p.imus)
|
||||
measured_imu=[m for m in p.imus if st['t0']<=m['t']<=records['stop']['t1']]
|
||||
imu_times=np.array([m['t'] for m in measured_imu]);imu_intervals=np.diff(imu_times)
|
||||
imu_rate=(len(imu_times)-1)/(imu_times[-1]-imu_times[0])
|
||||
checks['imu_continuity']=bool(abs(imu_rate-200)<2 and np.min(imu_intervals)>0 and np.max(imu_intervals)<.02)
|
||||
if args.case=='flat':
|
||||
tr=records['turn'];moving=[m for m in p.imus if tr['t0']+.3<m['t']<tr['t1']-.1]
|
||||
checks['gyro_motion']=len(moving)>100 and abs(np.median([m['gyro'][2] for m in moving])-.3)<.02
|
||||
checks['real_scan_distortion']=max(geometry[n]['instantaneous_p95_error_m'] for n in ('forward','turn'))>.015
|
||||
checks['free_fall_imu']=len(free)>20 and np.quantile([np.linalg.norm(m['acc']) for m in free],.95)<.05
|
||||
else:
|
||||
checks['slope_physically_tilted']=abs(np.median([s['rpy'][1] for s in st['states']])-math.atan2(.597,3.5))<.02
|
||||
result.update(geometry=geometry,records=records,imus=p.imus,sensor_status=p.sensor_status,
|
||||
stationary_imu_p95_error_m_s2=float(np.quantile(stationary_error,.95)),
|
||||
stationary_imu_mean=np.mean(acc,axis=0).tolist(),frame_returns=[len(f['xyz']) for f in frames],
|
||||
measured_imu_rate_hz=float(imu_rate),maximum_imu_interval_s=float(np.max(imu_intervals)),
|
||||
sim_duration_s=p.now()-records['stationary']['t0'],wall_duration_s=time.monotonic()-wall)
|
||||
result['status']='PASS' if all(checks.values()) else 'FAIL'
|
||||
print(json.dumps(dict(status=result['status'],checks=checks,geometry=geometry),indent=2,default=json_value),flush=True)
|
||||
except Exception as exc:
|
||||
result['status']='INVALID';result['error']=repr(exc);print(result['error'],flush=True)
|
||||
finally:
|
||||
if p is not None:p.send(0.,0.,0.);p.destroy_node()
|
||||
if rclpy.ok():rclpy.shutdown()
|
||||
result['teardown']=sim.stop()
|
||||
(out/'result.json').write_text(json.dumps(result,indent=2,default=json_value)+'\n')
|
||||
return {'PASS':0,'FAIL':30,'INVALID':40}[result['status']]
|
||||
|
||||
|
||||
if __name__=='__main__':sys.exit(main())
|
||||
@@ -0,0 +1,188 @@
|
||||
#!/usr/bin/python3
|
||||
"""P5 flat-ground corridor acceptance and unsupported-terrain rejection.
|
||||
|
||||
Each case owns a fresh simulator. Temporary corridor geometry is independent of
|
||||
the production field. No drive or stop command is injected during measurements.
|
||||
"""
|
||||
import argparse
|
||||
import hashlib
|
||||
import json
|
||||
import math
|
||||
import os
|
||||
from pathlib import Path
|
||||
import sys
|
||||
import time
|
||||
|
||||
import numpy as np
|
||||
import rclpy
|
||||
from gazebo_msgs.srv import GetEntityState, SpawnEntity
|
||||
from geometry_msgs.msg import PoseStamped
|
||||
|
||||
from check_omni_robot import Sim, sim_env
|
||||
from check_scan_navigation import NavProbe, run_goal
|
||||
from check_sim_lidar import points
|
||||
|
||||
|
||||
def spawn_corridor(p, width, out):
|
||||
poses = []
|
||||
for side, sign in (('left', -1), ('right', 1)):
|
||||
name = 'p5_wall_'+side
|
||||
req = SpawnEntity.Request()
|
||||
req.name, req.reference_frame = name, 'world'
|
||||
req.initial_pose.position.x = -4.5 + sign*(width/2+.05)
|
||||
req.initial_pose.position.y = 3.25
|
||||
req.initial_pose.position.z = .3
|
||||
req.initial_pose.orientation.w = 1.
|
||||
req.xml = '''<sdf version="1.6"><model name="%s"><static>true</static><link name="wall">
|
||||
<collision name="wall"><geometry><box><size>0.1 1.5 0.6</size></box></geometry></collision>
|
||||
<visual name="wall"><geometry><box><size>0.1 1.5 0.6</size></box></geometry></visual>
|
||||
</link></model></sdf>''' % name
|
||||
(out/(name+'.sdf')).write_text(req.xml)
|
||||
res = p._call(p.spawn, req, timeout=15)
|
||||
if not res or not res.success:
|
||||
raise RuntimeError('wall spawn failed: %r' % res)
|
||||
query = GetEntityState.Request()
|
||||
query.name, query.reference_frame = name, 'world'
|
||||
actual = p._call(p.cli_get, query)
|
||||
if not actual or not actual.success:
|
||||
raise RuntimeError('wall truth unavailable')
|
||||
pose = actual.state.pose.position
|
||||
poses.append([pose.x, pose.y, pose.z])
|
||||
measured = poses[1][0]-poses[0][0]-.1
|
||||
if abs(measured-width) > 1e-6:
|
||||
raise RuntimeError('corridor width differs from specification')
|
||||
return dict(nominal_width_m=width, measured_width_m=measured, wall_centers=poses,
|
||||
wall_size_m=[.1, 1.5, .6], y_extent_m=[2.5, 4.])
|
||||
|
||||
|
||||
def run_rejection(p, goal):
|
||||
first = p.get_state()
|
||||
if first is None:
|
||||
raise RuntimeError('no initial independent truth')
|
||||
old_id = p.status[-1].goal_id if p.status else 0
|
||||
first_cmd, first_status = len(p.commands), len(p.status)
|
||||
m = PoseStamped()
|
||||
m.header.frame_id = 'world'
|
||||
m.header.stamp = p.get_clock().now().to_msg()
|
||||
m.pose.position.x, m.pose.position.y, m.pose.position.z = goal[0], goal[1], .15
|
||||
m.pose.orientation.w = 1.
|
||||
p.goal_pub.publish(m)
|
||||
t0, end = p.now(), time.monotonic()+120
|
||||
samples = []
|
||||
while p.now()-t0 < 13. and time.monotonic() < end:
|
||||
p.pump(.1)
|
||||
s = p.get_state()
|
||||
if s is None:
|
||||
raise RuntimeError('missing truth during rejection')
|
||||
samples.append(s)
|
||||
status = p.status[-1]
|
||||
if status.goal_id > old_id and status.state in (status.SUCCEEDED, status.FAILED):
|
||||
break
|
||||
p.pump(1.1)
|
||||
final = p.get_state()
|
||||
if final is None or not samples:
|
||||
raise RuntimeError('missing final truth')
|
||||
samples.append(final)
|
||||
statuses, cmds = p.status[first_status:], p.commands[first_cmd:]
|
||||
drift = max(math.hypot(s['pos'][0]-first['pos'][0], s['pos'][1]-first['pos'][1]) for s in samples)
|
||||
status = p.status[-1]
|
||||
checks = dict(acknowledged=any(s.goal_id > old_id for s in statuses),
|
||||
failed_as_expected=status.goal_id > old_id and status.state == status.FAILED,
|
||||
never_active=not any(s.state == s.ACTIVE for s in statuses),
|
||||
fresh_perception=p.ready,
|
||||
stopped=drift < .02 and max(math.hypot(*s['twist_world'][:2]) for s in samples) < .01,
|
||||
zero_commands=len(cmds) > 10 and all(max(abs(c[k]) for k in ('vx','vy','wz')) < 1e-6 for c in cmds),
|
||||
original_goal_preserved=abs(status.goal.x-goal[0]) < 1e-6 and abs(status.goal.y-goal[1]) < 1e-6)
|
||||
return dict(goal=goal, checks=checks, ok=all(checks.values()), drift_m=drift,
|
||||
samples=samples, commands=cmds,
|
||||
statuses=[dict(state=s.state, goal_id=s.goal_id, reason=s.reason) for s in statuses])
|
||||
|
||||
|
||||
def run_case(name, out):
|
||||
out.mkdir(parents=True, exist_ok=True)
|
||||
os.environ.update(sim_env())
|
||||
os.environ['ROS_LOG_DIR'] = str(out/'ros')
|
||||
sim, p = Sim(str(out/'sim')), None
|
||||
report = dict(case=name, status='INVALID')
|
||||
try:
|
||||
spawn = (2.2, 4.65, .15, 0.) if name == 'ramp_entry_rejected' else (
|
||||
(-4.5, 4.5, .15, math.pi/2) if name == 'corridor_120_yaw90' else None)
|
||||
ok, why = sim.start(navigation=True, spawn=spawn)
|
||||
report['startup'] = why
|
||||
if not ok:
|
||||
raise RuntimeError(why)
|
||||
rclpy.init()
|
||||
p = NavProbe()
|
||||
if not p.wait_clock():
|
||||
raise RuntimeError('no clock')
|
||||
deadline = time.monotonic()+90
|
||||
while time.monotonic() < deadline:
|
||||
rclpy.spin_once(p, timeout_sec=.02)
|
||||
if p.ready and p.status and p.goal_pub.get_subscription_count() >= 2:
|
||||
break
|
||||
else:
|
||||
raise RuntimeError('SCAN not ready')
|
||||
if name.startswith('corridor'):
|
||||
width = 1.2 if name.startswith('corridor_120') else .95
|
||||
report['geometry'] = spawn_corridor(p, width, out)
|
||||
p.pump(2.)
|
||||
if name.startswith('corridor_120'):
|
||||
yaw = math.pi/2 if name.endswith('yaw90') else 0.
|
||||
result = run_goal(p, name, -4.5, 1.8, yaw, timeout=25.)
|
||||
inside = [s for s in result['samples'] if
|
||||
2.5 <= s['pos'][1]+.4 and s['pos'][1]-.4 <= 4.]
|
||||
clearance = min(.6 - abs(s['pos'][0]+4.5) -
|
||||
.4*(abs(math.cos(s['yaw']))+abs(math.sin(s['yaw']))) for s in inside) if inside else None
|
||||
result['min_wall_clearance_m'] = clearance
|
||||
result['checks']['crossed_channel'] = bool(inside) and min(s['pos'][1] for s in inside) < 2.5
|
||||
result['checks']['physical_clearance'] = clearance is not None and clearance >= .03
|
||||
result['checks']['heading_held'] = max(abs(math.atan2(math.sin(s['yaw']-yaw),
|
||||
math.cos(s['yaw']-yaw))) for s in result['samples']) <= .01
|
||||
axis = 'vx' if name.endswith('yaw90') else 'vy'
|
||||
result['checks']['expected_body_axis'] = any(abs(c[axis]) > .05 for c in result['commands'])
|
||||
else:
|
||||
goal = {'corridor_095': (-4.5, 3.25), 'stairs_rejected': (-2.5, 3.5),
|
||||
'ramp_entry_rejected': (2., 3.5)}[name]
|
||||
result = run_rejection(p, goal)
|
||||
result['ok'] = all(result['checks'].values())
|
||||
report['result'] = result
|
||||
report['status'] = 'PASS' if result['ok'] else 'FAIL'
|
||||
# Preserve input geometry evidence for auditing rejection vs data loss.
|
||||
clouds = {topic: points(msg) for topic, msg in p.clouds.items()}
|
||||
np.savez_compressed(out/'map_evidence.npz', **clouds)
|
||||
print(name, report['status'], result['checks'], flush=True)
|
||||
except Exception as exc:
|
||||
report['error'] = repr(exc)
|
||||
print(name, report['error'], flush=True)
|
||||
finally:
|
||||
if p is not None:
|
||||
p.send(0., 0., 0.)
|
||||
p.destroy_node()
|
||||
if rclpy.ok():
|
||||
rclpy.shutdown()
|
||||
report['teardown'] = sim.stop()
|
||||
(out/'result.json').write_text(json.dumps(report, indent=2)+'\n')
|
||||
return report
|
||||
|
||||
|
||||
def main():
|
||||
ap = argparse.ArgumentParser()
|
||||
ap.add_argument('--out', required=True)
|
||||
names = ('corridor_120', 'corridor_120_yaw90', 'corridor_095', 'stairs_rejected', 'ramp_entry_rejected')
|
||||
ap.add_argument('--case', choices=names)
|
||||
args = ap.parse_args()
|
||||
out = Path(args.out).resolve()
|
||||
out.mkdir(parents=True, exist_ok=True)
|
||||
source = Path(__file__).read_bytes()
|
||||
(out/'collector_snapshot.py').write_bytes(source)
|
||||
reports = [run_case(name, out/name) for name in (names if args.case is None else [args.case])]
|
||||
status = 'INVALID' if any(r['status'] == 'INVALID' for r in reports) else (
|
||||
'FAIL' if any(r['status'] == 'FAIL' for r in reports) else 'PASS')
|
||||
summary = dict(status=status, collector_sha256=hashlib.sha256(source).hexdigest(),
|
||||
cases=[dict(case=r['case'], status=r['status']) for r in reports])
|
||||
(out/'result.json').write_text(json.dumps(summary, indent=2)+'\n')
|
||||
return {'PASS': 0, 'FAIL': 30, 'INVALID': 40}[status]
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(main())
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,132 @@
|
||||
#!/usr/bin/python3
|
||||
"""Evaluate existing Point-LIO with one fixed initial SE3 alignment; no truth feedback."""
|
||||
import argparse
|
||||
import hashlib
|
||||
import json
|
||||
import math
|
||||
import os
|
||||
from pathlib import Path
|
||||
import subprocess
|
||||
import sys
|
||||
import time
|
||||
|
||||
import numpy as np
|
||||
import rclpy
|
||||
from nav_msgs.msg import Odometry
|
||||
from check_omni_robot import Sim,sim_env
|
||||
from check_mid360 import SensorProbe,phase,interpolate,rotate,json_value
|
||||
|
||||
IMU_OFFSET=np.array([.011,.02329,.25588])
|
||||
|
||||
|
||||
def matrix(q):
|
||||
return rotate(np.broadcast_to(q,(3,4)),np.eye(3)).T
|
||||
|
||||
|
||||
class LioProbe(SensorProbe):
|
||||
def __init__(self):
|
||||
super().__init__();self.estimates=[]
|
||||
self.create_subscription(Odometry,'/sim/lio/aft_mapped_to_init',self.on_estimate,100)
|
||||
|
||||
def on_estimate(self,m):
|
||||
p=m.pose.pose.position;q=m.pose.pose.orientation;v=m.twist.twist.linear
|
||||
self.estimates.append(dict(t=m.header.stamp.sec+m.header.stamp.nanosec*1e-9,
|
||||
frame=m.header.frame_id,child=m.child_frame_id,pos=[p.x,p.y,p.z],
|
||||
q=[q.x,q.y,q.z,q.w],body_velocity=[v.x,v.y,v.z],received_sim=self.now()))
|
||||
|
||||
|
||||
def main():
|
||||
ap=argparse.ArgumentParser();ap.add_argument('--out',required=True)
|
||||
ap.add_argument('--case',choices=('flat','slope'),default='flat');args=ap.parse_args()
|
||||
out=Path(args.out).resolve();out.mkdir(parents=True,exist_ok=True)
|
||||
os.environ.update(sim_env());os.environ['ROS_LOG_DIR']=str(out/'ros')
|
||||
source=Path(__file__).read_bytes();(out/'collector_snapshot.py').write_bytes(source)
|
||||
result=dict(status='INVALID',case=args.case,checks={},collector_sha256=hashlib.sha256(source).hexdigest())
|
||||
sim,p=Sim(str(out/'sim')),None
|
||||
try:
|
||||
spawn=(3.5,3.5125,.15,0.) if args.case=='slope' else (-4.5,4.5,.15,0.)
|
||||
ok,why=sim.start(localization=True,spawn=spawn);result['startup']=why
|
||||
if not ok:raise RuntimeError(why)
|
||||
rclpy.init();p=LioProbe()
|
||||
if not p.wait_clock():raise RuntimeError('missing clock')
|
||||
deadline=time.monotonic()+60
|
||||
while time.monotonic()<deadline:
|
||||
rclpy.spin_once(p,timeout_sec=.02)
|
||||
if len(p.frames)>=10 and len(p.imus)>=100 and p.get_state() is not None:break
|
||||
else:raise RuntimeError('model/sensors not ready')
|
||||
# CLI discovery may take wall time; perform it before the measured truth
|
||||
# interval, so it cannot create an unobserved hole in the trajectory.
|
||||
for name,cmd in [('node_info',['ros2','node','info','/sim/lio/point_lio_sim']),
|
||||
('parameters',['ros2','param','dump','/sim/lio/point_lio_sim'])]:
|
||||
r=subprocess.run(cmd,capture_output=True,text=True,timeout=30)
|
||||
(out/(name+'.txt')).write_text(r.stdout+r.stderr)
|
||||
if r.returncode:raise RuntimeError(name+' unavailable')
|
||||
initial=phase(p,(0.,0.,0.),4.)
|
||||
if len(p.estimates)<100:raise RuntimeError('Point-LIO output missing or startup incomplete')
|
||||
init_est=p.estimates[-1]
|
||||
pos,q=interpolate(initial['states'],np.array([init_est['t']]))
|
||||
R=matrix(q[0])@matrix(np.array(init_est['q'])).T
|
||||
truth_imu=pos[0]+rotate(q,IMU_OFFSET[None,:])[0]
|
||||
translation=truth_imu-R@np.array(init_est['pos'])
|
||||
result['alignment']=dict(stamp=init_est['t'],rotation=R.tolist(),translation=translation.tolist(),
|
||||
method='one initial stationary IMU pose; fixed for entire route; evaluator only')
|
||||
records={}
|
||||
motions=([('up_first',(-.25,0.,0.),10.),('hill_stop',(0.,0.,0.),2.),
|
||||
('up_second',(-.25,0.,0.),8.8),('top_stop',(0.,0.,0.),1.5),
|
||||
('down',(.25,0.,0.),18.8),('final_stop',(0.,0.,0.),1.5)] if args.case=='slope' else
|
||||
[('forward',(.2,0.,0.),2.5),('lateral',(0.,-.2,0.),2.),
|
||||
('turn',(0.,0.,.3),2.),
|
||||
('return_x',(-.2*math.cos(.6),.2*math.sin(.6),0.),2.5),
|
||||
('return_y',(.2*math.sin(.6),.2*math.cos(.6),0.),2.),
|
||||
('turn_back',(0.,0.,-.3),2.),('final_stop',(0.,0.,0.),1.5)])
|
||||
for name,cmd,duration in motions:
|
||||
records[name]=phase(p,cmd,duration)
|
||||
(out/(name+'_truth.json')).write_text(json.dumps(records[name],indent=2)+'\n')
|
||||
print(name,records[name]['states'][-1]['pos'],'estimates',len(p.estimates),flush=True)
|
||||
truth=initial['states']+[s for record in records.values() for s in record['states']]
|
||||
estimates=[e for e in p.estimates if init_est['t']<=e['t']<=truth[-1]['stamp']]
|
||||
if len(estimates)<100:raise RuntimeError('insufficient estimates in truth interval')
|
||||
pos,q=interpolate(truth,np.array([e['t'] for e in estimates]))
|
||||
expected=pos+rotate(q,np.broadcast_to(IMU_OFFSET,pos.shape))
|
||||
predicted=np.array([R@np.array(e['pos'])+translation for e in estimates])
|
||||
position_error=np.linalg.norm(predicted-expected,axis=1)
|
||||
angle_error=np.array([math.acos(np.clip((np.trace(matrix(tq).T@R@matrix(np.array(e['q'])))-1)/2,-1,1)) for tq,e in zip(q,estimates)])
|
||||
estimates_t=np.array([e['t'] for e in estimates]);lags=np.array([e['received_sim']-e['t'] for e in estimates])
|
||||
graph=(out/'node_info.txt').read_text();subscribers=graph.split('Subscribers:')[1].split('Publishers:')[0]
|
||||
# A namespaced node's inputs must be sensors and clock, never truth odom/TF.
|
||||
checks=result['checks']
|
||||
checks.update(input_isolation='/sim/mid360/lidar:' in subscribers and '/sim/mid360/imu:' in subscribers and
|
||||
all(topic not in subscribers for topic in ('/odom:','/body_odom:','/tf:','/tf_static:')),
|
||||
estimated_tf_disabled=bool(p.tf_pairs) and set(p.tf_pairs)=={'odom->base_link'},
|
||||
frames=all(e['frame']=='camera_init' and e['child']=='body' for e in estimates),
|
||||
finite=bool(np.isfinite(predicted).all() and np.isfinite(angle_error).all()),
|
||||
position=bool(np.max(position_error)<.10),orientation=bool(np.max(angle_error)<.10),
|
||||
timestamps=bool(np.all(np.diff(estimates_t)>0) and np.max(np.diff(estimates_t))<.2),
|
||||
latency=bool(np.quantile(lags,.95)<.3 and np.max(lags)<1.0))
|
||||
if args.case=='slope':
|
||||
checks['physical_top_landing']=abs(records['top_stop']['states'][-1]['pos'][2]-.749)<.03
|
||||
checks['physical_return']=abs(records['final_stop']['states'][-1]['pos'][2]-.149)<.02
|
||||
else:
|
||||
checks['physical_excitation']=max(s['yaw'] for s in truth)-min(s['yaw'] for s in truth)>.5 and max(s['pos'][0] for s in truth)-min(s['pos'][0] for s in truth)>.4
|
||||
result.update(checks=checks,estimates=estimates,truth=truth,
|
||||
observed_tf_edges=p.tf_pairs,observed_static_tf_edges=p.tf_static_pairs,
|
||||
max_position_error_m=float(np.max(position_error)),p95_position_error_m=float(np.quantile(position_error,.95)),
|
||||
max_angle_error_rad=float(np.max(angle_error)),p95_lag_s=float(np.quantile(lags,.95)),
|
||||
max_lag_s=float(np.max(lags)),median_rate_hz=float(1/np.median(np.diff(estimates_t))),
|
||||
last_position_error_m=float(position_error[-1]))
|
||||
np.savez_compressed(out/'comparison.npz',times=estimates_t,expected=expected,predicted=predicted,
|
||||
position_error=position_error,angle_error=angle_error,lags=lags)
|
||||
result['status']='PASS' if all(checks.values()) else 'FAIL'
|
||||
print(json.dumps({k:v for k,v in result.items() if k not in ('truth','estimates')},indent=2,default=json_value),flush=True)
|
||||
except Exception as exc:
|
||||
result['status']='INVALID';result['error']=repr(exc);print(result['error'],flush=True)
|
||||
if p is not None:result['estimates']=p.estimates
|
||||
finally:
|
||||
if p is not None:p.send(0.,0.,0.);p.destroy_node()
|
||||
if rclpy.ok():rclpy.shutdown()
|
||||
result['teardown']=sim.stop()
|
||||
(out/'result.json').write_text(json.dumps(result,indent=2,default=json_value)+'\n')
|
||||
return {'PASS':0,'FAIL':30,'INVALID':40}[result['status']]
|
||||
|
||||
|
||||
if __name__=='__main__':sys.exit(main())
|
||||
@@ -0,0 +1,306 @@
|
||||
#!/usr/bin/python3
|
||||
"""Run existing SCAN/controller against Gazebo truth, never publish drive commands.
|
||||
|
||||
PASS requires a new goal to be acknowledged, ACTIVE and SUCCEEDED, physical
|
||||
arrival, and a full second stopped at the goal. Save every independent truth
|
||||
sample and observed command. A static test obstacle does not modify the map.
|
||||
"""
|
||||
import argparse
|
||||
import hashlib
|
||||
import json
|
||||
import math
|
||||
import os
|
||||
from pathlib import Path
|
||||
import signal
|
||||
import sys
|
||||
import time
|
||||
|
||||
import numpy as np
|
||||
import rclpy
|
||||
from gazebo_msgs.srv import SpawnEntity
|
||||
from geometry_msgs.msg import PoseStamped, Twist
|
||||
from rclpy.qos import QoSProfile, DurabilityPolicy, qos_profile_sensor_data
|
||||
from sensor_msgs.msg import PointCloud2
|
||||
from scan_planner_msgs.msg import TrajectoryStatus
|
||||
from std_msgs.msg import Bool
|
||||
|
||||
from check_omni_robot import Probe, Sim, sim_env
|
||||
from check_sim_lidar import points
|
||||
|
||||
|
||||
class NavProbe(Probe):
|
||||
def __init__(self, map_diagnostics=True):
|
||||
super().__init__()
|
||||
self.goal_pub = self.create_publisher(PoseStamped, '/move_base_simple/goal', 10)
|
||||
self.status = []
|
||||
self.commands = []
|
||||
self.ready = False
|
||||
self.clouds = {}
|
||||
topics = ['/cloud_registered_for_scan']
|
||||
if map_diagnostics:
|
||||
topics.extend(('/grid_map/occupancy', '/grid_map/occupancy_inflate'))
|
||||
for topic in topics:
|
||||
self.create_subscription(PointCloud2, topic,
|
||||
lambda m, topic=topic: self.clouds.update({topic: m}), qos_profile_sensor_data)
|
||||
self.create_subscription(TrajectoryStatus, '/planning/trajectory_status',
|
||||
self.status.append,
|
||||
QoSProfile(depth=1, durability=DurabilityPolicy.TRANSIENT_LOCAL))
|
||||
self.create_subscription(Twist, '/cmd_vel', self.on_cmd, 100)
|
||||
self.create_subscription(Bool, '/planning/perception_ready',
|
||||
lambda m: setattr(self, 'ready', m.data),
|
||||
QoSProfile(depth=1, durability=DurabilityPolicy.TRANSIENT_LOCAL))
|
||||
self.spawn = self.create_client(SpawnEntity, '/spawn_entity')
|
||||
|
||||
def on_cmd(self, m):
|
||||
self.commands.append(dict(t=self.now(), vx=m.linear.x, vy=m.linear.y, wz=m.angular.z))
|
||||
|
||||
def add_obstacle(self):
|
||||
req = SpawnEntity.Request()
|
||||
req.name = 'p4_test_box'
|
||||
req.reference_frame = 'world'
|
||||
req.initial_pose.position.x = -4.6
|
||||
req.initial_pose.position.y = 3.0
|
||||
req.initial_pose.position.z = .3
|
||||
req.initial_pose.orientation.w = 1.
|
||||
req.xml = '''<sdf version="1.6"><model name="p4_test_box"><static>true</static>
|
||||
<link name="box"><collision name="collision"><geometry><box><size>0.25 0.25 0.6</size></box></geometry></collision>
|
||||
<visual name="visual"><geometry><box><size>0.25 0.25 0.6</size></box></geometry></visual></link></model></sdf>'''
|
||||
res = self._call(self.spawn, req, timeout=15)
|
||||
if not res or not res.success:
|
||||
raise RuntimeError('test obstacle spawn failed: %s' % res)
|
||||
return req.xml
|
||||
|
||||
|
||||
def run_goal(p, name, x, y, yaw, timeout=55., obstacle=False, goal_z=None, settle_timeout=0., sample_hook=None):
|
||||
first = p.get_state()
|
||||
old_id = p.status[-1].goal_id if p.status else 0
|
||||
start_cmd = len(p.commands)
|
||||
start_status = len(p.status)
|
||||
m = PoseStamped()
|
||||
m.header.frame_id = 'world'
|
||||
m.header.stamp = p.get_clock().now().to_msg()
|
||||
m.pose.position.x, m.pose.position.y, m.pose.position.z = x, y, first['pos'][2] if goal_z is None else goal_z
|
||||
m.pose.orientation.z, m.pose.orientation.w = math.sin(yaw/2), math.cos(yaw/2)
|
||||
p.goal_pub.publish(m)
|
||||
t0, wall_end = p.now(), time.monotonic()+300
|
||||
samples = []
|
||||
while p.now()-t0 < timeout and time.monotonic() < wall_end:
|
||||
p.pump(.1)
|
||||
truth = p.get_state()
|
||||
if truth is None:
|
||||
raise RuntimeError('missing independent Gazebo truth')
|
||||
samples.append(truth)
|
||||
if sample_hook is not None:
|
||||
sample_hook(truth)
|
||||
s = p.status[-1] if p.status else None
|
||||
if s is not None and s.goal_id > old_id and s.state in (s.SUCCEEDED, s.FAILED):
|
||||
break
|
||||
# The optional force-drive protocol measures braking explicitly, then starts
|
||||
# the full stopped window. Legacy instantaneous-drive protocol is unchanged.
|
||||
braking=[];settle_latency=None;terminal_observed_time=p.now()
|
||||
terminal_status=p.status[-1] if p.status else None
|
||||
terminal_time=terminal_observed_time
|
||||
if terminal_status is not None and terminal_status.goal_id>old_id and terminal_status.state in (terminal_status.SUCCEEDED,terminal_status.FAILED):
|
||||
terminal_time=terminal_status.header.stamp.sec+terminal_status.header.stamp.nanosec*1e-9
|
||||
if settle_timeout>0:
|
||||
while p.now()-terminal_time<settle_timeout:
|
||||
p.pump(.005);state=p.get_state()
|
||||
if state is None:raise RuntimeError('truth missing during braking')
|
||||
braking.append(state)
|
||||
if math.hypot(*state['twist_world'][:2])<.01 and abs(state['wz'])<.02:
|
||||
settle_latency=state['stamp']-terminal_time;break
|
||||
# Observe the post-arrival behavior; do not inject a stop to make this pass.
|
||||
stop_start = p.now()
|
||||
stopped_samples = []
|
||||
while p.now()-stop_start < 1.1:
|
||||
p.pump(.1)
|
||||
stopped_samples.append(p.get_state())
|
||||
final = stopped_samples[-1]
|
||||
statuses = p.status[start_status:]
|
||||
cmds = p.commands[start_cmd:]
|
||||
err = math.hypot(final['pos'][0]-x, final['pos'][1]-y)
|
||||
yaw_err = abs(math.atan2(math.sin(final['yaw']-yaw), math.cos(final['yaw']-yaw)))
|
||||
speed = max(math.hypot(*s['twist_world'][:2]) for s in stopped_samples)
|
||||
drift = max(math.hypot(s['pos'][0]-final['pos'][0], s['pos'][1]-final['pos'][1])
|
||||
for s in stopped_samples)
|
||||
checks = dict(acknowledged=any(s.goal_id > old_id for s in statuses),
|
||||
active=any(s.goal_id > old_id and s.state == s.ACTIVE for s in statuses),
|
||||
succeeded=bool(statuses and statuses[-1].goal_id > old_id and
|
||||
statuses[-1].state == statuses[-1].SUCCEEDED),
|
||||
arrival=err < .10, yaw=yaw_err < .10,
|
||||
stopped=speed < .01 and drift < .02,
|
||||
commands_observed=len(cmds) > 10,
|
||||
moved=math.hypot(final['pos'][0]-first['pos'][0],
|
||||
final['pos'][1]-first['pos'][1]) > .3)
|
||||
if name == 'lateral':
|
||||
checks['lateral_command'] = any(abs(c['vy']) > .05 for c in cmds)
|
||||
if settle_timeout>0:
|
||||
checks['bounded_braking']=settle_latency is not None and 0<=settle_latency<=settle_timeout
|
||||
checks['stopped_rotation']=all(abs(s['wz'])<.02 for s in stopped_samples)
|
||||
if obstacle:
|
||||
# Square footprint at heading pi/2; use its enclosing AABB, including yaw drift.
|
||||
clearances = []
|
||||
for s in samples:
|
||||
extent = .4*(abs(math.cos(s['yaw']))+abs(math.sin(s['yaw'])))
|
||||
clearances.append(max(abs(s['pos'][0]+4.6)-.125-extent,
|
||||
abs(s['pos'][1]-3.)-.125-extent))
|
||||
checks['physical_clearance'] = min(clearances) > .015
|
||||
checks['detoured'] = max(s['pos'][0] for s in samples) > -3.95
|
||||
else:
|
||||
clearances = []
|
||||
cloud_diagnostics = {}
|
||||
for topic, msg in p.clouds.items():
|
||||
pc = points(msg)
|
||||
pc = pc[np.isfinite(pc).all(axis=1)]
|
||||
near = pc[(np.abs(pc[:, 0]-x) < .6) & (np.abs(pc[:, 1]-y) < .6) & (pc[:, 2] < .4)]
|
||||
cloud_diagnostics[topic] = dict(total=len(pc), near_goal=near.tolist())
|
||||
return dict(name=name, goal=[x, y, yaw], checks=checks, ok=all(checks.values()),
|
||||
cloud_diagnostics=cloud_diagnostics,
|
||||
position_error_m=err, yaw_error_rad=yaw_err, stopped_max_speed_m_s=speed,
|
||||
stopped_drift_m=drift, duration_sim_s=p.now()-t0,
|
||||
settle_latency_sim_s=settle_latency,braking_samples=braking,
|
||||
terminal_source_stamp=terminal_time,terminal_observed_stamp=terminal_observed_time,
|
||||
min_obstacle_clearance_m=min(clearances) if clearances else None,
|
||||
samples=samples, stop_samples=stopped_samples, commands=cmds,
|
||||
statuses=[dict(t=s.header.stamp.sec+s.header.stamp.nanosec*1e-9,
|
||||
goal_id=s.goal_id, state=s.state, reason=s.reason,
|
||||
traj_id=s.traj_id, is_final=s.is_final,
|
||||
goal=[s.goal.x, s.goal.y, s.goal.z]) for s in statuses])
|
||||
|
||||
|
||||
def run_data_loss(p, sim):
|
||||
"""Suspend only our adapter while the real controller is moving; no injected stop."""
|
||||
m = PoseStamped()
|
||||
m.header.frame_id = 'world'
|
||||
m.header.stamp = p.get_clock().now().to_msg()
|
||||
m.pose.position.x, m.pose.position.y = -3.6, 4.5
|
||||
m.pose.orientation.w = 1.
|
||||
p.goal_pub.publish(m)
|
||||
deadline = time.monotonic()+60
|
||||
while time.monotonic() < deadline:
|
||||
p.pump(.05)
|
||||
truth = p.get_state()
|
||||
if truth and math.hypot(*truth['twist_world'][:2]) > .1:
|
||||
break
|
||||
else:
|
||||
raise RuntimeError('data-loss test never reached moving state')
|
||||
owned = []
|
||||
for pid in sim.known:
|
||||
try:
|
||||
if b'/sim_data_adapter.py' in Path('/proc/%d/cmdline' % pid).read_bytes():
|
||||
owned.append(pid)
|
||||
except FileNotFoundError:
|
||||
pass
|
||||
if len(owned) != 1:
|
||||
raise RuntimeError('cannot identify exactly one owned adapter: %r' % owned)
|
||||
pid = owned[0]
|
||||
samples, ready = [], []
|
||||
t0 = p.now()
|
||||
try:
|
||||
os.kill(pid, signal.SIGSTOP)
|
||||
while p.now()-t0 < 1.3:
|
||||
p.pump(.05)
|
||||
state = p.get_state()
|
||||
if state is None:
|
||||
raise RuntimeError('independent truth missing during data loss')
|
||||
samples.append(state)
|
||||
ready.append(dict(t=p.now(), ready=p.ready))
|
||||
finally:
|
||||
os.kill(pid, signal.SIGCONT)
|
||||
stop = next((s['stamp']-t0 for s in samples
|
||||
if math.hypot(*s['twist_world'][:2]) < .01 and abs(s['wz']) < .02), None)
|
||||
late = [s for s in samples if s['stamp']-t0 >= .7]
|
||||
drift = max(math.hypot(s['pos'][0]-late[0]['pos'][0], s['pos'][1]-late[0]['pos'][1])
|
||||
for s in late) if late else None
|
||||
checks = dict(initially_moving=True, readiness_revoked=any(not s['ready'] for s in ready),
|
||||
stopped_in_time=stop is not None and 0 <= stop <= .5,
|
||||
stayed_stopped=bool(late) and all(math.hypot(*s['twist_world'][:2]) < .01
|
||||
for s in late) and drift < .02)
|
||||
return dict(name='data_loss_stop', checks=checks, ok=all(checks.values()),
|
||||
owned_adapter_pid=pid, stop_latency_sim_s=stop, drift_m=drift,
|
||||
samples=samples, readiness=ready)
|
||||
|
||||
|
||||
def main():
|
||||
ap = argparse.ArgumentParser()
|
||||
ap.add_argument('--out', required=True)
|
||||
ap.add_argument('--no-map-diagnostics', action='store_true',
|
||||
help='Skip dense visualization maps; keep physical arrival/stop criteria unchanged')
|
||||
ap.add_argument('--settle-timeout', type=float, default=0.,
|
||||
help='Explicit bounded braking window before the full stopped interval (0 preserves legacy protocol)')
|
||||
group = ap.add_mutually_exclusive_group()
|
||||
group.add_argument('--straight-only', action='store_true')
|
||||
group.add_argument('--fault-only', action='store_true')
|
||||
args = ap.parse_args()
|
||||
if not math.isfinite(args.settle_timeout) or not 0<=args.settle_timeout<=.2:
|
||||
ap.error('--settle-timeout must be between 0 and 0.20 simulation seconds')
|
||||
out = Path(args.out).resolve()
|
||||
out.mkdir(parents=True, exist_ok=True)
|
||||
os.environ.update(sim_env())
|
||||
sim, p = Sim(str(out/'sim')), None
|
||||
source = Path(__file__).read_bytes()
|
||||
(out/'collector_snapshot.py').write_bytes(source)
|
||||
report = dict(status='INVALID', cases=[],
|
||||
collector_sha256_at_start=hashlib.sha256(source).hexdigest(),
|
||||
braking_window_sim_s=args.settle_timeout, map_diagnostics=not args.no_map_diagnostics)
|
||||
try:
|
||||
ok, why = sim.start(navigation=True)
|
||||
report['sim_start'] = why
|
||||
if not ok:
|
||||
raise RuntimeError(why)
|
||||
rclpy.init()
|
||||
p = NavProbe(map_diagnostics=not args.no_map_diagnostics)
|
||||
if not p.wait_clock():
|
||||
raise RuntimeError('no simulation clock')
|
||||
end = time.monotonic()+90
|
||||
while time.monotonic() < end:
|
||||
rclpy.spin_once(p, timeout_sec=.02)
|
||||
if p.ready and p.status and p.goal_pub.get_subscription_count() >= 2:
|
||||
break
|
||||
else:
|
||||
raise RuntimeError('navigation not ready')
|
||||
p.pump(1.)
|
||||
if args.fault_only:
|
||||
result = run_data_loss(p, sim)
|
||||
report['cases'].append(result)
|
||||
print(result['name'], result['checks'], flush=True)
|
||||
# Keep the 0.8 m footprint plus margin away from the stair edge at y=4.
|
||||
goals = [('straight', -3.6, 4.5, 0.), ('lateral', -3.6, 3.5, 0.),
|
||||
('return_and_turn', -4.5, 4.5, math.pi/2)]
|
||||
if args.straight_only:
|
||||
goals = goals[:1]
|
||||
if args.fault_only:
|
||||
goals = []
|
||||
for name, x, y, yaw in goals:
|
||||
result = run_goal(p, name, x, y, yaw, settle_timeout=args.settle_timeout)
|
||||
report['cases'].append(result)
|
||||
(out/(name+'.json')).write_text(json.dumps(result, indent=2)+'\n')
|
||||
print(name, result['checks'], 'error', result['position_error_m'], flush=True)
|
||||
if not result['ok']:
|
||||
break
|
||||
if not args.straight_only and not args.fault_only and all(c['ok'] for c in report['cases']) and len(report['cases']) == 3:
|
||||
(out/'test_obstacle.sdf').write_text(p.add_obstacle())
|
||||
p.pump(2.)
|
||||
result = run_goal(p, 'detour', -4.5, 1.5, math.pi/2, obstacle=True, settle_timeout=args.settle_timeout)
|
||||
report['cases'].append(result)
|
||||
(out/'detour.json').write_text(json.dumps(result, indent=2)+'\n')
|
||||
print('detour', result['checks'], 'error', result['position_error_m'], flush=True)
|
||||
expected = 1 if args.straight_only or args.fault_only else 4
|
||||
report['status'] = 'PASS' if len(report['cases']) == expected and all(
|
||||
c['ok'] for c in report['cases']) else 'FAIL'
|
||||
except Exception as exc:
|
||||
report['error'] = repr(exc)
|
||||
print(report['error'], flush=True)
|
||||
finally:
|
||||
if p is not None:
|
||||
p.send(0., 0., 0.) # Teardown only, after all measurements have been saved.
|
||||
p.destroy_node()
|
||||
if rclpy.ok():
|
||||
rclpy.shutdown()
|
||||
report['teardown'] = sim.stop()
|
||||
(out/'result.json').write_text(json.dumps(report, indent=2)+'\n')
|
||||
return {'PASS': 0, 'FAIL': 30, 'INVALID': 40}[report['status']]
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(main())
|
||||
@@ -0,0 +1,66 @@
|
||||
#!/usr/bin/python3
|
||||
"""Validate noise against independently interpolated physics; no fabricated time or IMU truth input."""
|
||||
import argparse,json,os,sys,time,hashlib
|
||||
from pathlib import Path
|
||||
import numpy as np
|
||||
import yaml
|
||||
import rclpy
|
||||
from check_omni_robot import Sim,sim_env
|
||||
from check_mid360 import SensorProbe,phase,interpolate,rotate,scene_shapes,ray_ranges,json_value
|
||||
|
||||
|
||||
def main():
|
||||
ap=argparse.ArgumentParser();ap.add_argument('--out',required=True);ap.add_argument('--profile',choices=('mild','stress'),default='stress');args=ap.parse_args()
|
||||
out=Path(args.out).resolve();out.mkdir(parents=True,exist_ok=True);os.environ.update(sim_env());os.environ['ROS_LOG_DIR']=str(out/'ros')
|
||||
config=Path(__file__).resolve().parents[1]/'src/r2027_robot_description/config/sensor_profiles.yaml'
|
||||
profile=yaml.safe_load(config.read_text())[args.profile]
|
||||
(out/'sensor_profiles.yaml').write_bytes(config.read_bytes());(out/'collector_snapshot.py').write_bytes(Path(__file__).read_bytes())
|
||||
report=dict(status='INVALID',profile=args.profile,parameters=profile);sim=Sim(str(out/'sim'));p=None
|
||||
try:
|
||||
ok,why=sim.start(lidar=True,drive='contact',sensor_model='mid360',sensor_profile=args.profile,spawn=(-4.5,4.5,.15,0.));report['startup']=why
|
||||
if not ok:raise RuntimeError(why)
|
||||
rclpy.init();p=SensorProbe()
|
||||
if not p.wait_clock():raise RuntimeError('no clock')
|
||||
p.pump(2.);stationary=phase(p,(0.,0.,0.),3.);moving=phase(p,(.2,0.,0.),2.);final=phase(p,(0.,0.,0.),1.)
|
||||
records=dict(stationary=stationary,moving=moving,final=final)
|
||||
(out/'physics.json').write_text(json.dumps(records,indent=2)+'\n')
|
||||
imus=[m for m in p.imus if stationary['t0']+.2<m['t']<stationary['t1']-.1]
|
||||
if len(imus)<400:raise RuntimeError('insufficient IMU samples')
|
||||
_,q=interpolate(stationary['states'],[m['t'] for m in imus]);q[:,:3]*=-1
|
||||
expected=rotate(q,np.tile([0.,0.,9.8],(len(q),1)))
|
||||
accel=np.array([m['acc'] for m in imus])-expected;gyro=np.array([m['gyro'] for m in imus])
|
||||
frames=[f for f in p.frames if moving['t0']+.15<f['t'] and f['t']+.1<moving['t1']-.1]
|
||||
if len(frames)<6:raise RuntimeError('insufficient complete moving lidar frames')
|
||||
residuals=[];shapes=scene_shapes();saved={}
|
||||
for j,f in enumerate(frames[::max(1,len(frames)//6)]):
|
||||
take=np.arange(0,len(f['xyz']),max(1,len(f['xyz'])//500));xyz=f['xyz'][take];distance=np.linalg.norm(xyz,axis=1)
|
||||
pos,q=interpolate(moving['states'],f['t']+f['offsets'][take]*1e-9)
|
||||
origins=pos+rotate(q,np.tile([0.,0.,.3],(len(pos),1)))
|
||||
directions=rotate(q,xyz/distance[:,None]);expected_range=ray_ranges(origins,directions,shapes)
|
||||
valid=np.isfinite(expected_range)&(expected_range>.1)&(expected_range<40)
|
||||
residuals.extend((distance-expected_range)[valid]);saved['xyz_%d'%j]=xyz;saved['expected_%d'%j]=expected_range
|
||||
errors=np.array(residuals)
|
||||
statuses=[s for s in p.sensor_status if 'candidate_hits' in s];candidates=sum(s['candidate_hits'] for s in statuses);dropped=sum(s['dropped'] for s in statuses)
|
||||
times=np.array([m['t'] for m in imus]);std=profile['range_stddev'];checks=dict(
|
||||
physical_excitation=moving['states'][-1]['pos'][0]-moving['states'][0]['pos'][0]>.3,
|
||||
imu_bias=np.all(abs(accel.mean(axis=0)-profile['accel_bias'])<5*profile['accel_stddev']/np.sqrt(len(accel))+.002) and np.all(abs(gyro.mean(axis=0)-profile['gyro_bias'])<5*profile['gyro_stddev']/np.sqrt(len(gyro))+.00005),
|
||||
imu_stddev=np.all(abs(accel.std(axis=0)/profile['accel_stddev']-1)<.2) and np.all(abs(gyro.std(axis=0)/profile['gyro_stddev']-1)<.2),
|
||||
range_noise=len(errors)>2000 and abs(errors.mean())<.1*std and .8<errors.std()/std<1.2,
|
||||
dropout=candidates>5000 and abs(dropped/candidates-profile['dropout'])<5*np.sqrt(profile['dropout']*(1-profile['dropout'])/candidates),
|
||||
packet_accounting=bool(statuses) and all(s['candidate_hits']==s['returns']+s['dropped']+s['range_rejected'] and s['rays']==20000 for s in statuses),
|
||||
acquisition_times=all(np.all(f['offsets']%1000000==0) and max(f['offsets'])<=99000000 and f['timebase']==round(f['t']*1e9) for f in frames),
|
||||
imu_times=np.min(np.diff(times))>0 and np.max(np.diff(times))<.02 and abs((len(times)-1)/(times[-1]-times[0])-200)<2,
|
||||
no_attitude_oracle=all(m['orientation_covariance_0']==-1 for m in imus))
|
||||
report.update(checks=checks,accel_mean=accel.mean(axis=0).tolist(),accel_stddev=accel.std(axis=0).tolist(),gyro_mean=gyro.mean(axis=0).tolist(),gyro_stddev=gyro.std(axis=0).tolist(),
|
||||
range_residual_mean_m=float(errors.mean()),range_residual_stddev_m=float(errors.std()),sampled_range_returns=len(errors),dropped=dropped,candidates=candidates,dropout_fraction=dropped/candidates,sensor_status=statuses)
|
||||
report.update(imu_mean_rate_hz=float((len(times)-1)/(times[-1]-times[0])),imu_interval_range_s=[float(np.diff(times).min()),float(np.diff(times).max())])
|
||||
np.savez_compressed(out/'observations.npz',imu_times=times,accel_residual=accel,gyro=gyro,range_residual=errors,**saved)
|
||||
report['status']='PASS' if all(checks.values()) else 'FAIL';print(report['status'],checks,flush=True)
|
||||
except Exception as e:report['error']=repr(e);print(report['error'],flush=True)
|
||||
finally:
|
||||
if p is not None:p.send(0.,0.,0.);p.destroy_node()
|
||||
if rclpy.ok():rclpy.shutdown()
|
||||
report['teardown']=sim.stop();(out/'result.json').write_text(json.dumps(report,indent=2,default=json_value)+'\n')
|
||||
return dict(PASS=0,FAIL=30,INVALID=40)[report['status']]
|
||||
|
||||
if __name__=='__main__':sys.exit(main())
|
||||
@@ -0,0 +1,142 @@
|
||||
#!/usr/bin/python3
|
||||
"""P3: compare raw/world 3D clouds against independent Gazebo truth at two yaws."""
|
||||
import argparse
|
||||
import json
|
||||
import math
|
||||
import os
|
||||
from pathlib import Path
|
||||
import sys
|
||||
import time
|
||||
import xml.etree.ElementTree as ET
|
||||
|
||||
import numpy as np
|
||||
import rclpy
|
||||
from sensor_msgs.msg import PointCloud2
|
||||
from nav_msgs.msg import Odometry
|
||||
from rclpy.qos import qos_profile_sensor_data
|
||||
|
||||
from check_omni_robot import Probe, Sim, reset_and_settle, sim_env
|
||||
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parents[1] /
|
||||
'src/r2027_robot_description/scripts'))
|
||||
from sim_data_adapter import xyz_views
|
||||
|
||||
|
||||
def stamp(m):
|
||||
return m.header.stamp.sec * 1_000_000_000 + m.header.stamp.nanosec
|
||||
|
||||
|
||||
def points(m):
|
||||
return np.stack(xyz_views(m), axis=-1).reshape(-1, 3)
|
||||
|
||||
|
||||
class LidarProbe(Probe):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.raw = {}
|
||||
self.world = {}
|
||||
self.body = []
|
||||
self.sensor = []
|
||||
self.create_subscription(PointCloud2, '/lidar/points',
|
||||
lambda m: self.raw.update({stamp(m): m}), qos_profile_sensor_data)
|
||||
self.create_subscription(PointCloud2, '/cloud_registered',
|
||||
lambda m: self.world.update({stamp(m): m}), 10)
|
||||
self.create_subscription(Odometry, '/body_odom', self.body.append, 10)
|
||||
self.create_subscription(Odometry, '/aft_mapped_to_init', self.sensor.append, 10)
|
||||
|
||||
|
||||
def check_phase(probe, out, yaw):
|
||||
ok, settle = reset_and_settle(probe, -4.5, 4.5, .17, yaw, str(out))
|
||||
if not ok:
|
||||
raise RuntimeError('robot did not settle')
|
||||
cutoff = int(probe.now() * 1e9)
|
||||
deadline = time.monotonic() + 60
|
||||
pairs = []
|
||||
while time.monotonic() < deadline:
|
||||
rclpy.spin_once(probe, timeout_sec=.02)
|
||||
pairs = sorted(s for s in probe.world if s >= cutoff and s in probe.raw)
|
||||
if len(pairs) >= 8 and probe.body and probe.sensor:
|
||||
break
|
||||
if len(pairs) < 8:
|
||||
raise RuntimeError('not enough paired raw/world clouds: %d' % len(pairs))
|
||||
truth = probe.get_state()
|
||||
if truth is None:
|
||||
raise RuntimeError('independent truth unavailable')
|
||||
s = pairs[-1]
|
||||
raw, world = probe.raw[s], probe.world[s]
|
||||
pr, pw = points(raw), points(world)
|
||||
good = np.isfinite(pr).all(axis=1) & np.isfinite(pw).all(axis=1)
|
||||
pr, pw = pr[good], pw[good]
|
||||
c, sn = math.cos(truth['yaw']), math.sin(truth['yaw'])
|
||||
R = np.array([[c, -sn, 0], [sn, c, 0], [0, 0, 1]])
|
||||
expected = (pr + [0, 0, .30]) @ R.T + truth['pos']
|
||||
error = float(np.max(np.linalg.norm(expected - pw, axis=1)))
|
||||
floor = int(np.count_nonzero(np.abs(pw[:, 2]) < .005))
|
||||
north = int(np.count_nonzero((np.abs(pw[:, 1]-5.5) < .005) & (pw[:, 2] >= -.005)
|
||||
& (pw[:, 2] <= .045)))
|
||||
west = int(np.count_nonzero((np.abs(pw[:, 0]+5.5) < .005) & (pw[:, 2] >= -.005)
|
||||
& (pw[:, 2] <= .045)))
|
||||
dt = np.diff(pairs) / 1e9
|
||||
body, sensor = probe.body[-1], probe.sensor[-1]
|
||||
shift = sensor.pose.pose.position.z - body.pose.pose.position.z
|
||||
checks = dict(raw_frame=raw.header.frame_id == 'lidar',
|
||||
world_frame=world.header.frame_id == 'world',
|
||||
cloud_3d=len(np.unique(np.round(pr[:, 2], 3))) > 10,
|
||||
finite_points=len(pw) > 1000, exact_stamp=stamp(raw) == stamp(world),
|
||||
stamp_monotonic=bool(np.all(dt > 0)),
|
||||
scan_rate=bool(np.max(dt) < .3),
|
||||
transform_matches_truth=error < .005,
|
||||
floor_correct=floor > 100, north_wall_correct=north > 2,
|
||||
west_wall_correct=west > 2,
|
||||
odom_frames=body.header.frame_id == 'world' and body.child_frame_id == 'base_link'
|
||||
and sensor.header.frame_id == 'world' and sensor.child_frame_id == 'lidar',
|
||||
sensor_mount=abs(shift-.30) < .001)
|
||||
np.savez_compressed(out / ('cloud_yaw_%d.npz' % round(yaw*180/math.pi)),
|
||||
raw=pr, world=pw, expected=expected)
|
||||
return dict(yaw=yaw, checks=checks, ok=all(checks.values()), settle=settle,
|
||||
truth=truth, stamp_ns=s, paired_clouds=len(pairs), finite_points=len(pw),
|
||||
fields=[f.name for f in raw.fields], rate_sim_hz=float(1/np.mean(dt)),
|
||||
transform_error_m=error, floor_points=floor, north_wall_points=north,
|
||||
west_wall_points=west, mount_shift_z=shift)
|
||||
|
||||
|
||||
def main():
|
||||
ap = argparse.ArgumentParser()
|
||||
ap.add_argument('--out', required=True)
|
||||
args = ap.parse_args()
|
||||
out = Path(args.out).resolve()
|
||||
out.mkdir(parents=True, exist_ok=True)
|
||||
os.environ.update(sim_env())
|
||||
sim = Sim(str(out/'sim'))
|
||||
report = {'phases': [], 'status': 'INVALID'}
|
||||
probe = None
|
||||
try:
|
||||
ok, why = sim.start(lidar=True)
|
||||
report['sim_start'] = why
|
||||
if not ok:
|
||||
raise RuntimeError(why)
|
||||
rclpy.init()
|
||||
probe = LidarProbe()
|
||||
if not probe.wait_clock():
|
||||
raise RuntimeError('no clock')
|
||||
for yaw in (0., math.pi/2):
|
||||
phase = check_phase(probe, out, yaw)
|
||||
report['phases'].append(phase)
|
||||
print('yaw %.3f: %s' % (yaw, phase['checks']), flush=True)
|
||||
report['status'] = 'PASS' if all(p['ok'] for p in report['phases']) else 'FAIL'
|
||||
except Exception as exc:
|
||||
report['error'] = repr(exc)
|
||||
print(report['error'], flush=True)
|
||||
finally:
|
||||
if probe is not None:
|
||||
probe.send(0., 0., 0.)
|
||||
probe.destroy_node()
|
||||
if rclpy.ok():
|
||||
rclpy.shutdown()
|
||||
report['teardown'] = sim.stop()
|
||||
(out/'result.json').write_text(json.dumps(report, ensure_ascii=False, indent=2)+'\n')
|
||||
return {'PASS': 0, 'FAIL': 30, 'INVALID': 40}[report['status']]
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(main())
|
||||
@@ -0,0 +1,166 @@
|
||||
#!/usr/bin/python3
|
||||
"""Validate force drive using independent Gazebo state, real contacts and lidar geometry."""
|
||||
import argparse
|
||||
import hashlib
|
||||
import json
|
||||
import math
|
||||
import os
|
||||
from pathlib import Path
|
||||
import sys
|
||||
import time
|
||||
|
||||
import numpy as np
|
||||
import rclpy
|
||||
from gazebo_msgs.msg import ContactsState
|
||||
from gazebo_msgs.srv import GetEntityState
|
||||
from geometry_msgs.msg import WrenchStamped
|
||||
from rclpy.qos import qos_profile_sensor_data
|
||||
from sensor_msgs.msg import PointCloud2
|
||||
|
||||
from check_omni_robot import BASE, Probe, Sim, reset_and_settle, sim_env
|
||||
from check_sim_lidar import points, stamp
|
||||
|
||||
|
||||
class SlopeProbe(Probe):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.contacts, self.wrenches, self.cloud_checks = [], [], []
|
||||
self.raw = {}
|
||||
self.create_subscription(ContactsState, '/sim/drive_contacts', self.on_contacts, 100)
|
||||
self.create_subscription(WrenchStamped, '/sim/drive_wrench', self.on_force, 100)
|
||||
self.create_subscription(PointCloud2, '/lidar/points', lambda m: self.raw.update({stamp(m):m}), qos_profile_sensor_data)
|
||||
self.create_subscription(PointCloud2, '/cloud_registered', self.on_cloud, 5)
|
||||
|
||||
def on_contacts(self, m):
|
||||
self.contacts.append(dict(t=m.header.stamp.sec+m.header.stamp.nanosec*1e-9,
|
||||
pairs=[(s.collision1_name,s.collision2_name) for s in m.states],
|
||||
max_depth=max((d for s in m.states for d in s.depths),default=0.)))
|
||||
|
||||
def on_force(self, m):
|
||||
self.wrenches.append(dict(t=m.header.stamp.sec+m.header.stamp.nanosec*1e-9,
|
||||
force=[m.wrench.force.x,m.wrench.force.y,m.wrench.force.z],
|
||||
torque=[m.wrench.torque.x,m.wrench.torque.y,m.wrench.torque.z]))
|
||||
|
||||
def on_cloud(self, m):
|
||||
raw = self.raw.pop(stamp(m), None)
|
||||
if raw is None:
|
||||
return
|
||||
pr,pw = points(raw),points(m)
|
||||
self_hit = (np.abs(pr[:,0])<=.42)&(np.abs(pr[:,1])<=.42)&(pr[:,2]>=-.47)&(pr[:,2]<=-.20)
|
||||
roi = np.isfinite(pw).all(1)&(~self_hit)&(pw[:,0]>-.5)&(pw[:,0]<2.4)&(pw[:,1]>3.1)&(pw[:,1]<3.9)
|
||||
pc=pw[roi]
|
||||
if len(pc)>20:
|
||||
errors=np.abs(.597*pc[:,0]+3.5*pc[:,2]-1.6119)/math.hypot(.597,3.5)
|
||||
self.cloud_checks.append(dict(t=stamp(m)*1e-9,points=len(pc),max_plane_error_m=float(np.max(errors))))
|
||||
for key in sorted(self.raw)[:-20]:self.raw.pop(key)
|
||||
|
||||
def get_state(self):
|
||||
req=GetEntityState.Request(); req.name=BASE; req.reference_frame='world'
|
||||
res=self._call(self.cli_get,req)
|
||||
if res is None or not res.success:return None
|
||||
st=res.state;q=st.pose.orientation
|
||||
roll=math.atan2(2*(q.w*q.x+q.y*q.z),1-2*(q.x*q.x+q.y*q.y))
|
||||
pitch=math.asin(max(-1.,min(1.,2*(q.w*q.y-q.z*q.x))))
|
||||
yaw=math.atan2(2*(q.w*q.z+q.x*q.y),1-2*(q.y*q.y+q.z*q.z))
|
||||
return dict(stamp=res.header.stamp.sec+res.header.stamp.nanosec*1e-9,
|
||||
pos=[st.pose.position.x,st.pose.position.y,st.pose.position.z],yaw=yaw,
|
||||
rpy=[roll,pitch,yaw],quaternion=[q.x,q.y,q.z,q.w],
|
||||
twist_world=[st.twist.linear.x,st.twist.linear.y,st.twist.linear.z],
|
||||
wz=st.twist.angular.z)
|
||||
|
||||
|
||||
def hold(p, cmd, duration):
|
||||
samples=[];nxt=p.now()
|
||||
def sample():
|
||||
nonlocal nxt
|
||||
if p.now()<nxt:return
|
||||
state=p.get_state()
|
||||
if state is None:raise RuntimeError('independent truth unavailable')
|
||||
samples.append(state);nxt=p.now()+.04
|
||||
p.hold(*cmd,duration,sampler=sample)
|
||||
return samples
|
||||
|
||||
|
||||
def main():
|
||||
ap=argparse.ArgumentParser();ap.add_argument('--out',required=True)
|
||||
ap.add_argument('--world');args=ap.parse_args()
|
||||
out=Path(args.out).resolve();out.mkdir(parents=True,exist_ok=True)
|
||||
os.environ.update(sim_env());os.environ['ROS_LOG_DIR']=str(out/'ros')
|
||||
sim,p=Sim(str(out/'sim')),None
|
||||
report=dict(status='INVALID',phases={})
|
||||
source=Path(__file__).read_bytes();(out/'collector_snapshot.py').write_bytes(source)
|
||||
report['collector_sha256']=hashlib.sha256(source).hexdigest()
|
||||
try:
|
||||
ok,why=sim.start(lidar=True,drive='contact',world=args.world);report['startup']=why
|
||||
if not ok:raise RuntimeError(why)
|
||||
rclpy.init();p=SlopeProbe()
|
||||
if not p.wait_clock():raise RuntimeError('no clock')
|
||||
p.pump(.5)
|
||||
if not p.set_state(3.5,3.5,1.15,0.):raise RuntimeError('drop set failed')
|
||||
t0=p.now()
|
||||
drop=hold(p,(.2,0.,0.),.28)
|
||||
t=np.array([s['stamp'] for s in drop]); z=np.array([s['pos'][2] for s in drop])
|
||||
if len(np.unique(t))<5:raise RuntimeError('insufficient free-fall samples')
|
||||
acc=float(2*np.polyfit(t-t[0],z,2)[0])
|
||||
forces=[s for s in p.wrenches if t0+.04<s['t']<p.now()]
|
||||
checks=dict(gravity=abs(acc+9.81)<.5,
|
||||
no_air_drive=len(forces)>3 and max(np.linalg.norm(s['force']) for s in forces)<1e-6,
|
||||
horizontal_drift=abs(drop[-1]['pos'][0]-drop[0]['pos'][0])<.01)
|
||||
report['phases']['free_fall']=dict(checks=checks,acceleration_z_m_s2=acc,samples=drop)
|
||||
ok,rec=reset_and_settle(p,3.5,3.5,.17,0.,str(out))
|
||||
if not ok:raise RuntimeError('ramp start did not settle')
|
||||
t0=p.now()
|
||||
motions={}
|
||||
for name,cmd,duration in (
|
||||
('up_first',(-.25,0.,0.),10.),('stop',(0.,0.,0.),2.),
|
||||
('up_second',(-.25,0.,0.),8.8),('upper_landing',(0.,0.,0.),1.5),
|
||||
('down',(.25,0.,0.),18.8),('bottom',(0.,0.,0.),1.5)):
|
||||
motions[name]=hold(p,cmd,duration)
|
||||
(out/(name+'.json')).write_text(json.dumps(dict(samples=motions[name],
|
||||
contacts=p.contacts,wrenches=p.wrenches),indent=2)+'\n')
|
||||
print(name,motions[name][-1]['pos'],motions[name][-1]['rpy'],flush=True)
|
||||
if name=='up_first' and motions[name][-1]['pos'][0]>2.:
|
||||
report['phases']['ascent_entry']=dict(checks=dict(entered_ramp=False),samples=motions[name])
|
||||
report['status']='FAIL'
|
||||
return 30
|
||||
up1,stop,up2,top,down,bottom=[motions[n] for n in (
|
||||
'up_first','stop','up_second','upper_landing','down','bottom')]
|
||||
states=up1+up2+down
|
||||
mid=[s for s in states if -.35<s['pos'][0]<2.2]
|
||||
if len(mid)<20:raise RuntimeError('insufficient ramp samples')
|
||||
err=max(abs(s['pos'][2]-((1.6119-.597*s['pos'][0])/3.5+.15)) for s in mid)
|
||||
theta=math.atan2(.597,3.5)
|
||||
tilt=max(abs(s['rpy'][1]-theta) for s in mid)
|
||||
late=stop[len(stop)//2:]
|
||||
stop_speed=max(np.linalg.norm(s['twist_world']) for s in late)
|
||||
stop_drift=max(np.linalg.norm(np.array(s['pos'])-late[0]['pos']) for s in late)
|
||||
contacts=[s for s in p.contacts if s['t']>t0]
|
||||
force=[s for s in p.wrenches if s['t']>t0]
|
||||
clouds=[s for s in p.cloud_checks if s['t']>t0]
|
||||
checks=dict(reached_upper_landing=top[-1]['pos'][0]<-.9 and abs(top[-1]['pos'][2]-.749)<.03,
|
||||
returned_to_ground=bottom[-1]['pos'][0]>3. and abs(bottom[-1]['pos'][2]-.149)<.02,
|
||||
followed_ramp=err<.03,physical_pitch=tilt<.05,
|
||||
stayed_in_lane=max(abs(s['pos'][1]-3.5) for s in states)<.03,
|
||||
hill_stop=stop_speed<.01 and stop_drift<.02,
|
||||
ramp_contact=any('ramp_north' in n for s in contacts for pair in s['pairs'] for n in pair),
|
||||
no_excess_penetration=bool(contacts) and max(s['max_depth'] for s in contacts)<.005,
|
||||
no_vertical_or_tilt_actuator=bool(force) and all(s['force'][2]==0 and s['torque'][:2]==[0,0] for s in force),
|
||||
tilted_cloud_geometry=len(clouds)>10 and max(s['max_plane_error_m'] for s in clouds)<.01)
|
||||
report['phases']['round_trip']=dict(checks=checks,up_first=up1,stop=stop,up_second=up2,
|
||||
upper_landing=top,down=down,bottom=bottom,max_height_error_m=err,max_pitch_error_rad=tilt,
|
||||
hill_stop_speed_m_s=float(stop_speed),hill_stop_drift_m=float(stop_drift),
|
||||
contacts=contacts,applied_wrenches=force,cloud_geometry=clouds)
|
||||
for name,phase in report['phases'].items():print(name,phase['checks'],flush=True)
|
||||
report['status']='PASS' if all(all(v['checks'].values()) for v in report['phases'].values()) else 'FAIL'
|
||||
except Exception as exc:
|
||||
report['error']=repr(exc);print(report['error'],flush=True)
|
||||
finally:
|
||||
if p is not None:p.send(0.,0.,0.);p.destroy_node()
|
||||
if rclpy.ok():rclpy.shutdown()
|
||||
report['teardown']=sim.stop()
|
||||
(out/'result.json').write_text(json.dumps(report,indent=2,
|
||||
default=lambda v:v.item() if isinstance(v,np.generic) else str(v))+'\n')
|
||||
return {'PASS':0,'FAIL':30,'INVALID':40}[report['status']]
|
||||
|
||||
|
||||
if __name__=='__main__':sys.exit(main())
|
||||
@@ -0,0 +1,141 @@
|
||||
#!/usr/bin/python3
|
||||
"""Existing SCAN reference-path controller + force physics: uphill, downhill, stair rejection."""
|
||||
import argparse
|
||||
import hashlib
|
||||
import json
|
||||
import math
|
||||
import os
|
||||
from pathlib import Path
|
||||
import sys
|
||||
import time
|
||||
|
||||
import numpy as np
|
||||
import rclpy
|
||||
from gazebo_msgs.msg import ContactsState
|
||||
from nav_msgs.msg import Path as NavPath
|
||||
from geometry_msgs.msg import PoseStamped
|
||||
from rclpy.qos import QoSProfile,DurabilityPolicy
|
||||
|
||||
from check_omni_robot import Sim,sim_env
|
||||
from check_scan_navigation import NavProbe
|
||||
from check_slope_drive import SlopeProbe
|
||||
from check_sim_lidar import points
|
||||
|
||||
LANE_Y=3.5125 # Midpoint of the rail's outer face y=3.025 and ramp edge y=4.
|
||||
|
||||
|
||||
class TerrainProbe(NavProbe):
|
||||
get_state=SlopeProbe.get_state
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.path_pub=self.create_publisher(NavPath,'/initial_path',
|
||||
QoSProfile(depth=1,durability=DurabilityPolicy.TRANSIENT_LOCAL))
|
||||
self.contacts=[]
|
||||
self.create_subscription(ContactsState,'/sim/drive_contacts',self.contacts.append,100)
|
||||
|
||||
|
||||
def run_path(p, xs, blocked=False):
|
||||
old_id=p.status[-1].goal_id if p.status else 0
|
||||
first_status,first_cmd,first_contacts=len(p.status),len(p.commands),len(p.contacts)
|
||||
first=p.get_state()
|
||||
if first is None:raise RuntimeError('missing starting truth')
|
||||
msg=NavPath();msg.header.frame_id='world';msg.header.stamp=p.get_clock().now().to_msg()
|
||||
for x in xs:
|
||||
z=0.15 if blocked and x<-1.8 else (0. if x>=2.7 else (.6 if x<=-.8 else (1.6119-.597*x)/3.5))
|
||||
pose=PoseStamped();pose.header=msg.header;pose.pose.position.x=float(x)
|
||||
pose.pose.position.y=LANE_Y;pose.pose.position.z=z;pose.pose.orientation.w=1.
|
||||
msg.poses.append(pose)
|
||||
p.path_pub.publish(msg)
|
||||
t0,end=p.now(),time.monotonic()+360
|
||||
states=[]
|
||||
while p.now()-t0<65 and time.monotonic()<end:
|
||||
p.pump(.1);state=p.get_state()
|
||||
if state is None:raise RuntimeError('missing independent state')
|
||||
states.append(state)
|
||||
status=p.status[-1] if p.status else None
|
||||
if status and status.goal_id>old_id and status.state in (status.SUCCEEDED,status.FAILED):break
|
||||
p.pump(1.)
|
||||
rest=[]
|
||||
for _ in range(10):p.pump(.1);rest.append(p.get_state())
|
||||
if any(s is None for s in rest):raise RuntimeError('missing stop truth')
|
||||
status=p.status[-1]
|
||||
statuses=p.status[first_status:];commands=p.commands[first_cmd:]
|
||||
contacts=p.contacts[first_contacts:]
|
||||
err=math.hypot(rest[-1]['pos'][0]-xs[-1],rest[-1]['pos'][1]-LANE_Y)
|
||||
goal_z=msg.poses[-1].pose.position.z+.15
|
||||
drift=max(math.dist(s['pos'],rest[0]['pos']) for s in rest)
|
||||
checks=dict(acknowledged=status.goal_id>old_id,
|
||||
state_as_expected=status.state==(status.FAILED if blocked else status.SUCCEEDED),
|
||||
perception_fresh=p.ready,
|
||||
stopped=drift<.02 and max(math.hypot(*s['twist_world'][:2]) for s in rest)<.01,
|
||||
original_goal_preserved=abs(status.goal.x-xs[-1])<1e-6 and abs(status.goal.y-LANE_Y)<1e-6)
|
||||
if blocked:
|
||||
checks.update(never_active=not any(s.state==s.ACTIVE for s in statuses),
|
||||
stationary=max(math.dist(s['pos'],first['pos']) for s in states)<.02,
|
||||
zero_commands=bool(commands) and all(max(abs(c[k]) for k in ('vx','vy','wz'))<1e-6 for c in commands))
|
||||
else:
|
||||
mid=[s for s in states if -.35<s['pos'][0]<2.2]
|
||||
checks.update(active=any(s.state==s.ACTIVE for s in statuses),physical_arrival=err<.10,
|
||||
physical_height=abs(rest[-1]['pos'][2]-goal_z)<.03,
|
||||
ramp_pitch=bool(mid) and max(abs(s['rpy'][1]-math.atan2(.597,3.5)) for s in mid)<.05,
|
||||
ramp_height=bool(mid) and max(abs(s['pos'][2]-((1.6119-.597*s['pos'][0])/3.5+.15)) for s in mid)<.04,
|
||||
lane=max(abs(s['pos'][1]-LANE_Y) for s in states)<.03,
|
||||
real_ramp_contacts=any(('ramp_north' if LANE_Y>0 else 'ramp_south') in pair for m in contacts for s in m.states
|
||||
for pair in (s.collision1_name,s.collision2_name)),
|
||||
penetration=bool(contacts) and max((d for m in contacts for s in m.states for d in s.depths),default=1)<.005)
|
||||
return dict(checks=checks,ok=all(checks.values()),duration_sim_s=p.now()-t0,
|
||||
goal=[xs[-1],LANE_Y,goal_z],position_error_m=err,stop_drift_m=drift,
|
||||
input_path=[[s.pose.position.x,s.pose.position.y,s.pose.position.z] for s in msg.poses],
|
||||
samples=states,stop_samples=rest,commands=commands,
|
||||
statuses=[dict(t=s.header.stamp.sec+s.header.stamp.nanosec*1e-9,state=s.state,reason=s.reason,
|
||||
goal=[s.goal.x,s.goal.y,s.goal.z],traj_id=s.traj_id) for s in statuses])
|
||||
|
||||
|
||||
def main():
|
||||
global LANE_Y
|
||||
ap=argparse.ArgumentParser();ap.add_argument('--out',required=True)
|
||||
ap.add_argument('--side',choices=('red','blue'),default='red')
|
||||
ap.add_argument('--case',choices=('round_trip','stairs_rejected'),default='round_trip')
|
||||
args=ap.parse_args()
|
||||
if args.side=='blue':LANE_Y=-LANE_Y
|
||||
out=Path(args.out).resolve();out.mkdir(parents=True,exist_ok=True)
|
||||
os.environ.update(sim_env());os.environ['ROS_LOG_DIR']=str(out/'ros')
|
||||
source=Path(__file__).read_bytes();(out/'collector_snapshot.py').write_bytes(source)
|
||||
report=dict(status='INVALID',side=args.side,cases={},collector_sha256=hashlib.sha256(source).hexdigest())
|
||||
sim,p=Sim(str(out/'sim')),None
|
||||
try:
|
||||
spawn=(1.5,LANE_Y,.5,0.) if args.case=='stairs_rejected' else (3.5,LANE_Y,.15,0.)
|
||||
ok,why=sim.start(navigation=True,terrain=True,spawn=spawn);report['startup']=why
|
||||
if not ok:raise RuntimeError(why)
|
||||
rclpy.init();p=TerrainProbe()
|
||||
if not p.wait_clock():raise RuntimeError('no clock')
|
||||
end=time.monotonic()+90
|
||||
while time.monotonic()<end:
|
||||
rclpy.spin_once(p,timeout_sec=.02)
|
||||
if p.ready and p.status and p.path_pub.get_subscription_count()>0:break
|
||||
else:raise RuntimeError('terrain pipeline not ready')
|
||||
p.pump(2.)
|
||||
# A distant goal outside the sliding map is allowed to approach before
|
||||
# re-evaluation. Test immediate rejection only with the goal observed.
|
||||
cases=([('stairs_rejected',[1.5,-2.5],True)] if args.case=='stairs_rejected' else
|
||||
[('uphill',[3.5,2.7,-.8,-1.2],False),('downhill',[-1.2,-.8,2.7,3.5],False)])
|
||||
for name,xs,blocked in cases:
|
||||
result=run_path(p,xs,blocked)
|
||||
report['cases'][name]=result
|
||||
(out/(name+'.json')).write_text(json.dumps(result,indent=2)+'\n')
|
||||
np.savez_compressed(out/(name+'_map.npz'),**{t:points(m) for t,m in p.clouds.items()})
|
||||
print(name,result['checks'],'error',result['position_error_m'],flush=True)
|
||||
if not result['ok']:break
|
||||
report['status']='PASS' if len(report['cases'])==len(cases) and all(c['ok'] for c in report['cases'].values()) else 'FAIL'
|
||||
except Exception as exc:
|
||||
report['error']=repr(exc);print(report['error'],flush=True)
|
||||
finally:
|
||||
if p is not None:p.send(0.,0.,0.);p.destroy_node()
|
||||
if rclpy.ok():rclpy.shutdown()
|
||||
report['teardown']=sim.stop()
|
||||
(out/'result.json').write_text(json.dumps(report,indent=2)+'\n')
|
||||
return {'PASS':0,'FAIL':30,'INVALID':40}[report['status']]
|
||||
|
||||
|
||||
if __name__=='__main__':sys.exit(main())
|
||||
@@ -0,0 +1,56 @@
|
||||
#!/usr/bin/python3
|
||||
"""Reproduce the pinned upstream ramp face-winding correction, without moving vertices."""
|
||||
import argparse
|
||||
import hashlib
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
UPSTREAM_SHA256 = '5344932eae23391872e371758bbe9a70a6b5b9979fa53d3862b3183bee331f13'
|
||||
|
||||
|
||||
def corrected_bytes(source):
|
||||
if hashlib.sha256(source).hexdigest() != UPSTREAM_SHA256:
|
||||
raise ValueError('Unknown upstream ramp: review geometry before applying this repair')
|
||||
lines=source.decode().splitlines(keepends=True)
|
||||
return ''.join('f '+' '.join(reversed(l.split()[1:]))+'\n' if l.startswith('f ') else l
|
||||
for l in lines).encode()
|
||||
|
||||
|
||||
def geometry(data):
|
||||
lines=data.decode().splitlines()
|
||||
vertices=[tuple(map(float,l.split()[1:])) for l in lines if l.startswith('v ')]
|
||||
faces=[tuple(int(v)-1 for v in l.split()[1:]) for l in lines if l.startswith('f ')]
|
||||
volume=0.
|
||||
for f in faces:
|
||||
a,b,c=[vertices[i] for i in f]
|
||||
volume+=(a[0]*(b[1]*c[2]-b[2]*c[1])+a[1]*(b[2]*c[0]-b[0]*c[2])+a[2]*(b[0]*c[1]-b[1]*c[0]))/6
|
||||
edges={}
|
||||
for f in faces:
|
||||
for a,b in zip(f,f[1:]+f[:1]):edges[(a,b)]=edges.get((a,b),0)+1
|
||||
closed=all(count==1 and edges.get((b,a))==1 for (a,b),count in edges.items())
|
||||
return vertices,faces,volume,closed
|
||||
|
||||
|
||||
def verify(source,target):
|
||||
sv,sf,volume_in,closed_in=geometry(source)
|
||||
tv,tf,volume_out,closed_out=geometry(target)
|
||||
return dict(upstream_sha256=hashlib.sha256(source).hexdigest(),
|
||||
repaired_sha256=hashlib.sha256(target).hexdigest(),
|
||||
exact_pinned_repair=target==corrected_bytes(source),
|
||||
vertices_unchanged=sv==tv,
|
||||
all_faces_reversed=tf==[tuple(reversed(f)) for f in sf],
|
||||
closed_before=closed_in,closed_after=closed_out,
|
||||
signed_volume_before_m3=volume_in,signed_volume_after_m3=volume_out)
|
||||
|
||||
|
||||
def main():
|
||||
ap=argparse.ArgumentParser();ap.add_argument('source');ap.add_argument('--output',required=True)
|
||||
args=ap.parse_args();source=Path(args.source).read_bytes();target=corrected_bytes(source)
|
||||
evidence=verify(source,target)
|
||||
assert all(evidence[k] for k in ('exact_pinned_repair','vertices_unchanged','all_faces_reversed','closed_before','closed_after'))
|
||||
assert evidence['signed_volume_before_m3']<0<evidence['signed_volume_after_m3']
|
||||
Path(args.output).write_bytes(target)
|
||||
print(json.dumps(evidence,indent=2))
|
||||
|
||||
|
||||
if __name__=='__main__':main()
|
||||
@@ -0,0 +1,130 @@
|
||||
#!/usr/bin/python3
|
||||
"""Numerical/reference-frame and fail-closed contract tests; no Gazebo required."""
|
||||
from array import array
|
||||
import copy
|
||||
import math
|
||||
from pathlib import Path
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
import numpy as np
|
||||
import rclpy
|
||||
from nav_msgs.msg import Odometry
|
||||
from sensor_msgs.msg import PointCloud2,PointField
|
||||
|
||||
sys.path.insert(0,str(Path(__file__).resolve().parents[1]/'src/br_sim_bringup/scripts'))
|
||||
from lio_navigation_adapter import FixedAlignment,LioNavigationAdapter,quaternion,rotation,shifted_twist,float_fields
|
||||
|
||||
|
||||
class Recorder:
|
||||
def __init__(self):self.messages=[]
|
||||
def publish(self,m):self.messages.append(copy.deepcopy(m))
|
||||
|
||||
|
||||
class GeometryTests(unittest.TestCase):
|
||||
def test_known_start_maps_imu_and_optical_origins(self):
|
||||
imu=np.array([.011,.02329,.25588]);prior=np.array([-4.5,4.5,.15,math.pi/2])
|
||||
p=np.array([.2,-.3,.02]);q=np.array([0.,0.,math.sin(.35),math.cos(.35)])
|
||||
a=FixedAlignment(prior,imu,p,q)
|
||||
base,bq=a.pose(p,q,-imu);lidar,_=a.pose(p,q,np.array([0.,0.,.3])-imu)
|
||||
np.testing.assert_allclose(base,prior[:3],atol=1e-12)
|
||||
np.testing.assert_allclose(lidar,prior[:3]+[0,0,.3],atol=1e-12)
|
||||
self.assertAlmostEqual(math.atan2(rotation(bq)[1,0],rotation(bq)[0,0]),math.pi/2)
|
||||
old_t=a.t.copy();later,_=a.pose(p+[1,0,0],q,-imu)
|
||||
np.testing.assert_allclose(later-base,a.R@[1,0,0],atol=1e-12)
|
||||
np.testing.assert_array_equal(a.t,old_t)
|
||||
|
||||
def test_rotating_imu_lever_arm_by_finite_difference(self):
|
||||
offset=np.array([.011,.02329,.25588]);yaw=.8;w=.4;dt=1e-6
|
||||
def R(y):return np.array([[math.cos(y),-math.sin(y),0],[math.sin(y),math.cos(y),0],[0,0,1]])
|
||||
imu_world_velocity=(R(yaw+w*dt)@offset-R(yaw-w*dt)@offset)/(2*dt)
|
||||
imu_body_velocity=R(yaw).T@imu_world_velocity
|
||||
base=shifted_twist(imu_body_velocity,[0,0,w],-offset)
|
||||
np.testing.assert_allclose(base,[0,0,0],atol=1e-10)
|
||||
lidar=shifted_twist(imu_body_velocity,[0,0,w],np.array([0,0,.3])-offset)
|
||||
np.testing.assert_allclose(lidar,[0,0,0],atol=1e-10)
|
||||
|
||||
def test_invalid_quaternions_are_rejected(self):
|
||||
for values in ([0,0,0,0],[0,0,0,2],[float('nan'),0,0,1]):
|
||||
with self.assertRaises(ValueError):quaternion(values)
|
||||
|
||||
|
||||
class AdapterTests(unittest.TestCase):
|
||||
@classmethod
|
||||
def setUpClass(cls):rclpy.init()
|
||||
@classmethod
|
||||
def tearDownClass(cls):rclpy.shutdown()
|
||||
def setUp(self):
|
||||
self.node=LioNavigationAdapter();self.time=1.;self.node.now_s=lambda:self.time
|
||||
for key in ('body_pub','sensor_pub','world_pub','planning_pub','ready_pub','status_pub'):setattr(self.node,key,Recorder())
|
||||
def tearDown(self):self.node.destroy_node()
|
||||
def odom(self,t):
|
||||
self.time=t;m=Odometry();m.header.frame_id='camera_init';m.child_frame_id='body'
|
||||
m.header.stamp.sec=int(t);m.header.stamp.nanosec=round((t-int(t))*1e9)
|
||||
m.pose.pose.orientation.w=1.;return m
|
||||
def anchor(self):
|
||||
for t in np.arange(1.,2.11,.05):self.node.on_odom(self.odom(float(t)))
|
||||
self.assertIsNotNone(self.node.alignment)
|
||||
|
||||
def test_stale_and_discontinuous_odometry_never_reanchors(self):
|
||||
self.anchor();t=self.node.odom_stamp;translation=self.node.alignment.t.copy()
|
||||
stale=self.odom(t);self.time=t+.3;count=len(self.node.body_pub.messages)
|
||||
self.node.on_odom(stale);self.node.health()
|
||||
self.assertFalse(self.node.ready_pub.messages[-1].data)
|
||||
self.assertEqual(len(self.node.body_pub.messages),count)
|
||||
self.node.on_odom(self.odom(t+1.))
|
||||
self.assertTrue(self.node.fault)
|
||||
self.assertEqual(len(self.node.body_pub.messages),count)
|
||||
np.testing.assert_array_equal(self.node.alignment.t,translation)
|
||||
|
||||
def test_paired_cloud_filters_original_indices_and_preserves_stamp(self):
|
||||
self.anchor();n=111;data=np.zeros((n,6),dtype='<f4');data[:,3]=1.
|
||||
data[0,3:]=[0,0,-.3] # self return, regardless of latest robot pose
|
||||
data[1,2]=-self.node.alignment.t[2] # world ground
|
||||
m=PointCloud2();m.header.frame_id='camera_init';m.header.stamp=self.odom(self.time).header.stamp
|
||||
m.height=1;m.width=n;m.point_step=24;m.row_step=24*n
|
||||
m.fields=[PointField(name=name,offset=i*4,datatype=PointField.FLOAT32,count=1) for i,name in enumerate(('x','y','z','lidar_x','lidar_y','lidar_z'))]
|
||||
m.data=array('B',data.tobytes());self.node.on_cloud(m);self.node.health()
|
||||
self.assertTrue(self.node.ready_pub.messages[-1].data)
|
||||
full=self.node.world_pub.messages[-1];filtered=self.node.planning_pub.messages[-1]
|
||||
self.assertEqual(filtered.header.stamp,m.header.stamp)
|
||||
xyz=np.stack(float_fields(filtered,('x','y','z')),axis=-1).reshape(n,3)
|
||||
self.assertTrue(np.isnan(xyz[:2]).all());self.assertTrue(np.isfinite(xyz[2:]).all())
|
||||
for a,b in zip(float_fields(full,('lidar_x','lidar_y','lidar_z')),float_fields(filtered,('lidar_x','lidar_y','lidar_z'))):np.testing.assert_array_equal(a,b)
|
||||
|
||||
def test_wrong_source_frame_latches_stop(self):
|
||||
m=self.odom(1.);m.header.frame_id='world';self.node.on_odom(m)
|
||||
self.assertTrue(self.node.fault);self.assertIsNone(self.node.alignment)
|
||||
|
||||
def test_known_slope_uncertainty_preserves_raised_obstacles(self):
|
||||
self.anchor();self.node.planes=[[-.8,2.7,3.,4.,-.597/3.5,0.,1.6119/3.5]]
|
||||
self.node.surface_tolerance=.06
|
||||
xyz=[]
|
||||
for bias in (-.04,0.,.04):
|
||||
for height in (0.,.15):
|
||||
xyz.extend([[1.,3.5,(1.6119-.597)/3.5+bias+height]]*20)
|
||||
data=np.ones((len(xyz),6),dtype='<f4');data[:,:3]=np.asarray(xyz)-self.node.alignment.t
|
||||
m=PointCloud2();m.header.frame_id='camera_init';m.header.stamp=self.odom(self.time).header.stamp
|
||||
m.height=1;m.width=len(data);m.point_step=24;m.row_step=24*len(data)
|
||||
m.fields=[PointField(name=n,offset=i*4,datatype=PointField.FLOAT32,count=1) for i,n in enumerate(('x','y','z','lidar_x','lidar_y','lidar_z'))]
|
||||
m.data=array('B',data.tobytes());original=bytes(m.data);self.node.on_cloud(m)
|
||||
result=np.stack(float_fields(self.node.planning_pub.messages[-1],('x','y','z')),axis=-1).reshape(-1,3)
|
||||
for i in range(3):
|
||||
self.assertTrue(np.isnan(result[i*40:i*40+20]).all())
|
||||
self.assertTrue(np.isfinite(result[i*40+20:(i+1)*40]).all())
|
||||
self.assertEqual(bytes(m.data),original)
|
||||
full=np.stack(float_fields(self.node.world_pub.messages[-1],('x','y','z')),axis=-1).reshape(-1,3)
|
||||
np.testing.assert_allclose(full,xyz,atol=1e-6)
|
||||
|
||||
def test_downstream_planning_loss_revokes_readiness(self):
|
||||
self.anchor();self.node.planning_topic='/sim/navigation/terrain_planning_cloud'
|
||||
self.node.planning_max_age=.2
|
||||
self.node.cloud_stamp=self.time;self.node.downstream_stamp=self.time
|
||||
self.node.health();self.assertTrue(self.node.ready_pub.messages[-1].data)
|
||||
self.time+=.19;self.node.odom_stamp=self.time;self.node.cloud_stamp=self.time
|
||||
self.node.health();self.assertTrue(self.node.ready_pub.messages[-1].data)
|
||||
self.time+=.02;self.node.odom_stamp=self.time;self.node.cloud_stamp=self.time
|
||||
self.node.health();self.assertFalse(self.node.ready_pub.messages[-1].data)
|
||||
|
||||
|
||||
if __name__=='__main__':unittest.main()
|
||||
Reference in New Issue
Block a user