test(localization): replay contact regressions and validate arena navigation
This commit is contained in:
1 parent
28ac7c488e
commit
0602144ac5
29 files changed
+762
-22
No files matched your search
@@ -115,3 +115,16 @@ Python 入口可用 `tools/verify_lio_stack.py --launcher python` 做同样的
|
|||||||
导航时,车端转发节点仅接收碰撞监控器的最终 `/cmd_vel`。LIO 心跳失效或超时触发零速度与目标取消。速度命令自身超时也触发零速度,恢复行为中的正常等待可以继续。解除定位失效后需要重新发送已取消的目标。Shell 的 `NAV2=0` 和 Python 的 `nav2:=false` 都可通过 `MANUAL_CMD_VEL_TOPIC` 设置手动输入。
|
导航时,车端转发节点仅接收碰撞监控器的最终 `/cmd_vel`。LIO 心跳失效或超时触发零速度与目标取消。速度命令自身超时也触发零速度,恢复行为中的正常等待可以继续。解除定位失效后需要重新发送已取消的目标。Shell 的 `NAV2=0` 和 Python 的 `nav2:=false` 都可通过 `MANUAL_CMD_VEL_TOPIC` 设置手动输入。
|
||||||
|
|
||||||
两个仿真入口启用点云可靠传输。独立运行定位节点时可用 `reliable_clouds` 匹配发布者。指定 `LIO_TRACE_PATH` 可记录每帧的预测、候选和最终状态、协方差、信息矩阵及拒绝原因,这会增加磁盘 I/O。已知初始位姿仍是连续跟踪的前提。动态障碍遮挡全部可用结构、场地退化或传感器断流时,导航将停止。
|
两个仿真入口启用点云可靠传输。独立运行定位节点时可用 `reliable_clouds` 匹配发布者。指定 `LIO_TRACE_PATH` 可记录每帧的预测、候选和最终状态、协方差、信息矩阵及拒绝原因,这会增加磁盘 I/O。已知初始位姿仍是连续跟踪的前提。动态障碍遮挡全部可用结构、场地退化或传感器断流时,导航将停止。
|
||||||
|
|
||||||
|
### 复现导航验收
|
||||||
|
|
||||||
|
两个入口都可运行相同的隔离验收。域编号可用 `--domain` 显式保留给并行测试;如域已有导航或定位节点,启动器会拒绝启动。
|
||||||
|
|
||||||
|
```bash
|
||||||
|
python3 tools/run_lio_matrix.py --launcher shell --map generated/field.flmap --output generated/lio_matrix_shell
|
||||||
|
python3 tools/run_lio_matrix.py --launcher python --map generated/field.flmap --output generated/lio_matrix_python
|
||||||
|
python3 tools/validate_lio_navigation.py --launcher shell --scenario lidar_loss --goal 0 0 \
|
||||||
|
--map generated/field.flmap --output generated/lio_lidar_loss
|
||||||
|
```
|
||||||
|
|
||||||
|
默认矩阵各跑三次空场和三次圆柱绕行,再跑一次堵塞。默认圆柱在 `(-4, -1.5)`,半径 0.22 m、高 0.8 m。每次保留启动与目标日志、录制数据、TF 发布者数、最小圆柱净距及无需轨迹对齐的 3D ATE 和 1 秒 RPE。堵塞场景要求 Nav2 返回明确中止。断流场景只停止试验自己创建的自滤节点,并用执行器收到的零速度测量停车延迟。实测位姿来自 Gazebo PosePublisher,只参与评估。
|
||||||
@@ -13,7 +13,7 @@ struct NoiseOptions {
|
|||||||
double accel_bias_walk{1e-4};
|
double accel_bias_walk{1e-4};
|
||||||
double gravity_walk{0.0};
|
double gravity_walk{0.0};
|
||||||
// Quadrature/model error for unresolved between-sample dynamics, separate from sensor noise.
|
// Quadrature/model error for unresolved between-sample dynamics, separate from sensor noise.
|
||||||
double integration_error_scale{0.5};
|
double integration_error_scale{2.0};
|
||||||
double maximum_imu_gap{0.05};
|
double maximum_imu_gap{0.05};
|
||||||
};
|
};
|
||||||
struct FilterSnapshot {
|
struct FilterSnapshot {
|
||||||
@@ -21,6 +21,8 @@ struct FilterSnapshot {
|
|||||||
// Error order: position, velocity, right attitude error, gyro bias, accel bias, gravity.
|
// Error order: position, velocity, right attitude error, gyro bias, accel bias, gravity.
|
||||||
Matrix18 covariance{Matrix18::Identity()};
|
Matrix18 covariance{Matrix18::Identity()};
|
||||||
};
|
};
|
||||||
|
enum class InnovationCheck { FINAL, TRIAL };
|
||||||
|
|
||||||
class ErrorStateFilter {
|
class ErrorStateFilter {
|
||||||
public:
|
public:
|
||||||
explicit ErrorStateFilter(const NoiseOptions &noise = {});
|
explicit ErrorStateFilter(const NoiseOptions &noise = {});
|
||||||
@@ -31,7 +33,8 @@ public:
|
|||||||
// Fixed-prior iterated update. Hessian/gradient are from current point-plane residuals.
|
// Fixed-prior iterated update. Hessian/gradient are from current point-plane residuals.
|
||||||
bool correct_information(const FilterSnapshot &prior, const MotionState &linearization,
|
bool correct_information(const FilterSnapshot &prior, const MotionState &linearization,
|
||||||
const Matrix6 &information, const Vector6 &gradient,
|
const Matrix6 &information, const Vector6 &gradient,
|
||||||
const Matrix6 &projector, const Matrix6 &model_covariance = Matrix6::Zero());
|
const Matrix6 &projector, const Matrix6 &model_covariance = Matrix6::Zero(),
|
||||||
|
InnovationCheck check = InnovationCheck::FINAL);
|
||||||
double last_nis() const { return last_nis_; }
|
double last_nis() const { return last_nis_; }
|
||||||
int measurement_rank() const { return measurement_rank_; }
|
int measurement_rank() const { return measurement_rank_; }
|
||||||
const FilterSnapshot &snapshot() const { return estimate_; }
|
const FilterSnapshot &snapshot() const { return estimate_; }
|
||||||
@@ -40,7 +43,8 @@ public:
|
|||||||
static Vector18 difference(const MotionState &reference, const MotionState &state);
|
static Vector18 difference(const MotionState &reference, const MotionState &state);
|
||||||
private:
|
private:
|
||||||
bool update(const FilterSnapshot &prior, const Eigen::Matrix<double,6,18> &h,
|
bool update(const FilterSnapshot &prior, const Eigen::Matrix<double,6,18> &h,
|
||||||
const Vector6 &innovation, const Matrix6 &noise, const Matrix6 &projector);
|
const Vector6 &innovation, const Matrix6 &noise, const Matrix6 &projector,
|
||||||
|
InnovationCheck check = InnovationCheck::FINAL);
|
||||||
double last_nis_{0};
|
double last_nis_{0};
|
||||||
int measurement_rank_{0};
|
int measurement_rank_{0};
|
||||||
NoiseOptions noise_;
|
NoiseOptions noise_;
|
||||||
|
|||||||
@@ -39,8 +39,8 @@ struct RegistrationOptions {
|
|||||||
// Shared map/association uncertainty does not shrink with the number of scan points.
|
// Shared map/association uncertainty does not shrink with the number of scan points.
|
||||||
double map_translation_sigma{0.02};
|
double map_translation_sigma{0.02};
|
||||||
double map_rotation_sigma{0.002};
|
double map_rotation_sigma{0.002};
|
||||||
double huber_threshold{0.05};
|
double huber_threshold{0.025};
|
||||||
double max_plane_distance{0.2};
|
double max_plane_distance{0.12};
|
||||||
double max_rmse{0.1};
|
double max_rmse{0.1};
|
||||||
double minimum_inlier_ratio{0.2};
|
double minimum_inlier_ratio{0.2};
|
||||||
std::size_t minimum_inliers{50};
|
std::size_t minimum_inliers{50};
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ inline Matrix6 base_pose_covariance(const LocalizationSnapshot &s,const Pose3D &
|
|||||||
return j*s.filter.covariance*j.transpose();
|
return j*s.filter.covariance*j.transpose();
|
||||||
}
|
}
|
||||||
struct HealthOptions {
|
struct HealthOptions {
|
||||||
double correction_timeout{0.3},imu_timeout{0.1},clock_tolerance{0.02};
|
double correction_timeout{0.3},imu_timeout{0.1},clock_tolerance{0.05};
|
||||||
double position_three_sigma{0.5},yaw_three_sigma{15*std::numbers::pi/180};
|
double position_three_sigma{0.5},yaw_three_sigma{15*std::numbers::pi/180};
|
||||||
std::size_t recovery_scans{5};
|
std::size_t recovery_scans{5};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ Vector18 ErrorStateFilter::difference(const MotionState &a,const MotionState &b)
|
|||||||
return d;
|
return d;
|
||||||
}
|
}
|
||||||
bool ErrorStateFilter::update(const FilterSnapshot &prior,const Eigen::Matrix<double,6,18> &h,
|
bool ErrorStateFilter::update(const FilterSnapshot &prior,const Eigen::Matrix<double,6,18> &h,
|
||||||
const Vector6 &innovation,const Matrix6 &noise,const Matrix6 &projector) {
|
const Vector6 &innovation,const Matrix6 &noise,const Matrix6 &projector,InnovationCheck gate) {
|
||||||
if(!h.allFinite() || !innovation.allFinite() || !noise.allFinite() || !projector.allFinite()) return false;
|
if(!h.allFinite() || !innovation.allFinite() || !noise.allFinite() || !projector.allFinite()) return false;
|
||||||
const Eigen::SelfAdjointEigenSolver<Matrix6> spectrum(h*h.transpose());
|
const Eigen::SelfAdjointEigenSolver<Matrix6> spectrum(h*h.transpose());
|
||||||
if(spectrum.info()!=Eigen::Success) return false;
|
if(spectrum.info()!=Eigen::Success) return false;
|
||||||
@@ -97,7 +97,7 @@ bool ErrorStateFilter::update(const FilterSnapshot &prior,const Eigen::Matrix<do
|
|||||||
last_nis_=innovation.dot(solver.solve(innovation));
|
last_nis_=innovation.dot(solver.solve(innovation));
|
||||||
// Chi-square 99.9% bounds for the retained measurement rank, not always six DOF.
|
// Chi-square 99.9% bounds for the retained measurement rank, not always six DOF.
|
||||||
constexpr double gates[]{0,10.827566,13.815511,16.266236,18.466827,20.515006,22.457744};
|
constexpr double gates[]{0,10.827566,13.815511,16.266236,18.466827,20.515006,22.457744};
|
||||||
if(!std::isfinite(last_nis_) || last_nis_>gates[measurement_rank_]) return false;
|
if(!std::isfinite(last_nis_) || (gate==InnovationCheck::FINAL && last_nis_>gates[measurement_rank_])) return false;
|
||||||
Eigen::Matrix<double,18,6> k=prior.covariance*h.transpose()*solver.solve(Matrix6::Identity());
|
Eigen::Matrix<double,18,6> k=prior.covariance*h.transpose()*solver.solve(Matrix6::Identity());
|
||||||
const auto selector=pose_selector();
|
const auto selector=pose_selector();
|
||||||
const Eigen::Matrix<double,6,6> pose_k=projector*(selector*k);
|
const Eigen::Matrix<double,6,6> pose_k=projector*(selector*k);
|
||||||
@@ -128,7 +128,7 @@ bool ErrorStateFilter::correct_pose(const Pose3D &measurement,const Matrix6 &noi
|
|||||||
return update(estimate_,projector*pose_selector(),projector*innovation,r,projector);
|
return update(estimate_,projector*pose_selector(),projector*innovation,r,projector);
|
||||||
}
|
}
|
||||||
bool ErrorStateFilter::correct_information(const FilterSnapshot &prior,const MotionState &linearization,
|
bool ErrorStateFilter::correct_information(const FilterSnapshot &prior,const MotionState &linearization,
|
||||||
const Matrix6 &information,const Vector6 &gradient,const Matrix6 &projector,const Matrix6 &model_covariance) {
|
const Matrix6 &information,const Vector6 &gradient,const Matrix6 &projector,const Matrix6 &model_covariance,InnovationCheck gate) {
|
||||||
const Matrix6 retained_information=projector*information*projector.transpose();
|
const Matrix6 retained_information=projector*information*projector.transpose();
|
||||||
const Vector6 retained_gradient=projector*gradient;
|
const Vector6 retained_gradient=projector*gradient;
|
||||||
const Eigen::SelfAdjointEigenSolver<Matrix6> eig(retained_information);
|
const Eigen::SelfAdjointEigenSolver<Matrix6> eig(retained_information);
|
||||||
@@ -151,6 +151,6 @@ bool ErrorStateFilter::correct_information(const FilterSnapshot &prior,const Mot
|
|||||||
Matrix6 prior_projector=Matrix6::Zero();
|
Matrix6 prior_projector=Matrix6::Zero();
|
||||||
for(int i=0;i<6;++i) if(observable.eigenvalues()[i]>1e-10*std::max(1.0,observable.eigenvalues().maxCoeff()))
|
for(int i=0;i<6;++i) if(observable.eigenvalues()[i]>1e-10*std::max(1.0,observable.eigenvalues().maxCoeff()))
|
||||||
prior_projector.noalias()+=observable.eigenvectors().col(i)*observable.eigenvectors().col(i).transpose();
|
prior_projector.noalias()+=observable.eigenvectors().col(i)*observable.eigenvectors().col(i).transpose();
|
||||||
return update(prior,h,innovation,Matrix6::Identity()+whitening*model_covariance*whitening.transpose(),prior_projector);
|
return update(prior,h,innovation,Matrix6::Identity()+whitening*model_covariance*whitening.transpose(),prior_projector,gate);
|
||||||
}
|
}
|
||||||
} // namespace field_localization::core
|
} // namespace field_localization::core
|
||||||
@@ -147,6 +147,9 @@ RegistrationResult scan_to_map(const PointCloud &cloud,const Pose3D &extrinsic,c
|
|||||||
result.degeneracy=detect_degeneracy(l.h/std::max(1.0,static_cast<double>(l.inliers)),o);
|
result.degeneracy=detect_degeneracy(l.h/std::max(1.0,static_cast<double>(l.inliers)),o);
|
||||||
result.estimate=filter.snapshot();
|
result.estimate=filter.snapshot();
|
||||||
};
|
};
|
||||||
|
Matrix6 model_covariance=Matrix6::Zero();
|
||||||
|
model_covariance.topLeftCorner<3,3>().diagonal().setConstant(o.map_translation_sigma*o.map_translation_sigma);
|
||||||
|
model_covariance.bottomRightCorner<3,3>().diagonal().setConstant(o.map_rotation_sigma*o.map_rotation_sigma);
|
||||||
for (int iteration=0;iteration<o.maximum_iterations;++iteration) {
|
for (int iteration=0;iteration<o.maximum_iterations;++iteration) {
|
||||||
const auto before=filter.snapshot().state;
|
const auto before=filter.snapshot().state;
|
||||||
const auto l=linearize(scan,extrinsic,map,before,o);
|
const auto l=linearize(scan,extrinsic,map,before,o);
|
||||||
@@ -154,21 +157,31 @@ RegistrationResult scan_to_map(const PointCloud &cloud,const Pose3D &extrinsic,c
|
|||||||
if (l.inliers<o.minimum_inliers) return result;
|
if (l.inliers<o.minimum_inliers) return result;
|
||||||
const auto deg=detect_degeneracy(l.h/static_cast<double>(l.inliers),o);
|
const auto deg=detect_degeneracy(l.h/static_cast<double>(l.inliers),o);
|
||||||
if (deg.dimensions==6) { result.failure=RegistrationFailure::DEGENERATE; return result; }
|
if (deg.dimensions==6) { result.failure=RegistrationFailure::DEGENERATE; return result; }
|
||||||
const Matrix6 h=deg.projector*l.h*deg.projector;
|
// Trial iterates update correspondence geometry in this private filter.
|
||||||
const Vector6 gradient=deg.projector*l.gradient;
|
// The innovation gate is evaluated against the original prior once those
|
||||||
Matrix6 model_covariance=Matrix6::Zero();
|
// correspondences have settled, before the result can reach LocalizationCore.
|
||||||
model_covariance.topLeftCorner<3,3>().diagonal().setConstant(o.map_translation_sigma*o.map_translation_sigma);
|
const bool updated=filter.correct_information(prediction,before,l.h,l.gradient,
|
||||||
model_covariance.bottomRightCorner<3,3>().diagonal().setConstant(o.map_rotation_sigma*o.map_rotation_sigma);
|
deg.projector,model_covariance,InnovationCheck::TRIAL);
|
||||||
const bool updated=filter.correct_information(prediction,before,h,gradient,deg.projector,model_covariance);
|
|
||||||
result.nis=filter.last_nis(); result.measurement_rank=filter.measurement_rank();
|
result.nis=filter.last_nis(); result.measurement_rank=filter.measurement_rank();
|
||||||
if (!updated) { result.failure=RegistrationFailure::INNOVATION; return result; }
|
if (!updated) { result.failure=RegistrationFailure::INNOVATION; return result; }
|
||||||
|
const auto trial=ErrorStateFilter::difference(prediction.state,filter.snapshot().state);
|
||||||
|
if (trial.head<3>().norm()>=0.5 || trial.segment<3>(6).norm()>=0.35) {
|
||||||
|
result.failure=RegistrationFailure::QUALITY; return result;
|
||||||
|
}
|
||||||
const auto step=ErrorStateFilter::difference(before,filter.snapshot().state);
|
const auto step=ErrorStateFilter::difference(before,filter.snapshot().state);
|
||||||
if (step.segment<3>(0).norm()<1e-4 && step.segment<3>(6).norm()<1e-4) break;
|
if (step.segment<3>(0).norm()<1e-4 && step.segment<3>(6).norm()<1e-4) break;
|
||||||
}
|
}
|
||||||
const auto final=linearize(scan,extrinsic,map,filter.snapshot().state,o);
|
const auto final=linearize(scan,extrinsic,map,filter.snapshot().state,o);
|
||||||
record(final);
|
record(final);
|
||||||
|
if (result.inliers<o.minimum_inliers) return result;
|
||||||
|
if (result.degeneracy.dimensions==6) { result.failure=RegistrationFailure::DEGENERATE; return result; }
|
||||||
|
const bool fused=filter.correct_information(prediction,filter.snapshot().state,
|
||||||
|
final.h,final.gradient,result.degeneracy.projector,model_covariance);
|
||||||
|
result.nis=filter.last_nis(); result.measurement_rank=filter.measurement_rank();
|
||||||
|
if (!fused) { result.failure=RegistrationFailure::INNOVATION; return result; }
|
||||||
|
record(linearize(scan,extrinsic,map,filter.snapshot().state,o));
|
||||||
const auto change=ErrorStateFilter::difference(prediction.state,filter.snapshot().state);
|
const auto change=ErrorStateFilter::difference(prediction.state,filter.snapshot().state);
|
||||||
result.success=final.inliers>=o.minimum_inliers && result.inlier_ratio>=o.minimum_inlier_ratio &&
|
result.success=result.inliers>=o.minimum_inliers && result.inlier_ratio>=o.minimum_inlier_ratio &&
|
||||||
result.rmse<=o.max_rmse && result.degeneracy.dimensions<6 &&
|
result.rmse<=o.max_rmse && result.degeneracy.dimensions<6 &&
|
||||||
change.segment<3>(0).norm()<0.5 && change.segment<3>(6).norm()<0.35;
|
change.segment<3>(0).norm()<0.5 && change.segment<3>(6).norm()<0.35;
|
||||||
result.failure=result.success ? RegistrationFailure::NONE : RegistrationFailure::QUALITY;
|
result.failure=result.success ? RegistrationFailure::NONE : RegistrationFailure::QUALITY;
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ LocalizationNode::LocalizationNode(const rclcpp::NodeOptions &options):Node("fie
|
|||||||
core_options_.noise.gyro=declare_parameter<double>("gyro_noise_density",0.003);
|
core_options_.noise.gyro=declare_parameter<double>("gyro_noise_density",0.003);
|
||||||
core_options_.noise.accel=declare_parameter<double>("accel_noise_density",0.03);
|
core_options_.noise.accel=declare_parameter<double>("accel_noise_density",0.03);
|
||||||
core_options_.noise.gyro_bias_walk=declare_parameter<double>("gyro_bias_walk",1e-5);
|
core_options_.noise.gyro_bias_walk=declare_parameter<double>("gyro_bias_walk",1e-5);
|
||||||
core_options_.noise.integration_error_scale=declare_parameter<double>("integration_error_scale",0.5);
|
core_options_.noise.integration_error_scale=declare_parameter<double>("integration_error_scale",core_options_.noise.integration_error_scale);
|
||||||
core_options_.noise.accel_bias_walk=declare_parameter<double>("accel_bias_walk",1e-4);
|
core_options_.noise.accel_bias_walk=declare_parameter<double>("accel_bias_walk",1e-4);
|
||||||
core_options_.map_resolution=declare_parameter<double>("map_voxel_size",0.1);
|
core_options_.map_resolution=declare_parameter<double>("map_voxel_size",0.1);
|
||||||
core_options_.registration.map_translation_sigma=declare_parameter<double>("map_translation_sigma",0.02);
|
core_options_.registration.map_translation_sigma=declare_parameter<double>("map_translation_sigma",0.02);
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1 @@
|
|||||||
|
21.5 -4.9584264520627084 2.8312555285145069 0.066642701693339218 0.28925532856581104 -0.18381915008460603 -0.088000693255994411 -0.00067113795667528883 0.0020454012507826885 -0.59983425677615865 0.8001213847319415 0.00013545462743937917 -0.00011407959527293953 7.7473698313815906e-05 0.094527591711915243 -0.018654076254896023 0.0059506817166394832 0.09629720315366537 -0.0095379732857951496 -9.8076595698943176 5.4211970910770516e-05 -1.6913810010464369e-06 7.7093436287022919e-08 0.00019387688324965145 -3.9371910845080579e-05 -3.076733516773156e-09 -6.5879156639180102e-08 3.3594270298662e-08 -6.9256690960194507e-08 2.7813913824052845e-09 -3.9388948155551208e-09 2.7030692132274592e-09 6.7300085074034144e-05 -0.00014701238697221737 -3.6740275206857811e-07 6.7649803199897789e-05 -0.00014627685630574802 -4.5186245904610204e-07 -1.6913810010464369e-06 5.72793708146413e-05 2.8440372274030672e-07 -3.2377452257135454e-05 0.00025496896000278674 7.2995229948893227e-07 5.0336174808415647e-08 8.6199059252662469e-08 -5.8734582018920561e-09 -3.5968463297817861e-09 -4.8402498733582902e-09 1.616767127151391e-10 0.00012940623942249684 7.7784760250283177e-05 -6.2149350554646791e-08 0.00012864861059710134 7.8059097522582328e-05 6.5809483616306078e-08 7.7093436287022919e-08 2.8440372274030672e-07 4.4887792501138219e-05 1.6481005494312824e-07 3.3036051466097291e-07 9.4396205964828535e-05 1.0746546275263083e-07 7.1978980696136641e-08 -4.56926219074464e-09 -9.2063759574381534e-09 -2.9925456873137583e-09 1.0356849209793115e-10 4.1101855612585824e-08 8.5015802052718161e-08 -5.6829671521961278e-06 4.3297632733567627e-08 8.3966956861444471e-08 2.2914719948329354e-07 0.00019387688324965145 -3.2377452257135454e-05 1.6481005494312824e-07 0.0014059864076449847 -0.00060156667631372442 -1.4477134773688117e-06 -2.1823656182909228e-06 5.9188720608873556e-07 -1.4649709427784945e-07 1.3273493659769134e-07 -6.9244332841764212e-08 6.2740980664033955e-09 0.00089514847072110935 -0.0013394792725598911 -8.5265579403348356e-06 0.00089525610558024722 -0.0013328928842766964 -9.1617952588180192e-06 -3.9371910845080579e-05 0.00025496896000278674 3.3036051466097291e-07 -0.00060156667631372442 0.002463472591958255 3.5836619389065894e-06 -4.4575707601887398e-07 -1.1768510327073258e-06 9.9552288663074785e-08 4.6256335948957022e-08 7.1161172428782834e-08 -4.2102789712100902e-09 0.0011477879323172333 0.00065501652442554468 -1.9605052538671123e-06 0.0011427053782942492 0.00065527039106214242 -1.0098242081899217e-06 -3.076733516773156e-09 7.2995229948893227e-07 9.4396205964828535e-05 -1.4477134773688117e-06 3.5836619389065894e-06 0.00043323801298578271 4.7889351727371411e-07 -3.7836925694658505e-08 -6.0909800875255969e-09 -7.3782931566863936e-09 2.1482886014884101e-08 -8.1860284535393516e-11 2.4471929872239124e-06 1.5975125965650238e-06 -2.6141701453767846e-05 2.5003766573461859e-06 1.5647774043328547e-06 1.0714728784118976e-06 -6.5879156639180102e-08 5.0336174808415647e-08 1.0746546275263083e-07 -2.1823656182909228e-06 -4.4575707601887398e-07 4.7889351727371411e-07 1.8634814206817319e-06 -6.5406181501742526e-08 -5.9879319969574165e-09 -1.1308758845294002e-07 3.2875194268899705e-08 3.6605395830826769e-10 9.5395073951606776e-07 -1.2086054116854707e-06 -1.7791229708523751e-08 9.5805103233717334e-07 -1.1994805300485477e-06 4.4726135709942555e-10 3.3594270298662e-08 8.6199059252662469e-08 7.1978980696136641e-08 5.9188720608873556e-07 -1.1768510327073258e-06 -3.7836925694658505e-08 -6.5406181501742526e-08 1.6306204086006391e-06 -3.7659580115382053e-09 -1.9568111489965129e-08 -1.0266195435166226e-07 1.6962366071786955e-10 9.9466921733896439e-07 1.0447122421018458e-06 -3.3863971471289592e-09 9.8565734537631504e-07 1.0470045147292737e-06 1.4724984962219323e-09 -6.9256690960194507e-08 -5.8734582018920561e-09 -4.56926219074464e-09 -1.4649709427784945e-07 9.9552288663074785e-08 -6.0909800875255969e-09 -5.9879319969574165e-09 -3.7659580115382053e-09 1.738679824274879e-06 3.0547132036890773e-10 4.9222657173568789e-11 -7.974542467371376e-08 -9.6533208413801504e-08 1.1328959003903214e-07 3.6098490506195615e-10 -9.6748486948590507e-08 1.1239758479133494e-07 6.7324089562498283e-11 2.7813913824052845e-09 -3.5968463297817861e-09 -9.2063759574381534e-09 1.3273493659769134e-07 4.6256335948957022e-08 -7.3782931566863936e-09 -1.1308758845294002e-07 -1.9568111489965129e-08 3.0547132036890773e-10 6.0976535317072009e-07 -5.3356788860148487e-10 -1.3567694186530896e-10 -1.0852134915108957e-07 -8.0855594335962174e-08 -3.6660465634396378e-10 -1.0355841555197264e-07 -7.5482084479384465e-08 3.5358876726330169e-11 -3.9388948155551208e-09 -4.8402498733582902e-09 -2.9925456873137583e-09 -6.9244332841764212e-08 7.1161172428782834e-08 2.1482886014884101e-08 3.2875194268899705e-08 -1.0266195435166226e-07 4.9222657173568789e-11 -5.3356788860148487e-10 6.101867536363909e-07 3.7511965469393576e-11 7.998411272557813e-08 -1.39999752509837e-07 -1.7172385625784348e-09 7.6460470194792003e-08 -1.36667696931179Line truncated
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
FIELD_LIO_DATASET 1
|
||||||
|
initial_pose -5 3 0 0 0 0 1
|
||||||
|
base_from_imu 0 0 0.14999999999999999 0 0 0 1
|
||||||
|
imu_from_lidar -0.0935 -0.1512 0.25519999999999998 0 0 0 1
|
||||||
|
scan_timing 0 0.10000000000000001 -3.1415926535897931 1 1
|
||||||
@@ -0,0 +1,62 @@
|
|||||||
|
timestamp,gx,gy,gz,ax,ay,az
|
||||||
|
21.5,0.027876815948866075,0.030751855940937323,-1.1842935700125712,-0.023111402382871217,-0.1395854844850429,9.8048196820867783
|
||||||
|
21.510000000000002,-0.017607971943273938,-0.019452753963797663,-1.0602135046058219,-1.8701885300232559,-4.8705061252712838,9.8492370134248119
|
||||||
|
21.52,-0.018846260953600025,-0.022937105492543533,-1.0885774106073516,1.7897503972716406,-0.52672997202580918,10.044685765383601
|
||||||
|
21.530000000000001,-0.016026186362089922,-0.020400366678482509,-1.0917241522243037,-0.62935551826196445,-0.1902268052569194,9.8327730329417005
|
||||||
|
21.539999999999999,-0.0039680052956488614,-0.0048802501128351631,-1.0654810805867481,-0.44032183352333709,-0.87969651611324595,9.7995619192456243
|
||||||
|
21.550000000000001,0.003925853378591285,0.0043237549583911806,-1.050994136270337,-0.44419549879966652,-0.97063770692490714,9.7865771166979361
|
||||||
|
21.559999999999999,0.015521072951268861,0.018556156846335888,-1.0353119198407827,-0.44966512255833768,-1.1168820870323035,9.7662886848858701
|
||||||
|
21.57,-0.010713980836765676,-0.013782805389494718,-0.94648142161182514,1.0499207329160547,-1.5307281829738353,9.8558645017074973
|
||||||
|
21.579999999999998,0.0031908795850543073,0.0035817993979718257,-0.92877659759056419,-0.4049306552659751,-1.4212029132690633,9.753489507374999
|
||||||
|
21.59,-0.021896214870731016,-0.027220937407084374,-1.046273171064463,-0.019080772620131286,-0.6706677557942925,9.8494812269271783
|
||||||
|
21.600000000000001,-0.0066984038660593166,-0.011113690260045382,-1.0149032364140909,-0.57963659076810203,-0.72547828545723159,9.7982242770199388
|
||||||
|
21.609999999999999,-0.039158333081591237,-0.052117197217750884,-0.89957843673794069,3.139885509588999,-1.5781583695599466,9.9983700160178195
|
||||||
|
21.620000000000001,-0.027351924574812329,-0.031862753564538271,-0.88420699018074034,0.69448039315213117,-1.6305374543474735,9.2340980561444557
|
||||||
|
21.629999999999999,-0.015742222043143166,-0.016493939663926746,-0.88981339413502702,0.13150673202177771,-1.1306170708571193,9.7647431139790921
|
||||||
|
21.640000000000001,-0.004022699885873662,-0.001259569669767647,-0.89551123337432403,0.13599635495643095,-1.1261639413381019,9.7647800516600576
|
||||||
|
21.649999999999999,0.0053353662239785616,0.010725575725301893,-0.90942875157974634,0.15789610004821517,-1.0530705154987865,9.7628617078795266
|
||||||
|
21.66,0.016491250498544736,0.024609379686451945,-0.91558626730855419,0.13365907581890527,-1.0429172980073094,9.7708766453126117
|
||||||
|
21.670000000000002,-0.021584399663932677,-0.024912300322534046,-0.76095815345993478,6.334705400986917,-1.9226497375982048,10.16362673678579
|
||||||
|
21.68,-0.024613197565842172,-0.028395976761316468,-0.72376627351450273,0.16010078508940159,-1.1232093770948182,9.7658992604965018
|
||||||
|
21.690000000000001,-0.01332931734631751,-0.01358980859023368,-0.72760711502275677,0.16465795448040937,-1.120516879442744,9.7659457879414191
|
||||||
|
21.699999999999999,-0.0019575192421991657,0.0011106136969861063,-0.73150418485493418,0.16801879382850354,-1.1169314917879238,9.7659654174605368
|
||||||
|
21.710000000000001,-0.044054573922724313,-0.053285716147205384,-0.61035702732550567,6.0602938776630646,-1.7233623359755605,10.128535591728884
|
||||||
|
21.719999999999999,-0.033182538192041783,-0.038747817964841308,-0.61310117399133168,0.18427679543960218,-1.1232537058471808,9.7662459312502019
|
||||||
|
21.73,0.0065937579963648487,0.01220371761027326,-0.61819333204270599,0.42320660850550007,-1.1077954778840988,9.7787270047329358
|
||||||
|
21.739999999999998,0.017743748619107744,0.026227702779281103,-0.62109178345466298,0.17964983435637935,-1.07910404731498,9.7687556248026848
|
||||||
|
21.75,0.032070966256201157,0.044123934778049302,-0.6215635501503658,0.84781519798736116,-1.1424853289040711,9.8052938196326451
|
||||||
|
21.760000000000002,0.04323159084711134,0.05774811074414956,-0.62595909325220001,0.17881946371284294,-1.0776411109044441,9.7676732379160764
|
||||||
|
21.77,0.014565654737886168,0.020141041915345721,-0.51962271077133859,3.5985100821990623,-1.301336010579152,9.9755222340616978
|
||||||
|
21.780000000000001,0.025801767523406849,0.034196267656947055,-0.52176828690226362,0.18271536293139218,-1.0746575281330528,9.768878610689395
|
||||||
|
21.789999999999999,0.037193714362879646,0.048275107001682457,-0.52410013243946096,0.1837758742603682,-1.0694389692875366,9.7691355126248602
|
||||||
|
21.800000000000001,0.01223316024587217,0.019170210150084323,-0.45087651659991557,-0.0016956389731149143,-0.025951705650085775,9.8096683309132633
|
||||||
|
21.809999999999999,-0.00014021699382744945,0.087350461521265688,-0.35560102149335326,-12.017207426083699,12.525109252441553,17.022397415679425
|
||||||
|
21.82,-0.00018166526363231261,-0.0010756693194457732,-0.22095831438709318,-6.0427967228584052,0.88698691055288525,8.3850437959484463
|
||||||
|
21.829999999999998,-0.00040895771439254658,-0.086090056130199294,-0.21465058401431397,-6.0590794225276614,0.020058605902515955,8.397829504956416
|
||||||
|
21.84,-0.00026355398198325039,9.7904213798260322e-05,-4.2769962500452402e-07,-9.8707398799650079,-1.5965914924433029,9.8098653716609068
|
||||||
|
21.850000000000001,-0.00025050049702286293,9.3204854111866273e-05,-1.4542927798134628e-08,-9.8061290208515803,0.2527329127215982,9.8097768235231264
|
||||||
|
21.859999999999999,-0.00023879590816752226,8.7332624985708365e-05,-1.1593175628075952e-08,-0.001764775913125201,0.00036811344182996567,9.8095835903475646
|
||||||
|
21.870000000000001,-0.00022709254981645351,8.3052230814051822e-05,-1.0502390166897367e-08,9.9535930503896199e-05,0.00026561050962938242,9.8096475330243074
|
||||||
|
21.879999999999999,-0.00021596264222375556,7.8981892437700638e-05,-9.4969272472534689e-09,9.4713541093136591e-05,0.00025242575083570602,9.8096648083568869
|
||||||
|
21.890000000000001,-0.00020537820496690276,7.5111043850616314e-05,-8.5876661972860452e-09,9.0127483839020159e-05,0.000239887096402082,9.8096812369447548
|
||||||
|
21.899999999999999,-0.00019531250426390155,7.1429908199846623e-05,-7.7654053039581541e-09,8.5766177110097508e-05,0.00022796288931141036,9.8096968602951602
|
||||||
|
21.91,-0.00018574011653788892,6.7929187801640416e-05,-7.0218228570528799e-09,8.1618606354085882e-05,0.00021662302360277895,9.8097117178802993
|
||||||
|
21.920000000000002,-0.00017663686420234747,6.4600040662224806e-05,-6.3493930202361042e-09,7.7674297127672986e-05,0.00020583886784211096,9.8097258472369333
|
||||||
|
21.93,-0.00016797975459500661,6.1434058138850052e-05,-5.7413096683436485e-09,7.3923288085381996e-05,0.00019558319324319956,9.8097392840616973
|
||||||
|
21.940000000000001,-0.00015974692190305937,5.8423243706815917e-05,-5.1914176625325811e-09,7.035610602655997e-05,0.00018583010503157816,9.8097520623012606
|
||||||
|
21.949999999999999,-0.00015191757193588139,5.5559992759625349e-05,-4.6941504767884928e-09,6.6963741937274546e-05,0.00017655497694641463,9.8097642142377186
|
||||||
|
21.960000000000001,-0.00014447192960282323,5.2837073402874852e-05,-4.244473988010895e-09,6.3737628363540714e-05,0.0001677343891905942,9.8097757705710382
|
||||||
|
21.969999999999999,-0.00013739118896762418,5.0247608185847667e-05,-3.8378355327169014e-09,6.0669617530851912e-05,0.00015934606945459698,9.8097867604958644
|
||||||
|
21.98,-0.00013065746574668732,4.7785056735067413e-05,-3.470117895178189e-09,5.775196114331094e-05,0.00015136883648773686,9.8097972117756687
|
||||||
|
21.989999999999998,-0.00012425375213870804,4.5443199230114358e-05,-3.1375976145222629e-09,5.4977290465550821e-05,0.00014378254678249264,9.8098071508129543
|
||||||
|
22,-0.00011816387386841682,4.3216120697468507e-05,-2.8369073533752963e-09,5.2338597750746862e-05,0.00013656804408554844,9.809816602716035
|
||||||
|
22.010000000000002,-0.0001123724493311345,4.1098196068081264e-05,-2.5650018791755717e-09,4.9829218857646998e-05,0.00012970711036944108,9.8098255913621486
|
||||||
|
22.02,-0.00010686485074289968,3.9084075973122962e-05,-2.3191271625440211e-09,4.7442816148963473e-05,0.00012318242028306969,9.8098341394582906
|
||||||
|
22.030000000000001,-0.00010162716719666886,3.7168673228841246e-05,-2.0967926695168354e-09,4.5173362454866423e-05,0.00011697749758873088,9.8098422685983877
|
||||||
|
22.039999999999999,-9.6646169523062264e-05,3.534714999127065e-05,-1.895746026129816e-09,4.3015126098136043e-05,0.00011107667321795587,9.8098499993176098
|
||||||
|
22.050000000000001,-9.1909276878162586e-05,3.3614905535276057e-05,-1.7139503102811479e-09,4.0962656144982116e-05,0.0001054650458994324,9.8098573511448244
|
||||||
|
22.059999999999999,-8.7404524966776096e-05,3.1967564634825251e-05,-1.5495634754864029e-09,3.9010768977033052e-05,0.00010012844451797148,9.8098643426515846
|
||||||
|
22.07,-8.3120535823239054e-05,3.040096651154403e-05,-1.4009196137885638e-09,3.715453465619199e-05,9.5053392424021405e-05,9.80987099149886
|
||||||
|
22.079999999999998,-7.90464890723387e-05,2.8911154327071686e-05,-1.2665122120811435e-09,3.538926515309853e-05,9.0227073343135129e-05,9.809877314482172
|
||||||
|
22.09,-7.5172094600004836e-05,2.7494365189110178e-05,-1.1449788632454963e-09,3.3710502056849816e-05,8.5637298907652895e-05,9.8098833275738873
|
||||||
|
22.100000000000001,-7.1487566562624332e-05,2.6147020645983372e-05,-1.0350874626715972e-09,3.211400534500572e-05,8.1272478241284333e-05,9.8098890459632262
|
||||||
|
Binary file not shown.
@@ -0,0 +1,8 @@
|
|||||||
|
Gazebo isolated Python launch, cylinder at (-4,-1.5), radius .22 m, height .8 m.
|
||||||
|
Input acceleration/gyro are sensor-noise-free; finite-rate dynamics are not zero.
|
||||||
|
Checkpoint is the prior accepted estimate at sim 21.5 s from the pre-final-model run.
|
||||||
|
Five real scans 21.6--22.0 s and corresponding IMU samples reproduce the innovation
|
||||||
|
rejection cascade (NIS 31.6 then 35.1...) with an overconfident map model.
|
||||||
|
This is a recorded regression for a discovered failure during repair, not a claim
|
||||||
|
that the user's unrecorded original divergence has been reproduced exactly.
|
||||||
|
Ground truth is evaluation-only and never supplied to the filter.
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
timestamp,file
|
||||||
|
21.600000000000001,152.flpc
|
||||||
|
21.699999999999999,153.flpc
|
||||||
|
21.800000000000001,154.flpc
|
||||||
|
21.899999999999999,155.flpc
|
||||||
|
22,156.flpc
|
||||||
|
@@ -0,0 +1,5 @@
|
|||||||
|
21.6 -4.938314134624523 2.796687470553623 0.0030149441445529064 -0.0007754419507424783 -0.00012456097725818525 -0.6408927062560147 0.7676300686152059
|
||||||
|
21.7 -4.925609698330944 2.7637372767944877 0.0030671789615293672 -0.0015214828458520557 -0.000254778602981217 -0.6729537584402829 0.7396829450372034
|
||||||
|
21.8 -4.923934087982928 2.7224593206086922 0.002981906031251714 -0.000194014824747835 -7.274393365116528e-05 -0.6945213952429082 0.719472020732156
|
||||||
|
21.9 -4.923427531970908 2.7076583973333985 0.002987579905231361 9.171974543353667e-06 -1.9365968979289335e-05 -0.6979490977997831 0.7161473706027992
|
||||||
|
22.0 -4.923427531952121 2.7076583973504693 0.0029924332530261426 5.532422580515229e-06 -1.1786157218031994e-05 -0.6979490980902097 0.7161473705219769
|
||||||
@@ -0,0 +1,64 @@
|
|||||||
|
#include "field_localization/core/tracking_health.hpp"
|
||||||
|
#include "test_util.hpp"
|
||||||
|
#include <limits>
|
||||||
|
#include <numbers>
|
||||||
|
#include <random>
|
||||||
|
#include <cstdio>
|
||||||
|
using namespace field_localization::core;
|
||||||
|
namespace {
|
||||||
|
Pose3D truth(double t) {
|
||||||
|
return {exp_so3({0,0,0.15*std::sin(0.3*t)}),{-2+0.3*std::sin(0.4*t),-1+0.2*std::sin(0.5*t),0}};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
int main() {
|
||||||
|
std::vector<Eigen::Vector3d> map;
|
||||||
|
for(int x=-30;x<=30;++x) for(int y=-20;y<=20;++y) map.emplace_back(0.2*x,0.2*y,0);
|
||||||
|
for(int i=-60;i<=60;++i) for(int z=0;z<=4;++z) {
|
||||||
|
map.emplace_back(0.1*i,-4,0.1*z);map.emplace_back(0.1*i,4,0.1*z);
|
||||||
|
if(std::abs(i)<=40) { map.emplace_back(-6,0.1*i,0.1*z);map.emplace_back(6,0.1*i,0.1*z); }
|
||||||
|
}
|
||||||
|
for(int x=0;x<=10;++x) for(int y=-5;y<=5;++y) map.emplace_back(0.1*x,0.1*y,0.42);
|
||||||
|
for(bool noisy:{false,true}) {
|
||||||
|
CoreOptions options;options.initial_pose=truth(0);
|
||||||
|
options.deskew.imu_from_sensor.translation={-0.0935,-0.1512,0.2552};
|
||||||
|
LocalizationCore core(options);core.set_map_points(map);TrackingHealth health;
|
||||||
|
std::mt19937 random(42);std::normal_distribution<double> normal;
|
||||||
|
double maximum_error=0;int full=0;bool stopped=false,recovered=false;
|
||||||
|
for(int i=0;i<=2000;++i) {
|
||||||
|
const double t=0.01*i;const auto pose=truth(t);
|
||||||
|
ImuData imu;imu.timestamp_sec=t;imu.angular_velocity={0,0,0.045*std::cos(0.3*t)};
|
||||||
|
const Eigen::Vector3d acceleration{-0.048*std::sin(0.4*t),-0.05*std::sin(0.5*t),9.81};
|
||||||
|
imu.linear_acceleration=pose.rotation.conjugate()*acceleration;
|
||||||
|
if(noisy) for(int j=0;j<3;++j) { imu.angular_velocity[j]+=0.003*normal(random)+0.002;imu.linear_acceleration[j]+=0.03*normal(random)+0.02; }
|
||||||
|
CHECK(core.process_imu(imu));
|
||||||
|
if(i==0 || i%10) continue;
|
||||||
|
PointCloud scan;scan.timestamp_sec=t;
|
||||||
|
const auto lidar=compose(compose(pose,options.base_from_imu),options.deskew.imu_from_sensor);
|
||||||
|
auto add=[&](const Eigen::Vector3d &world) {
|
||||||
|
Eigen::Vector3d p=lidar.rotation.conjugate()*(world-lidar.translation);
|
||||||
|
const double range=p.norm(),elevation=std::atan2(p.z(),p.head<2>().norm());
|
||||||
|
if(range>12 || elevation < -7*std::numbers::pi/180 || elevation>52*std::numbers::pi/180) return;
|
||||||
|
if(noisy) for(int j=0;j<3;++j) p[j]+=0.005*normal(random);
|
||||||
|
PointXYZI point;point.timestamp_sec=t;point.position=p.cast<float>();scan.points.push_back(point);
|
||||||
|
};
|
||||||
|
for(const auto &p:map) add(p);
|
||||||
|
// Previously unmapped object, taller than the static 0.42 m field.
|
||||||
|
if(t>=4 && t<=14) for(int angle=0;angle<48;++angle) for(int z=1;z<=8;++z)
|
||||||
|
add({-1.3+0.22*std::cos(angle*2*std::numbers::pi/48),-1+0.22*std::sin(angle*2*std::numbers::pi/48),0.1*z});
|
||||||
|
if(t>=8 && t<8.8) scan.points.clear(); // complete observation failure
|
||||||
|
PointXYZI invalid;invalid.timestamp_sec=t;invalid.position.setConstant(std::numeric_limits<float>::infinity());
|
||||||
|
scan.points.push_back(invalid);
|
||||||
|
const bool accepted=core.process_point_cloud(scan);
|
||||||
|
CHECK(accepted==(t<8 || t>=8.8));
|
||||||
|
const auto snapshot=core.get_snapshot();const bool valid=health.update(snapshot,options.base_from_imu,t);
|
||||||
|
if(t>=8.4 && t<8.8) { CHECK(!valid);stopped=true; }
|
||||||
|
if(t>10 && valid) recovered=true;
|
||||||
|
if(snapshot.status.mode==TrackingMode::FULL) ++full;
|
||||||
|
maximum_error=std::max(maximum_error,(snapshot.pose.translation-pose.translation).norm());
|
||||||
|
CHECK(snapshot.pose.translation.allFinite());CHECK(snapshot.filter.covariance.allFinite());
|
||||||
|
}
|
||||||
|
std::printf("2.5D noisy=%d FULL=%d/200 maximum_position_error=%.9gm stopped=%d recovered=%d\n",noisy,full,maximum_error,stopped,recovered);
|
||||||
|
CHECK(full>=180);CHECK(maximum_error<0.15);CHECK(stopped);CHECK(recovered);
|
||||||
|
}
|
||||||
|
return sentry_nav_test::Summary("FieldTracking");
|
||||||
|
}
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
#include "field_localization/core/dataset.hpp"
|
||||||
|
#include "test_util.hpp"
|
||||||
|
#include <Eigen/Eigenvalues>
|
||||||
|
#include <fstream>
|
||||||
|
#include <sstream>
|
||||||
|
#include <cstdio>
|
||||||
|
using namespace field_localization::core;
|
||||||
|
int main(int argc,char **argv) {
|
||||||
|
CHECK(argc==2);if(argc!=2) return 1;
|
||||||
|
const std::filesystem::path directory=argv[1];
|
||||||
|
auto options=read_dataset_config(directory/"config.txt");
|
||||||
|
FilterSnapshot checkpoint;auto &s=checkpoint.state;std::ifstream input(directory/"checkpoint.txt");
|
||||||
|
input>>s.timestamp_sec;
|
||||||
|
for(auto *v:{&s.pose.translation,&s.velocity}) for(int i=0;i<3;++i) input>>(*v)[i];
|
||||||
|
for(int i=0;i<4;++i) input>>s.pose.rotation.coeffs()[i];
|
||||||
|
for(auto *v:{&s.gyro_bias,&s.accel_bias,&s.gravity}) for(int i=0;i<3;++i) input>>(*v)[i];
|
||||||
|
for(int i=0;i<18;++i) for(int j=0;j<18;++j) input>>checkpoint.covariance(i,j);
|
||||||
|
CHECK(static_cast<bool>(input));
|
||||||
|
std::string error;const auto map=read_map(directory/"map.flmap",error);CHECK(map.has_value());if(!map) return 1;
|
||||||
|
ErrorStateFilter filter;filter.restore(checkpoint);
|
||||||
|
std::vector<ImuData> samples;std::ifstream imu(directory/"imu.csv");std::string line;std::getline(imu,line);
|
||||||
|
while(std::getline(imu,line)) {
|
||||||
|
std::replace(line.begin(),line.end(),',',' ');std::istringstream row(line);ImuData value;
|
||||||
|
row>>value.timestamp_sec>>value.angular_velocity.x()>>value.angular_velocity.y()>>value.angular_velocity.z()
|
||||||
|
>>value.linear_acceleration.x()>>value.linear_acceleration.y()>>value.linear_acceleration.z();
|
||||||
|
CHECK(static_cast<bool>(row));samples.push_back(value);
|
||||||
|
}
|
||||||
|
const auto truth=read_trajectory(directory/"truth.tum");
|
||||||
|
std::ifstream scans(directory/"scans.csv");std::getline(scans,line);int full=0;double maximum=0;
|
||||||
|
while(std::getline(scans,line)) {
|
||||||
|
const auto cloud=read_cloud(directory/line.substr(line.find(',')+1));
|
||||||
|
auto a=interpolate_imu(samples,filter.snapshot().state.timestamp_sec);CHECK(a.has_value());if(!a) return 1;
|
||||||
|
for(const auto &b:samples) if(b.timestamp_sec>a->timestamp_sec && b.timestamp_sec<cloud.timestamp_sec) {
|
||||||
|
CHECK(filter.propagate(*a,b));a=b;
|
||||||
|
}
|
||||||
|
const auto finish=interpolate_imu(samples,cloud.timestamp_sec);CHECK(finish.has_value());if(!finish) return 1;
|
||||||
|
if(finish->timestamp_sec>a->timestamp_sec) CHECK(filter.propagate(*a,*finish));
|
||||||
|
const auto result=scan_to_map(cloud,options.deskew.imu_from_sensor,*map,filter.snapshot());
|
||||||
|
CHECK(result.success);if(result.success) {filter.restore(result.estimate);++full;}
|
||||||
|
const auto base=compose(filter.snapshot().state.pose,inverse(options.base_from_imu));
|
||||||
|
const auto gt=trajectory_pose(truth,cloud.timestamp_sec);CHECK(gt.has_value());if(!gt) return 1;
|
||||||
|
maximum=std::max(maximum,(base.translation-gt->translation).norm());
|
||||||
|
CHECK(log_so3(gt->rotation.conjugate()*base.rotation).norm()<0.02);
|
||||||
|
const Eigen::SelfAdjointEigenSolver<Matrix18> eigen(filter.snapshot().covariance);
|
||||||
|
CHECK(eigen.info()==Eigen::Success);CHECK(eigen.eigenvalues().minCoeff()>-1e-10);
|
||||||
|
}
|
||||||
|
std::printf("recorded transition: FULL=%d/5 maximum_position_error=%.9g m\n",full,maximum);
|
||||||
|
CHECK(full==5);CHECK(maximum<0.10);
|
||||||
|
return sentry_nav_test::Summary("RecordedUpdate");
|
||||||
|
}
|
||||||
@@ -40,6 +40,19 @@ int main() {
|
|||||||
CHECK(plane.degeneracy.projector.col(1).norm()<1e-8);
|
CHECK(plane.degeneracy.projector.col(1).norm()<1e-8);
|
||||||
CHECK(plane.degeneracy.projector.col(5).norm()<1e-8);
|
CHECK(plane.degeneracy.projector.col(5).norm()<1e-8);
|
||||||
CHECK_NEAR(plane.estimate.covariance(0,0),filter.snapshot().covariance(0,0),1e-12);
|
CHECK_NEAR(plane.estimate.covariance(0,0),filter.snapshot().covariance(0,0),1e-12);
|
||||||
|
// An offset plane yields plenty of inliers but disagrees with a confident
|
||||||
|
// prediction. Trial re-association still has to pass the final innovation gate.
|
||||||
|
PointCloud shifted=planar;
|
||||||
|
for (auto &point:shifted.points) point.position.z()+=0.09F;
|
||||||
|
FilterSnapshot confident;
|
||||||
|
confident.covariance=1e-6*Matrix18::Identity();
|
||||||
|
RegistrationOptions strict;
|
||||||
|
strict.map_translation_sigma=0.01;
|
||||||
|
const auto rejected=scan_to_map(shifted,{},floor,confident,{},strict);
|
||||||
|
CHECK(!rejected.success);
|
||||||
|
CHECK(rejected.failure==RegistrationFailure::INNOVATION);
|
||||||
|
CHECK(rejected.inliers>100);
|
||||||
|
CHECK(rejected.measurement_rank==3);
|
||||||
// Rotate the whole plane; verify its null space rather than an axis label.
|
// Rotate the whole plane; verify its null space rather than an axis label.
|
||||||
Matrix6 transform=Matrix6::Identity();
|
Matrix6 transform=Matrix6::Identity();
|
||||||
const Eigen::Matrix3d rotation=exp_so3({0.4,-0.3,0.1}).toRotationMatrix();
|
const Eigen::Matrix3d rotation=exp_so3({0.4,-0.3,0.1}).toRotationMatrix();
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ int main() {
|
|||||||
CHECK(health.update(s,{},0.1*i)==(i==5));
|
CHECK(health.update(s,{},0.1*i)==(i==5));
|
||||||
for(int j=0;j<20;++j) CHECK(health.update(s,{},0.1*i)==(i==5));
|
for(int j=0;j<20;++j) CHECK(health.update(s,{},0.1*i)==(i==5));
|
||||||
}
|
}
|
||||||
CHECK(health.update(s,{},s.status.state_timestamp-0.002)); // sensor callback can precede /clock by one tick
|
CHECK(health.update(s,{},s.status.state_timestamp-0.022)); // measured /clock delivery skew
|
||||||
s.status.mode=TrackingMode::IMU_ONLY;s.status.state_timestamp=0.7;
|
s.status.mode=TrackingMode::IMU_ONLY;s.status.state_timestamp=0.7;
|
||||||
CHECK(health.update(s,{},0.7)); // bounded short IMU-only grace period
|
CHECK(health.update(s,{},0.7)); // bounded short IMU-only grace period
|
||||||
s.status.state_timestamp=0.81;CHECK(!health.update(s,{},0.81));
|
s.status.state_timestamp=0.81;CHECK(!health.update(s,{},0.81));
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
Arena validation, 2026-11-22
|
||||||
|
GCC 15.2 / C++23, xmake release, zero compiler warnings; 15/15 test suites.
|
||||||
|
Five-frame contact fixture: all scan corrections accepted; maximum 3D error
|
||||||
|
below 0.10 m. A separate shifted-plane case was rejected by the final NIS
|
||||||
|
gate despite plenty of inliers.
|
||||||
|
|
||||||
|
Isolated Shell and Python launchers used the same map, start (-5,3) and
|
||||||
|
goal (0,0). The added cylinder was centered at (-4,-1.5), radius 0.22 m
|
||||||
|
and height 0.8 m. Acceptance requires Nav2 success, truth goal error <=0.30 m,
|
||||||
|
3D ATE <0.10 m, maximum 3D position error <0.25 m, and nonnegative clearance.
|
||||||
|
The final parameter file has SHA-256
|
||||||
|
ba353622d65e94628689842cbc55052420e529d9cba46cb9aee5742b28a16e9d.
|
||||||
|
|
||||||
|
Cylinder acceptance: Shell 2/3; Python 0/3 (2/3 reached the goal).
|
||||||
|
The two passing runs had cylinder clearances 0.1441 and 0.1215 m and
|
||||||
|
maximum position errors 0.0855 and 0.0798 m. Other runs either exhausted
|
||||||
|
recovery near the cylinder or exceeded the 3D position error criterion.
|
||||||
|
The vertical error reached 0.652 m in a weakly observed direction in one
|
||||||
|
run. The horizontal/yaw interlock does not guarantee vertical accuracy.
|
||||||
|
|
||||||
|
Replay of the passing Shell cylinder: 369/369 corrections, 100% matched
|
||||||
|
truth samples; translation/rotation ATE 0.01992 m / 0.3233 degrees,
|
||||||
|
translation/rotation 1 s RPE 0.01746 m / 0.1919 degrees. No trajectory alignment.
|
||||||
|
Lidar loss in the final Python configuration: first measured zero output
|
||||||
|
310 ms after injection, active goal canceled. No competing AMCL or map-to-odom
|
||||||
|
publisher was present. The original user failure lacks a synchronized recording,
|
||||||
|
and full navigation acceptance remains open.
|
||||||
@@ -393,6 +393,14 @@ target("test_tracking_safety")
|
|||||||
add_deps("field_localization_core")
|
add_deps("field_localization_core")
|
||||||
add_tests("default", {group = "unit"})
|
add_tests("default", {group = "unit"})
|
||||||
|
|
||||||
|
target("test_field_tracking")
|
||||||
|
set_targetdir("$(builddir)/bin")
|
||||||
|
set_kind("binary")
|
||||||
|
set_languages("c++23")
|
||||||
|
add_files("tests/test_field_tracking.cpp")
|
||||||
|
add_deps("field_localization_core")
|
||||||
|
add_tests("default", {group = "unit"})
|
||||||
|
|
||||||
target("test_filter_consistency")
|
target("test_filter_consistency")
|
||||||
set_targetdir("$(builddir)/bin")
|
set_targetdir("$(builddir)/bin")
|
||||||
set_kind("binary")
|
set_kind("binary")
|
||||||
@@ -400,3 +408,14 @@ target("test_filter_consistency")
|
|||||||
add_files("tests/test_filter_consistency.cpp")
|
add_files("tests/test_filter_consistency.cpp")
|
||||||
add_deps("field_localization_core")
|
add_deps("field_localization_core")
|
||||||
add_tests("default", {group = "unit"})
|
add_tests("default", {group = "unit"})
|
||||||
|
|
||||||
|
target("test_recorded_update")
|
||||||
|
set_targetdir("$(builddir)/bin")
|
||||||
|
set_kind("binary")
|
||||||
|
set_languages("c++23")
|
||||||
|
add_files("tests/test_recorded_update.cpp")
|
||||||
|
add_deps("field_localization_core")
|
||||||
|
on_load(function(target)
|
||||||
|
target:set("runargs", {path.join(os.projectdir(), "src/field_localization/tests/data/turn_contact")})
|
||||||
|
end)
|
||||||
|
add_tests("default", {group = "unit"})
|
||||||
@@ -278,7 +278,8 @@ local_costmap:
|
|||||||
footprint: "[[0.325, 0.270], [0.325, -0.270], [-0.325, -0.270], [-0.325, 0.270]]"
|
footprint: "[[0.325, 0.270], [0.325, -0.270], [-0.325, -0.270], [-0.325, 0.270]]"
|
||||||
# MID-360 的 3D 点云已接入(/scan/points,PointCloud2)
|
# MID-360 的 3D 点云已接入(/scan/points,PointCloud2)
|
||||||
# MID-360 点云经 sentry_nav/self_filter 自滤(剔除车身包围盒内的点)后接入
|
# MID-360 点云经 sentry_nav/self_filter 自滤(剔除车身包围盒内的点)后接入
|
||||||
plugins: ["voxel_layer", "inflation_layer"]
|
# Retain known thin/occluded geometry when the live cloud sparsely samples it.
|
||||||
|
plugins: ["static_layer", "voxel_layer", "inflation_layer"]
|
||||||
voxel_layer:
|
voxel_layer:
|
||||||
plugin: "nav2_costmap_2d::VoxelLayer"
|
plugin: "nav2_costmap_2d::VoxelLayer"
|
||||||
enabled: True
|
enabled: True
|
||||||
@@ -310,7 +311,7 @@ local_costmap:
|
|||||||
inflation_layer:
|
inflation_layer:
|
||||||
plugin: "nav2_costmap_2d::InflationLayer"
|
plugin: "nav2_costmap_2d::InflationLayer"
|
||||||
cost_scaling_factor: 2.0
|
cost_scaling_factor: 2.0
|
||||||
inflation_radius: 0.45
|
inflation_radius: 0.60 # Give the rectangular base room to turn around dynamic obstacles.
|
||||||
static_layer:
|
static_layer:
|
||||||
plugin: "nav2_costmap_2d::StaticLayer"
|
plugin: "nav2_costmap_2d::StaticLayer"
|
||||||
map_subscribe_transient_local: true
|
map_subscribe_transient_local: true
|
||||||
@@ -361,7 +362,7 @@ global_costmap:
|
|||||||
inflation_layer:
|
inflation_layer:
|
||||||
plugin: "nav2_costmap_2d::InflationLayer"
|
plugin: "nav2_costmap_2d::InflationLayer"
|
||||||
cost_scaling_factor: 2.0
|
cost_scaling_factor: 2.0
|
||||||
inflation_radius: 0.45
|
inflation_radius: 0.60 # Give the rectangular base room to turn around dynamic obstacles.
|
||||||
always_send_full_costmap: true
|
always_send_full_costmap: true
|
||||||
introspection_mode: "disabled"
|
introspection_mode: "disabled"
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,65 @@
|
|||||||
|
"""Independent-frame trajectory metrics; no alignment or ground-truth feedback."""
|
||||||
|
import bisect
|
||||||
|
import math
|
||||||
|
|
||||||
|
|
||||||
|
def conjugate(q):
|
||||||
|
return [-q[0],-q[1],-q[2],q[3]]
|
||||||
|
|
||||||
|
|
||||||
|
def multiply(a,b):
|
||||||
|
x,y,z,w=a;X,Y,Z,W=b
|
||||||
|
return [w*X+x*W+y*Z-z*Y,w*Y-x*Z+y*W+z*X,w*Z+x*Y-y*X+z*W,w*W-x*X-y*Y-z*Z]
|
||||||
|
|
||||||
|
|
||||||
|
def rotate(q,p):
|
||||||
|
return multiply(multiply(q,[*p,0]),conjugate(q))[:3]
|
||||||
|
|
||||||
|
|
||||||
|
def angle(q):
|
||||||
|
return 2*math.acos(min(1,abs(q[3])/math.sqrt(sum(x*x for x in q))))
|
||||||
|
|
||||||
|
|
||||||
|
def interpolate(rows,t,gap=0.05):
|
||||||
|
i=bisect.bisect_left(rows,[t])
|
||||||
|
if i<len(rows) and abs(rows[i][0]-t)<1e-8:return rows[i][1:]
|
||||||
|
if i==0 or i==len(rows) or rows[i][0]-rows[i-1][0]>gap:return None
|
||||||
|
a,b=rows[i-1],rows[i];u=(t-a[0])/(b[0]-a[0])
|
||||||
|
p=[(1-u)*a[j]+u*b[j] for j in range(1,4)]
|
||||||
|
sign=1 if sum(a[j]*b[j] for j in range(4,8))>=0 else -1
|
||||||
|
q=[(1-u)*a[j]+u*sign*b[j] for j in range(4,8)];norm=math.sqrt(sum(x*x for x in q))
|
||||||
|
return p+[x/norm for x in q]
|
||||||
|
|
||||||
|
|
||||||
|
def metrics(estimate,truth):
|
||||||
|
# A single pose per stamp; ordering changes never create false zero-duration RPE.
|
||||||
|
estimate=sorted({row[0]:row for row in estimate}.values())
|
||||||
|
truth=sorted({row[0]:row for row in truth}.values())
|
||||||
|
translation=[];rotation=[];relative_t=[];relative_r=[]
|
||||||
|
for row in estimate:
|
||||||
|
t=row[0];e=row[1:];g=interpolate(truth,t)
|
||||||
|
if g is None:continue
|
||||||
|
translation.append(sum((e[j]-g[j])**2 for j in range(3)))
|
||||||
|
rotation.append(angle(multiply(conjugate(g[3:]),e[3:]))**2)
|
||||||
|
en=interpolate(estimate,t+1);gn=interpolate(truth,t+1)
|
||||||
|
if en is None or gn is None:continue
|
||||||
|
ep=rotate(conjugate(e[3:]),[en[j]-e[j] for j in range(3)])
|
||||||
|
gp=rotate(conjugate(g[3:]),[gn[j]-g[j] for j in range(3)])
|
||||||
|
relative_t.append(sum((ep[j]-gp[j])**2 for j in range(3)))
|
||||||
|
eq=multiply(conjugate(e[3:]),en[3:]);gq=multiply(conjugate(g[3:]),gn[3:])
|
||||||
|
relative_r.append(angle(multiply(conjugate(gq),eq))**2)
|
||||||
|
def rmse(values):return math.sqrt(sum(values)/len(values)) if values else None
|
||||||
|
return {'matched':len(translation),'total':len(estimate),'rpe_pairs':len(relative_t),
|
||||||
|
'ate_translation_m':rmse(translation),'ate_rotation_deg':None if not rotation else math.degrees(rmse(rotation)),
|
||||||
|
'rpe_1s_translation_m':rmse(relative_t),'rpe_1s_rotation_deg':None if not relative_r else math.degrees(rmse(relative_r)),
|
||||||
|
'maximum_position_error_m':math.sqrt(max(translation)) if translation else None}
|
||||||
|
|
||||||
|
|
||||||
|
def cylinder_clearance(row,x,y,radius):
|
||||||
|
q=row[4:];yaw=math.atan2(2*(q[3]*q[2]+q[0]*q[1]),1-2*(q[1]*q[1]+q[2]*q[2]))
|
||||||
|
dx,dy=x-row[1],y-row[2]
|
||||||
|
bx=math.cos(yaw)*dx+math.sin(yaw)*dy;by=-math.sin(yaw)*dx+math.cos(yaw)*dy
|
||||||
|
# Union of the actual SDF chassis and gimbal collision boxes.
|
||||||
|
chassis=math.hypot(max(0,abs(bx)-0.289),max(0,abs(by)-0.2605))
|
||||||
|
gimbal=math.hypot(max(0,abs(bx-0.12)-0.20),max(0,abs(by)-0.15))
|
||||||
|
return min(chassis,gimbal)-radius
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
"""Run three cold starts per route/launcher, plus a blocked-goal check."""
|
||||||
|
import argparse
|
||||||
|
import json
|
||||||
|
from pathlib import Path
|
||||||
|
import signal
|
||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
parser=argparse.ArgumentParser(description=__doc__)
|
||||||
|
parser.add_argument('--launcher',choices=['shell','python'],required=True)
|
||||||
|
parser.add_argument('--output',type=Path,required=True)
|
||||||
|
parser.add_argument('--map',type=Path,required=True)
|
||||||
|
parser.add_argument('--domain', type=int, choices=range(1, 233), metavar='[1–232]')
|
||||||
|
parser.add_argument('--scenario', action='append', choices=['clear', 'cylinder', 'blocked', 'lidar_loss'])
|
||||||
|
parser.add_argument('--repeats', type=int)
|
||||||
|
args=parser.parse_args()
|
||||||
|
if args.repeats is not None and args.repeats < 1:
|
||||||
|
parser.error('repeats must be positive')
|
||||||
|
if args.output.exists():parser.error('output must be new')
|
||||||
|
args.output.mkdir(parents=True)
|
||||||
|
root=Path(__file__).resolve().parents[1]
|
||||||
|
results=[]
|
||||||
|
for scenario in args.scenario or ['clear', 'cylinder', 'blocked']:
|
||||||
|
count = args.repeats if args.repeats is not None else (3 if scenario in ('clear', 'cylinder') else 1)
|
||||||
|
for index in range(1, count+1):
|
||||||
|
name=f'{scenario}_{index}';folder=args.output/name
|
||||||
|
with open(args.output/(name+'.log'),'w') as log:
|
||||||
|
command=[sys.executable,str(root/'tools/validate_lio_navigation.py'),
|
||||||
|
'--launcher',args.launcher,'--map',str(args.map.resolve()),'--output',str(folder.resolve()),
|
||||||
|
'--scenario',scenario,'--goal','0','0']
|
||||||
|
if args.domain is not None:
|
||||||
|
command.extend(['--domain', str(args.domain)])
|
||||||
|
child=subprocess.Popen(command,cwd=root,stdout=log,stderr=subprocess.STDOUT,start_new_session=True)
|
||||||
|
try:code=child.wait()
|
||||||
|
except KeyboardInterrupt:
|
||||||
|
child.send_signal(signal.SIGINT)
|
||||||
|
child.wait(timeout=30)
|
||||||
|
raise
|
||||||
|
file=folder/'result.json'
|
||||||
|
result=json.loads(file.read_text()) if file.exists() else {'passed':False,'error':'no result'}
|
||||||
|
results.append({'name':name,'exit_code':code,**result})
|
||||||
|
(args.output/'summary.json').write_text(json.dumps(results,indent=2))
|
||||||
|
print(f'{args.launcher} {name}: passed={result.get("passed")} goal={result.get("goal_succeeded")} metrics={result.get("trajectory_metrics")}',flush=True)
|
||||||
|
return 0 if all(r['passed'] and r['exit_code']==0 for r in results) else 1
|
||||||
|
|
||||||
|
|
||||||
|
if __name__=='__main__':sys.exit(main())
|
||||||
@@ -0,0 +1,334 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
"""Run an isolated Gazebo navigation scenario and score it using simulator truth."""
|
||||||
|
import argparse
|
||||||
|
import hashlib
|
||||||
|
import json
|
||||||
|
import math
|
||||||
|
import os
|
||||||
|
from pathlib import Path
|
||||||
|
import signal
|
||||||
|
import subprocess
|
||||||
|
import time
|
||||||
|
import uuid
|
||||||
|
from collections import Counter
|
||||||
|
|
||||||
|
import rclpy
|
||||||
|
from rclpy.node import Node
|
||||||
|
from rclpy.parameter import Parameter
|
||||||
|
from lifecycle_msgs.srv import GetState
|
||||||
|
from tf2_msgs.msg import TFMessage
|
||||||
|
from nav2_msgs.srv import IsPathValid
|
||||||
|
from nav_msgs.msg import Odometry
|
||||||
|
from geometry_msgs.msg import PoseStamped, Twist
|
||||||
|
from rclpy.qos import qos_profile_sensor_data
|
||||||
|
from std_msgs.msg import Bool
|
||||||
|
from rcl_interfaces.srv import GetParameters
|
||||||
|
from std_srvs.srv import Trigger
|
||||||
|
from rclpy.utilities import get_rmw_implementation_identifier
|
||||||
|
from nav2_startup import path_probe_request
|
||||||
|
|
||||||
|
from dds_environment import defaults as dds_defaults
|
||||||
|
from lio_metrics import cylinder_clearance, metrics
|
||||||
|
from verify_lio_stack import NODES, process_environment
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
parser = argparse.ArgumentParser(description=__doc__)
|
||||||
|
parser.add_argument('--map', type=Path, required=True)
|
||||||
|
parser.add_argument('--launcher', choices=['shell', 'python'], default='shell')
|
||||||
|
parser.add_argument('--output', type=Path, required=True)
|
||||||
|
parser.add_argument('--goal', nargs=2, type=float, metavar=('X', 'Y'))
|
||||||
|
parser.add_argument('--domain', type=int, choices=range(1, 233), metavar='[1–232]',
|
||||||
|
help='use an explicitly reserved ROS_DOMAIN_ID for parallel tests')
|
||||||
|
parser.add_argument('--timeout', type=float, default=420.0,
|
||||||
|
help='whole-stack validation deadline, including up to three startup attempts')
|
||||||
|
parser.add_argument('--scenario', choices=['clear', 'cylinder', 'blocked', 'lidar_loss'], default='clear')
|
||||||
|
parser.add_argument('--obstacle-x',type=float,default=-4.0)
|
||||||
|
parser.add_argument('--obstacle-y',type=float,default=-1.5)
|
||||||
|
parser.add_argument('--obstacle-radius',type=float,default=0.22)
|
||||||
|
parser.add_argument('--rviz', action='store_true', help='include offscreen RViz discovery load')
|
||||||
|
args = parser.parse_args()
|
||||||
|
if not args.map.is_file():
|
||||||
|
parser.error('map missing')
|
||||||
|
if args.output.exists():
|
||||||
|
parser.error('output must be a new directory')
|
||||||
|
args.output.mkdir(parents=True)
|
||||||
|
session = uuid.uuid4().hex[:12]
|
||||||
|
os.environ.update(ROS_DOMAIN_ID=str(args.domain if args.domain is not None else 50+int(session[:8], 16) % 50), GZ_PARTITION=f'lio_stack_{session}',
|
||||||
|
ROS2CLI_DISABLE_DAEMON='1',
|
||||||
|
HEADLESS='1', NAV2='1', RVIZ='0', LOCALIZATION='lio', LIO_MODE='localization',
|
||||||
|
LIO_MAP=str(args.map.resolve()), SENTRY_RUNTIME_DIR=str((args.output/'runtime').resolve()),
|
||||||
|
LIO_TRACE_PATH=str((args.output/'filter_trace.csv').resolve()), SENTRY_LOG=str((args.output/'stack.log').resolve()))
|
||||||
|
os.environ.update(dds_defaults(os.environ))
|
||||||
|
workspace = Path(__file__).resolve().parents[1]
|
||||||
|
params_file = workspace/'src/sentry_sim/config/nav2_params.yaml'
|
||||||
|
runtime = {
|
||||||
|
'domain': os.environ['ROS_DOMAIN_ID'],
|
||||||
|
'partition': os.environ['GZ_PARTITION'],
|
||||||
|
'scenario': args.scenario,
|
||||||
|
'obstacle': [args.obstacle_x, args.obstacle_y, args.obstacle_radius],
|
||||||
|
'nav2_config_sha256': hashlib.sha256(params_file.read_bytes()).hexdigest(),
|
||||||
|
}
|
||||||
|
(args.output/'runtime.json').write_text(json.dumps(runtime, indent=2))
|
||||||
|
log = None
|
||||||
|
record_log = open(args.output/'record.log', 'w', encoding='utf8')
|
||||||
|
recorder = subprocess.Popen([str(workspace/'build/bin/field_localization_record'), '--ros-args',
|
||||||
|
'-p', 'use_sim_time:=true', '-p', f'output_directory:={args.output.resolve()}/dataset',
|
||||||
|
'-p', 'duration_sec:=600.0'], stdout=record_log, stderr=subprocess.STDOUT, start_new_session=True)
|
||||||
|
if args.launcher == 'shell':
|
||||||
|
command = ['bash', str(workspace/'scripts/sentry_up.sh')]
|
||||||
|
else:
|
||||||
|
command = ['ros2', 'launch', str(workspace/'src/sentry_sim/launch/sentry_arena.launch.py'),
|
||||||
|
'headless:=true', 'rviz:=false', 'localization:=lio', f'lio_map:={args.map.resolve()}']
|
||||||
|
log = open(args.output/'stack.log', 'w', encoding='utf8')
|
||||||
|
started = time.monotonic()
|
||||||
|
process = subprocess.Popen(command, cwd=workspace, start_new_session=True,
|
||||||
|
stdout=log if log else subprocess.DEVNULL, stderr=subprocess.STDOUT)
|
||||||
|
rclpy.init()
|
||||||
|
node = Node('verify_lio_stack', parameter_overrides=[Parameter('use_sim_time', value=True)])
|
||||||
|
publishers = set()
|
||||||
|
samples = {'truth': [], 'estimate': []}
|
||||||
|
health_events=[]
|
||||||
|
actuator=[]
|
||||||
|
subscription_actuator=node.create_subscription(Twist,'/model/sentry/cmd_vel',lambda msg:actuator.append((time.monotonic(),msg.linear.x,msg.linear.y,msg.angular.z)),100)
|
||||||
|
subscriptions_health=node.create_subscription(Bool,'/field_localization/navigation_valid',
|
||||||
|
lambda msg:health_events.append((time.monotonic(),msg.data)),10)
|
||||||
|
subscriptions = []
|
||||||
|
def sample(message, name):
|
||||||
|
p = message.pose.pose if name == 'estimate' else message.pose
|
||||||
|
samples[name].append([message.header.stamp.sec+1e-9*message.header.stamp.nanosec,
|
||||||
|
p.position.x,p.position.y,p.position.z,p.orientation.x,p.orientation.y,p.orientation.z,p.orientation.w])
|
||||||
|
subscriptions.append(node.create_subscription(PoseStamped, '/evaluation/ground_truth',
|
||||||
|
lambda msg: sample(msg, 'truth'), qos_profile_sensor_data))
|
||||||
|
subscriptions.append(node.create_subscription(Odometry, '/field_localization/odometry',
|
||||||
|
lambda msg: sample(msg, 'estimate'), qos_profile_sensor_data))
|
||||||
|
counts = {'map_to_odom': 0, 'map_to_base_link': 0}
|
||||||
|
|
||||||
|
def on_tf(msg, info):
|
||||||
|
for transform in msg.transforms:
|
||||||
|
if transform.header.frame_id != 'map':
|
||||||
|
continue
|
||||||
|
if transform.child_frame_id == 'odom':
|
||||||
|
gid = info['publisher_gid'] if isinstance(info, dict) else info.publisher_gid
|
||||||
|
publishers.add(json.dumps(gid, sort_keys=True, default=str))
|
||||||
|
counts['map_to_odom'] += 1
|
||||||
|
if transform.child_frame_id == 'base_link':
|
||||||
|
counts['map_to_base_link'] += 1
|
||||||
|
|
||||||
|
subscription = node.create_subscription(TFMessage, '/tf', on_tf, 500)
|
||||||
|
clients = {name: node.create_client(GetState, f'/{name}/get_state') for name in NODES}
|
||||||
|
path_client = node.create_client(IsPathValid, '/is_path_valid')
|
||||||
|
active_client = node.create_client(Trigger, '/lifecycle_manager_nav2/is_active')
|
||||||
|
parameter_client = node.create_client(GetParameters, '/lifecycle_manager_nav2/get_parameters')
|
||||||
|
states = {}
|
||||||
|
processes = []
|
||||||
|
rviz = None
|
||||||
|
goal = None
|
||||||
|
reached_readiness = False
|
||||||
|
result = {}
|
||||||
|
try:
|
||||||
|
if args.rviz:
|
||||||
|
rviz = subprocess.Popen(['ros2', 'run', 'rviz2', 'rviz2', '-d',
|
||||||
|
str(workspace/'src/sentry_sim/config/sentry.rviz'), '--ros-args',
|
||||||
|
'-p', 'use_sim_time:=true'],
|
||||||
|
env={**os.environ, 'QT_QPA_PLATFORM': 'offscreen'},
|
||||||
|
start_new_session=True, stdout=subprocess.DEVNULL, stderr=subprocess.STDOUT)
|
||||||
|
deadline = time.monotonic()+args.timeout
|
||||||
|
last_check = 0.0
|
||||||
|
stable_since = None
|
||||||
|
manager_completed = False
|
||||||
|
while time.monotonic() < deadline:
|
||||||
|
rclpy.spin_once(node, timeout_sec=0.1)
|
||||||
|
if process.poll() is not None:
|
||||||
|
raise RuntimeError('stack exited')
|
||||||
|
if time.monotonic()-last_check < 0.5:
|
||||||
|
continue
|
||||||
|
last_check = time.monotonic()
|
||||||
|
if not processes and time.monotonic()-started > 8:
|
||||||
|
processes = process_environment(process.pid)
|
||||||
|
states = {}
|
||||||
|
pending = {}
|
||||||
|
for name, client in clients.items():
|
||||||
|
if not client.service_is_ready():
|
||||||
|
continue
|
||||||
|
pending[name] = client.call_async(GetState.Request())
|
||||||
|
poll_end = time.monotonic()+1
|
||||||
|
while time.monotonic() < poll_end and any(not f.done() for f in pending.values()):
|
||||||
|
rclpy.spin_once(node, timeout_sec=0.02)
|
||||||
|
for name, future in pending.items():
|
||||||
|
if future.done() and future.result():
|
||||||
|
states[name] = future.result().current_state.id
|
||||||
|
else:
|
||||||
|
clients[name].remove_pending_request(future)
|
||||||
|
log_path = args.output/'stack.log'
|
||||||
|
text = log_path.read_text(errors='replace') if log_path.exists() else ''
|
||||||
|
manager_completed = any('lifecycle_manager_nav2' in line and 'Managed nodes are active' in line
|
||||||
|
for line in text.splitlines())
|
||||||
|
if all(states.get(name) == 3 for name in NODES) and counts['map_to_odom'] > 20 and manager_completed and health_events and health_events[-1][1]:
|
||||||
|
if stable_since is None:
|
||||||
|
stable_since = time.monotonic()
|
||||||
|
if time.monotonic()-stable_since >= 2:
|
||||||
|
reached_readiness = True
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
stable_since = None
|
||||||
|
processes = process_environment(process.pid)
|
||||||
|
names = sorted(set(node.get_node_names()))
|
||||||
|
path_ready = path_client.wait_for_service(timeout_sec=2)
|
||||||
|
path_response = None
|
||||||
|
if path_ready:
|
||||||
|
future = path_client.call_async(path_probe_request())
|
||||||
|
rclpy.spin_until_future_complete(node, future, timeout_sec=3)
|
||||||
|
if future.done() and future.result() is not None:
|
||||||
|
path_response = str(future.result())
|
||||||
|
manager_active = False
|
||||||
|
if active_client.wait_for_service(timeout_sec=1):
|
||||||
|
future = active_client.call_async(Trigger.Request())
|
||||||
|
rclpy.spin_until_future_complete(node, future, timeout_sec=2)
|
||||||
|
manager_active = bool(future.done() and future.result() and future.result().success)
|
||||||
|
managed_nodes = []
|
||||||
|
if parameter_client.wait_for_service(timeout_sec=1):
|
||||||
|
future = parameter_client.call_async(GetParameters.Request(names=['node_names']))
|
||||||
|
rclpy.spin_until_future_complete(node, future, timeout_sec=2)
|
||||||
|
if future.done() and future.result() and future.result().values:
|
||||||
|
managed_nodes = list(future.result().values[0].string_array_value)
|
||||||
|
result = {'launcher': args.launcher, 'startup_seconds': time.monotonic()-started,
|
||||||
|
'startup_attempts': sum('startup attempt ' in line for line in text.splitlines()),
|
||||||
|
'rmw': get_rmw_implementation_identifier(), 'processes': processes,
|
||||||
|
'node_counts': dict(Counter(node.get_node_names())),
|
||||||
|
'services': dict(node.get_service_names_and_types()),
|
||||||
|
'path_service_endpoints': {'servers': list(map(str, node.get_servers_info_by_service('/is_path_valid'))),
|
||||||
|
'clients': list(map(str, node.get_clients_info_by_service('/is_path_valid')))},
|
||||||
|
'is_path_valid_discovered': path_ready, 'is_path_valid_response': path_response,
|
||||||
|
'topic_qos':{topic:[{'node':p.node_name,'reliability':str(p.qos_profile.reliability)} for p in node.get_publishers_info_by_topic(topic)] for topic in ['/scan/points','/scan/points_filtered','/imu']},
|
||||||
|
'manager_active': manager_active, 'managed_nodes': managed_nodes,
|
||||||
|
'manager_completed': manager_completed, 'lifecycle_states': states, 'amcl_present': 'amcl' in names,
|
||||||
|
'lio_present': 'field_localization' in names, 'map_to_odom_publishers': len(publishers), **counts}
|
||||||
|
result['passed'] = (reached_readiness and manager_completed and manager_active and path_response is not None
|
||||||
|
and bool(managed_nodes) and all(states.get(name) == 3 for name in managed_nodes)
|
||||||
|
and all(states.get(name) == 3 for name in NODES) and not result['amcl_present']
|
||||||
|
and result['lio_present'] and len(publishers) == 1 and counts['map_to_odom'] > 0
|
||||||
|
and counts['map_to_base_link'] == 0)
|
||||||
|
(args.output/'result.json').write_text(json.dumps(result, indent=2))
|
||||||
|
if args.scenario in ('cylinder','blocked') and result['passed']:
|
||||||
|
# Obstacle lies on the initial straight corridor; a route around the cylinder exists.
|
||||||
|
shape = f'<cylinder><radius>{args.obstacle_radius}</radius><length>0.8</length></cylinder>'
|
||||||
|
pose = f'{args.obstacle_x} {args.obstacle_y} 0.4 0 0 0'
|
||||||
|
if args.scenario == 'blocked':
|
||||||
|
shape = '<box><size>1.6 1.6 0.8</size></box>'
|
||||||
|
pose = '0 0 0.4 0 0 0'
|
||||||
|
sdf = f'<sdf version="1.9"><model name="validation_obstacle"><static>true</static><pose>{pose}</pose><link name="body"><collision name="collision"><geometry>{shape}</geometry></collision><visual name="visual"><geometry>{shape}</geometry></visual></link></model></sdf>'
|
||||||
|
gz = subprocess.run(['/usr/bin/gz', 'service', '-s', '/world/rmul_arena/create',
|
||||||
|
'--reqtype', 'gz.msgs.EntityFactory', '--reptype', 'gz.msgs.Boolean', '--timeout', '5000',
|
||||||
|
'--req', 'sdf: '+json.dumps(sdf)], capture_output=True,text=True,timeout=10)
|
||||||
|
(args.output/'obstacle.log').write_text(gz.stdout+gz.stderr)
|
||||||
|
if gz.returncode or 'data: true' not in gz.stdout:
|
||||||
|
raise RuntimeError('obstacle insertion failed')
|
||||||
|
until=time.monotonic()+2
|
||||||
|
while time.monotonic()<until:
|
||||||
|
rclpy.spin_once(node,timeout_sec=0.02)
|
||||||
|
if args.goal and result['passed']:
|
||||||
|
goal_start_sim=node.get_clock().now().nanoseconds*1e-9
|
||||||
|
goal_start_wall=time.monotonic()
|
||||||
|
goal = subprocess.Popen([str(workspace/'build/bin/nav_client'), *map(str, args.goal), '0'],
|
||||||
|
stdout=open(args.output/'goal.log','w'), stderr=subprocess.STDOUT, text=True, start_new_session=True)
|
||||||
|
until=time.monotonic()+(240 if args.scenario=="blocked" else 120)
|
||||||
|
fault_time=None
|
||||||
|
while goal.poll() is None and time.monotonic()<until:
|
||||||
|
rclpy.spin_once(node,timeout_sec=0.02)
|
||||||
|
if args.scenario=='lidar_loss' and fault_time is None and time.monotonic()-goal_start_wall>=5 and actuator and sum(abs(v) for v in actuator[-1][1:])>0.1:
|
||||||
|
owned=process_environment(process.pid)
|
||||||
|
sensors=[p['pid'] for p in owned if p['executable'] and Path(p['executable'][0]).name=='self_filter']
|
||||||
|
if len(sensors)!=1:
|
||||||
|
raise RuntimeError('cannot identify the owned self_filter for fault injection')
|
||||||
|
fault_time=time.monotonic();os.kill(sensors[0],signal.SIGTERM)
|
||||||
|
if goal.poll() is None:
|
||||||
|
os.killpg(goal.pid,signal.SIGINT)
|
||||||
|
goal.wait(timeout=5)
|
||||||
|
goal.stdout_text=(args.output/'goal.log').read_text()
|
||||||
|
if args.scenario == 'blocked':
|
||||||
|
terminal_time = time.monotonic()
|
||||||
|
while time.monotonic() - terminal_time < 0.5:
|
||||||
|
rclpy.spin_once(node, timeout_sec=0.02)
|
||||||
|
result['blocked_zero_output'] = bool(
|
||||||
|
actuator and actuator[-1][0] > terminal_time and actuator[-1][1:] == (0, 0, 0)
|
||||||
|
)
|
||||||
|
result['passed'] = result['passed'] and result['blocked_zero_output']
|
||||||
|
result.update(counts)
|
||||||
|
result['map_to_odom_publishers'] = len(publishers)
|
||||||
|
result['amcl_present'] = 'amcl' in node.get_node_names()
|
||||||
|
result['passed'] = (result['passed'] and len(publishers) == 1
|
||||||
|
and counts['map_to_base_link'] == 0
|
||||||
|
and not result['amcl_present'])
|
||||||
|
result['goal_exit_code'] = goal.returncode
|
||||||
|
if args.scenario=='lidar_loss':
|
||||||
|
stops=[t for t,x,y,z in actuator if fault_time is not None and t>=fault_time and x==0 and y==0 and z==0]
|
||||||
|
result['fault_stop_delay_sec']=min(stops)-fault_time if stops else None
|
||||||
|
result['fault_goal_canceled']='结果: ❌ CANCELED' in goal.stdout_text
|
||||||
|
result['goal_succeeded'] = '结果: ✅ SUCCEEDED' in goal.stdout_text
|
||||||
|
result['goal_elapsed_wall_sec']=time.monotonic()-goal_start_wall
|
||||||
|
result['trajectory_metrics']=metrics(samples['estimate'],samples['truth'])
|
||||||
|
truth_goal=[row for row in samples['truth'] if row[0]>=goal_start_sim]
|
||||||
|
result['truth_goal_error_m']=math.hypot(truth_goal[-1][1]-args.goal[0],truth_goal[-1][2]-args.goal[1]) if truth_goal else None
|
||||||
|
result['minimum_cylinder_clearance_m']=min(cylinder_clearance(row,args.obstacle_x,args.obstacle_y,args.obstacle_radius) for row in truth_goal) if truth_goal and args.scenario=='cylinder' else None
|
||||||
|
result['health_failures_during_goal']=sum(not value for stamp,value in health_events if stamp>=goal_start_wall)
|
||||||
|
quality=result['trajectory_metrics']
|
||||||
|
result['passed']=result['passed'] and quality['matched']>100 and quality['rpe_pairs']>0 and quality['maximum_position_error_m']<0.25 and quality['ate_translation_m']<0.1
|
||||||
|
if args.scenario not in ('blocked','lidar_loss'):
|
||||||
|
result['passed']=result['passed'] and result['truth_goal_error_m'] is not None and result['truth_goal_error_m']<=0.30
|
||||||
|
if result['minimum_cylinder_clearance_m'] is not None:
|
||||||
|
result['passed']=result['passed'] and result['minimum_cylinder_clearance_m']>=0
|
||||||
|
result['passed'] = result['passed'] and ((args.scenario == 'blocked' and '结果: ❌ ABORTED' in goal.stdout_text) or (args.scenario == 'lidar_loss' and result['fault_goal_canceled'] and result['fault_stop_delay_sec'] is not None and result['fault_stop_delay_sec']<0.5) or (goal.returncode == 0 and result['goal_succeeded']))
|
||||||
|
(args.output/'result.json').write_text(json.dumps(result, indent=2))
|
||||||
|
print(json.dumps({k: v for k, v in result.items() if k not in
|
||||||
|
('processes', 'services', 'node_counts', 'path_service_endpoints')}, indent=2), flush=True)
|
||||||
|
if not result['passed']:
|
||||||
|
raise RuntimeError('stack integration validation failed')
|
||||||
|
except Exception as error:
|
||||||
|
result.update(passed=False, error=str(error))
|
||||||
|
(args.output/'result.json').write_text(json.dumps(result, indent=2))
|
||||||
|
raise
|
||||||
|
finally:
|
||||||
|
_ = subscription, subscriptions, subscriptions_health, subscription_actuator
|
||||||
|
(args.output/'health_events.json').write_text(json.dumps(health_events))
|
||||||
|
for name, rows in samples.items():
|
||||||
|
with open(args.output/(name+'.tum'),'w') as output:
|
||||||
|
for row in rows:
|
||||||
|
output.write(' '.join(map(str,row))+'\n')
|
||||||
|
if goal is not None and goal.poll() is None:
|
||||||
|
os.killpg(goal.pid, signal.SIGINT)
|
||||||
|
try:
|
||||||
|
goal.wait(timeout=5)
|
||||||
|
except subprocess.TimeoutExpired:
|
||||||
|
os.killpg(goal.pid, signal.SIGKILL)
|
||||||
|
goal.wait()
|
||||||
|
if recorder.poll() is None:
|
||||||
|
os.killpg(recorder.pid, signal.SIGINT)
|
||||||
|
try:
|
||||||
|
recorder.wait(timeout=10)
|
||||||
|
except subprocess.TimeoutExpired:
|
||||||
|
os.killpg(recorder.pid, signal.SIGKILL)
|
||||||
|
recorder.wait()
|
||||||
|
record_log.close()
|
||||||
|
if process.poll() is None:
|
||||||
|
os.killpg(process.pid, signal.SIGINT)
|
||||||
|
try:
|
||||||
|
process.wait(timeout=20)
|
||||||
|
except subprocess.TimeoutExpired:
|
||||||
|
os.killpg(process.pid, signal.SIGKILL)
|
||||||
|
process.wait()
|
||||||
|
if rviz is not None:
|
||||||
|
os.killpg(rviz.pid, signal.SIGINT)
|
||||||
|
try:
|
||||||
|
rviz.wait(timeout=5)
|
||||||
|
except subprocess.TimeoutExpired:
|
||||||
|
os.killpg(rviz.pid, signal.SIGKILL)
|
||||||
|
rviz.wait()
|
||||||
|
if log:
|
||||||
|
log.close()
|
||||||
|
node.destroy_node()
|
||||||
|
rclpy.shutdown()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
||||||
Reference in new issue
Block a user