06_05.固定定位

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
	<title>Document</title>
	<style type="text/css">
	body{height: 2000px;}
	.box1{width: 300px;height: 100px;background: red;position: absolute;right: 0;bottom: 0;}
	/*固定定位:以当前可视文档为基准→→跟随滚动条移动,不以最近父级定位元素为基准*/
	.father{width: 400px;height: 400px;border: 2px solid black;position: relative;}
	/*固定定位:以当前可视文档为基准→→跟随滚动条移动*/
	span{width: 100px;height: 300px;background: blue;position: fixed;right: 0;bottom: 0;}
	/*for IE6:略过(JS处理)*/
	</style>
</head>
<body>
	<div class="box1">box1</div>

	<div class="father">father
		<span class="box2">span.box2</span>
	</div>
</body>
</html>

1.拖动滚动条前:


2.拖动滚动条后:



void ImuProcess::set_extrinsic(const MD(4,4) &T) { Lidar_T_wrt_IMU = T.block<3,1>(0,3); Lidar_R_wrt_IMU = T.block<3,3>(0,0); } void ImuProcess::set_extrinsic(const V3D &transl) { Lidar_T_wrt_IMU = transl; Lidar_R_wrt_IMU.setIdentity(); } void ImuProcess::set_extrinsic(const V3D &transl, const M3D &rot) { Lidar_T_wrt_IMU = transl; Lidar_R_wrt_IMU = rot; } void ImuProcess::set_gyr_cov(const V3D &scaler) { cov_gyr_scale = scaler; } void ImuProcess::set_acc_cov(const V3D &scaler) { cov_acc_scale = scaler; } void ImuProcess::set_gyr_bias_cov(const V3D &b_g) { cov_bias_gyr = b_g; } void ImuProcess::set_acc_bias_cov(const V3D &b_a) { cov_bias_acc = b_a; } /* Modified by XinweiCC 2025-04-06 13:37:05 */ void ImuProcess::set_init_state(const bool need_modify_init_state, const V3D &init_pos, const double &init_yaw) { need_modify_init_state_ = need_modify_init_state; init_pos_ = init_pos; init_yaw_ = init_yaw; } /* ======================================== */ void ImuProcess::IMU_init(const MeasureGroup &meas, esekfom::esekf<state_ikfom, 12, input_ikfom> &kf_state, int &N) { /** 1. initializing the gravity, gyro bias, acc and gyro covariance ** 2. normalize the acceleration measurenments to unit gravity **/ // EASY_FUNCTION(profiler::colors::Red300);//debug V3D cur_acc, cur_gyr; if (b_first_frame_) { Reset(); N = 1; b_first_frame_ = false; const auto &imu_acc = meas.imu.front()->linear_acceleration; const auto &gyr_acc = meas.imu.front()->angular_velocity; mean_acc << imu_acc.x, imu_acc.y, imu_acc.z; mean_gyr << gyr_acc.x, gyr_acc.y, gyr_acc.z; first_lidar_time = meas.lidar_beg_time; } for (const auto &imu : meas.imu) { const auto &imu_acc = imu->linear_acceleration; const auto &gyr_acc = imu->angular_velocity; cur_acc << imu_acc.x, imu_acc.y, imu_acc.z; cur_gyr << gyr_acc.x, gyr_acc.y, gyr_acc.z; mean_acc += (cur_acc - mean_acc) / N; mean_gyr += (cur_gyr - mean_gyr) / N; cov_acc = cov_acc * (N - 1.0) / N + (cur_acc - mean_acc).cwiseProduct(cur_acc - mean_acc) * (N - 1.0) / (N * N); cov_gyr = cov_gyr * (N - 1.0) / N + (cur_gyr - mean_gyr).cwiseProduct(cur_gyr - mean_gyr) * (N - 1.0) / (N * N); // cout<<"acc norm: "<<cur_acc.norm()<<" "<<mean_acc.norm()<<endl; N ++; } state_ikfom init_state = kf_state.get_x(); init_state.grav = S2(- mean_acc / mean_acc.norm() * G_m_s2); /* Modified by XinweiCC 2025-07-07 23:41:08 */ // Set the initial position for re-localization // Set the initial rotation to align the gravity vector with the Z-axis and yaw for re-localization Eigen::Vector3d grav_body = -mean_acc.normalized(); Eigen::Quaterniond quat_align = Eigen::Quaterniond::FromTwoVectors(grav_body, Eigen::Vector3d(0, 0, -1)); Eigen::Quaterniond quat_final = quat_align; if (need_modify_init_state_) { init_state.pos = init_pos_; Eigen::Quaterniond quat_yaw(Eigen::AngleAxisd(init_yaw_, Eigen::Vector3d(0, 0, 1))); quat_final = quat_yaw * quat_align; } init_state.rot = SO3(quat_final); init_state.grav = S2(Eigen::Vector3d(0, 0, -1) * G_m_s2); std::cout << "IMU init gyr: " << mean_gyr.transpose() << std::endl; std::cout << "IMU init acc: " << mean_acc.transpose() << std::endl; std::cout << "IMU init pos: " << init_state.pos.transpose() << std::endl; std::cout << "IMU init euler angle: " << quat_final.toRotationMatrix().eulerAngles(0, 1, 2).transpose() << std::endl; /* ======================================== */ //state_inout.rot = Eye3d; // Exp(mean_acc.cross(V3D(0, 0, -1 / scale_gravity))); init_state.bg = mean_gyr; init_state.offset_T_L_I = Lidar_T_wrt_IMU; init_state.offset_R_L_I = Lidar_R_wrt_IMU; kf_state.change_x(init_state); esekfom::esekf<state_ikfom, 12, input_ikfom>::cov init_P = kf_state.get_P(); init_P.setIdentity(); init_P(6,6) = init_P(7,7) = init_P(8,8) = 0.00001; init_P(9,9) = init_P(10,10) = init_P(11,11) = 0.00001; init_P(15,15) = init_P(16,16) = init_P(17,17) = 0.0001; init_P(18,18) = init_P(19,19) = init_P(20,20) = 0.001; init_P(21,21) = init_P(22,22) = 0.00001; kf_state.change_P(init_P); last_imu_ = meas.imu.back(); } 详细注释上述代码,函数前加说明,详细到参数
10-01
model District // 导入必要的库 import Modelica.Fluid.System; import Buildings.Fluid; import Modelica.Units.SI; inner System system(p_ambient=101325, T_ambient=293.15); // ===== 流体介质定义 ===== replaceable package Medium = Modelica.Media.Water.ConstantPropertyLiquidWater; // ===== 名义参数定义 ===== parameter Modelica.Units.SI.MassFlowRate m_flow_nominal = 10 "Nominal mass flow rate"; parameter Modelica.Units.SI.Pressure dp_nominal = 10000 "Nominal pressure drop"; // ===== 管道 ===== Buildings.Fluid.FixedResistances.Pipe pipe_pipe_main_001( redeclare package Medium = Medium, m_flow_nominal=m_flow_nominal, length=1469.63, diameter=0.800, roughness=0.00015, dp_nominal=50000, thicknessIns=0.002, lambdaIns=0.04); Buildings.Fluid.FixedResistances.Pipe pipe_pipe_main_002( redeclare package Medium = Medium, m_flow_nominal=m_flow_nominal, length=881.81, diameter=0.800, roughness=0.00015, dp_nominal=30000, thicknessIns=0.002, lambdaIns=0.04); Buildings.Fluid.FixedResistances.Pipe pipe_pipe_main_003( redeclare package Medium = Medium, m_flow_nominal=m_flow_nominal, length=881.83, diameter=0.700, roughness=0.00015, dp_nominal=30000, thicknessIns=0.002, lambdaIns=0.04); Buildings.Fluid.FixedResistances.Pipe pipe_pipe_branch_001( redeclare package Medium = Medium, m_flow_nominal=m_flow_nominal, length=293.93, diameter=0.300, roughness=7e-06, dp_nominal=20000, thicknessIns=0.002, lambdaIns=0.04); Buildings.Fluid.FixedResistances.Pipe pipe_pipe_branch_002( redeclare package Medium = Medium, m_flow_nominal=m_flow_nominal, length=146.96, diameter=0.300, roughness=7e-06, dp_nominal=10000, thicknessIns=0.002, lambdaIns=0.04); Buildings.Fluid.FixedResistances.Pipe pipe_pipe_branch_003( redeclare package Medium = Medium, m_flow_nominal=m_flow_nominal, length=293.94, diameter=0.400, roughness=7e-06, dp_nominal=15000, thicknessIns=0.002, lambdaIns=0.04); Buildings.Fluid.FixedResistances.Pipe pipe_pipe_branch_004( redeclare package Medium = Medium, m_flow_nominal=m_flow_nominal, length=146.97, diameter=0.250, roughness=7e-06, dp_nominal=8000, thicknessIns=0.002, lambdaIns=0.04); Buildings.Fluid.FixedResistances.Pipe pipe_pipe_branch_005( redeclare package Medium = Medium, m_flow_nominal=m_flow_nominal, length=146.97, diameter=0.300, roughness=7e-06, dp_nominal=10000, thicknessIns=0.002, lambdaIns=0.04); Buildings.Fluid.FixedResistances.Pipe pipe_pipe_branch_006( redeclare package Medium = Medium, m_flow_nominal=m_flow_nominal, length=146.97, diameter=0.300, roughness=7e-06, dp_nominal=10000, thicknessIns=0.002, lambdaIns=0.04); Buildings.Fluid.FixedResistances.Pipe pipe_pipe_rainbow_001( redeclare package Medium = Medium, m_flow_nominal=m_flow_nominal, length=587.90, diameter=0.600, roughness=0.00015, dp_nominal=40000, thicknessIns=0.002, lambdaIns=0.04); Buildings.Fluid.FixedResistances.Pipe pipe_pipe_rainbow_002( redeclare package Medium = Medium, m_flow_nominal=m_flow_nominal, length=146.98, diameter=0.300, roughness=7e-06, dp_nominal=10000, thicknessIns=0.002, lambdaIns=0.04); Buildings.Fluid.FixedResistances.Pipe pipe_pipe_xiaoshan_001( redeclare package Medium = Medium, m_flow_nominal=m_flow_nominal, length=881.83, diameter=0.700, roughness=0.00015, dp_nominal=30000, thicknessIns=0.002, lambdaIns=0.04); Buildings.Fluid.FixedResistances.Pipe pipe_pipe_yanjiang_001( redeclare package Medium = Medium, m_flow_nominal=m_flow_nominal, length=4335.92, diameter=0.600, roughness=0.00015, dp_nominal=80000, thicknessIns=0.002, lambdaIns=0.04); // ===== 热源 ===== Buildings.Fluid.Sources.Boundary_pT source_node_source_001( redeclare package Medium = Medium, p=4.5e5, T=273.15+85, nPorts=1); Buildings.Fluid.Sources.Boundary_pT source_node_source_002( redeclare package Medium = Medium, p=4.2e5, T=273.15+82, nPorts=1); Buildings.Fluid.Sources.Boundary_pT source_node_source_003( redeclare package Medium = Medium, p=4.0e5, T=273.15+80, nPorts=1); Buildings.Fluid.Sources.Boundary_pT source_node_source_004( redeclare package Medium = Medium, p=4.3e5, T=273.15+83, nPorts=1); // 沿江热源厂管道出口(零流量边界) Buildings.Fluid.Sources.MassFlowSource_T sink_yanjiang_boundary( redeclare package Medium = Medium, m_flow=0, T=273.15+45, nPorts=1); // ===== 需求节点 ===== Modelica.Blocks.Sources.TimeTable loadTab_node_demand_001(table=[0.0, 0.0000; 1680.0, 0.0000; 3360.0, 0.0000; 5040.0, 0.0000; 6720.0, 0.0000; 8400.0, 0.0000; 10080.0, 0.0000; 11760.0, 0.0114; 13440.0, 0.1157; 15120.0, 0.2290; 16800.0, 0.3495; 18480.0, 0.4755; 20160.0, 0.6052; 21840.0, 0.7365; 23520.0, 0.8675; 25200.0, 0.9963; 26880.0, 1.1210; 28560.0, 1.2396; 30240.0, 1.3505; 31920.0, 1.4519; 33600.0, 1.5424; 35280.0, 1.6206; 36960.0, 1.6853; 38640.0, 1.7356; 40320.0, 1.7707; 42000.0, 1.7902; 43680.0, 1.7936; 45360.0, 1.7810; 47040.0, 1.7526; 48720.0, 1.7087; 50400.0, 1.6500; 52080.0, 1.5775; 53760.0, 1.4921; 55440.0, 1.3952; 57120.0, 1.2882; 58800.0, 1.1727; 60480.0, 1.0504; 62160.0, 0.9231; 63840.0, 0.7928; 65520.0, 0.6614; 67200.0, 0.5308; 68880.0, 0.4029; 70560.0, 0.2798; 72240.0, 0.1632; 73920.0, 0.0549; 75600.0, 0.0000; 77280.0, 0.0000; 78960.0, 0.0000; 80640.0, 0.0000; 82320.0, 0.0000; 84000.0, 0.0000; 85680.0, 0.0000]); Buildings.Fluid.Sources.MassFlowSource_T sink_node_demand_001( redeclare package Medium = Medium, use_m_flow_in=true, T=273.15+45, nPorts=1); Modelica.Blocks.Sources.TimeTable loadTab_node_demand_002(table=[0.0, 0.0000; 1680.0, 0.0000; 3360.0, 0.0000; 5040.0, 0.0000; 6720.0, 0.0000; 8400.0, 0.0000; 10080.0, 0.0000; 11760.0, 0.0091; 13440.0, 0.0926; 15120.0, 0.1832; 16800.0, 0.2796; 18480.0, 0.3804; 20160.0, 0.4841; 21840.0, 0.5892; 23520.0, 0.6940; 25200.0, 0.7971; 26880.0, 0.8968; 28560.0, 0.9917; 30240.0, 1.0804; 31920.0, 1.1615; 33600.0, 1.2339; 35280.0, 1.2965; 36960.0, 1.3482; 38640.0, 1.3885; 40320.0, 1.4166; 42000.0, 1.4321; 43680.0, 1.4349; 45360.0, 1.4248; 47040.0, 1.4020; 48720.0, 1.3669; 50400.0, 1.3200; 52080.0, 1.2620; 53760.0, 1.1937; 55440.0, 1.1162; 57120.0, 1.0306; 58800.0, 0.9381; 60480.0, 0.8403; 62160.0, 0.7385; 63840.0, 0.6342; 65520.0, 0.5291; 67200.0, 0.4246; 68880.0, 0.3224; 70560.0, 0.2239; 72240.0, 0.1306; 73920.0, 0.0439; 75600.0, 0.0000; 77280.0, 0.0000; 78960.0, 0.0000; 80640.0, 0.0000; 82320.0, 0.0000; 84000.0, 0.0000; 85680.0, 0.0000]); Buildings.Fluid.Sources.MassFlowSource_T sink_node_demand_002( redeclare package Medium = Medium, use_m_flow_in=true, T=273.15+45, nPorts=1); Modelica.Blocks.Sources.TimeTable loadTab_node_demand_003(table=[0.0, 0.0000; 1680.0, 0.0000; 3360.0, 0.0000; 5040.0, 0.0000; 6720.0, 0.0000; 8400.0, 0.0000; 10080.0, 0.0000; 11760.0, 0.0167; 13440.0, 0.1697; 15120.0, 0.3358; 16800.0, 0.5126; 18480.0, 0.6974; 20160.0, 0.8876; 21840.0, 1.0802; 23520.0, 1.2724; 25200.0, 1.4613; 26880.0, 1.6441; 28560.0, 1.8181; 30240.0, 1.9807; 31920.0, 2.1295; 33600.0, 2.2622; 35280.0, 2.3768; 36960.0, 2.4718; 38640.0, 2.5456; 40320.0, 2.5971; 42000.0, 2.6256; 43680.0, 2.6306; 45360.0, 2.6121; 47040.0, 2.5704; 48720.0, 2.5061; 50400.0, 2.4200; 52080.0, 2.3136; 53760.0, 2.1884; 55440.0, 2.0463; 57120.0, 1.8893; 58800.0, 1.7199; 60480.0, 1.5406; 62160.0, 1.3539; 63840.0, 1.1628; 65520.0, 0.9700; 67200.0, 0.7785; 68880.0, 0.5910; 70560.0, 0.4104; 72240.0, 0.2394; 73920.0, 0.0805; 75600.0, 0.0000; 77280.0, 0.0000; 78960.0, 0.0000; 80640.0, 0.0000; 82320.0, 0.0000; 84000.0, 0.0000; 85680.0, 0.0000]); Buildings.Fluid.Sources.MassFlowSource_T sink_node_demand_003( redeclare package Medium = Medium, use_m_flow_in=true, T=273.15+45, nPorts=1); Modelica.Blocks.Sources.TimeTable loadTab_node_demand_004(table=[0.0, 0.0000; 1680.0, 0.0000; 3360.0, 0.0000; 5040.0, 0.0000; 6720.0, 0.0000; 8400.0, 0.0000; 10080.0, 0.0000; 11760.0, 0.0072; 13440.0, 0.0733; 15120.0, 0.1450; 16800.0, 0.2213; 18480.0, 0.3012; 20160.0, 0.3833; 21840.0, 0.4664; 23520.0, 0.5494; 25200.0, 0.6310; 26880.0, 0.7100; 28560.0, 0.7851; 30240.0, 0.8553; 31920.0, 0.9195; 33600.0, 0.9768; 35280.0, 1.0264; 36960.0, 1.0674; 38640.0, 1.0992; 40320.0, 1.1215; 42000.0, 1.1338; 43680.0, 1.1359; 45360.0, 1.1280; 47040.0, 1.1100; 48720.0, 1.0822; 50400.0, 1.0450; 52080.0, 0.9991; 53760.0, 0.9450; 55440.0, 0.8836; 57120.0, 0.8159; 58800.0, 0.7427; 60480.0, 0.6652; 62160.0, 0.5846; 63840.0, 0.5021; 65520.0, 0.4189; 67200.0, 0.3361; 68880.0, 0.2552; 70560.0, 0.1772; 72240.0, 0.1034; 73920.0, 0.0348; 75600.0, 0.0000; 77280.0, 0.0000; 78960.0, 0.0000; 80640.0, 0.0000; 82320.0, 0.0000; 84000.0, 0.0000; 85680.0, 0.0000]); Buildings.Fluid.Sources.MassFlowSource_T sink_node_demand_004( redeclare package Medium = Medium, use_m_flow_in=true, T=273.15+45, nPorts=1); Modelica.Blocks.Sources.TimeTable loadTab_node_demand_005(table=[0.0, 0.0000; 1680.0, 0.0000; 3360.0, 0.0000; 5040.0, 0.0000; 6720.0, 0.0000; 8400.0, 0.0000; 10080.0, 0.0000; 11760.0, 0.0084; 13440.0, 0.0848; 15120.0, 0.1679; 16800.0, 0.2563; 18480.0, 0.3487; 20160.0, 0.4438; 21840.0, 0.5401; 23520.0, 0.6362; 25200.0, 0.7306; 26880.0, 0.8221; 28560.0, 0.9091; 30240.0, 0.9904; 31920.0, 1.0647; 33600.0, 1.1311; 35280.0, 1.1884; 36960.0, 1.2359; 38640.0, 1.2728; 40320.0, 1.2985; 42000.0, 1.3128; 43680.0, 1.3153; 45360.0, 1.3061; 47040.0, 1.2852; 48720.0, 1.2530; 50400.0, 1.2100; 52080.0, 1.1568; 53760.0, 1.0942; 55440.0, 1.0231; 57120.0, 0.9447; 58800.0, 0.8600; 60480.0, 0.7703; 62160.0, 0.6770; 63840.0, 0.5814; 65520.0, 0.4850; 67200.0, 0.3892; 68880.0, 0.2955; 70560.0, 0.2052; 72240.0, 0.1197; 73920.0, 0.0403; 75600.0, 0.0000; 77280.0, 0.0000; 78960.0, 0.0000; 80640.0, 0.0000; 82320.0, 0.0000; 84000.0, 0.0000; 85680.0, 0.0000]); Buildings.Fluid.Sources.MassFlowSource_T sink_node_demand_005( redeclare package Medium = Medium, use_m_flow_in=true, T=273.15+45, nPorts=1); Modelica.Blocks.Sources.TimeTable loadTab_node_demand_006(table=[0.0, 0.0000; 1680.0, 0.0000; 3360.0, 0.0000; 5040.0, 0.0000; 6720.0, 0.0000; 8400.0, 0.0000; 10080.0, 0.0000; 11760.0, 0.0099; 13440.0, 0.1003; 15120.0, 0.1984; 16800.0, 0.3029; 18480.0, 0.4121; 20160.0, 0.5245; 21840.0, 0.6383; 23520.0, 0.7519; 25200.0, 0.8635; 26880.0, 0.9715; 28560.0, 1.0743; 30240.0, 1.1704; 31920.0, 1.2583; 33600.0, 1.3367; 35280.0, 1.4045; 36960.0, 1.4606; 38640.0, 1.5042; 40320.0, 1.5346; 42000.0, 1.5515; 43680.0, 1.5545; 45360.0, 1.5435; 47040.0, 1.5189; 48720.0, 1.4809; 50400.0, 1.4300; 52080.0, 1.3671; 53760.0, 1.2932; 55440.0, 1.2092; 57120.0, 1.1164; 58800.0, 1.0163; 60480.0, 0.9103; 62160.0, 0.8000; 63840.0, 0.6871; 65520.0, 0.5732; 67200.0, 0.4600; 68880.0, 0.3492; 70560.0, 0.2425; 72240.0, 0.1415; 73920.0, 0.0476; 75600.0, 0.0000; 77280.0, 0.0000; 78960.0, 0.0000; 80640.0, 0.0000; 82320.0, 0.0000; 84000.0, 0.0000; 85680.0, 0.0000]); Buildings.Fluid.Sources.MassFlowSource_T sink_node_demand_006( redeclare package Medium = Medium, use_m_flow_in=true, T=273.15+45, nPorts=1); Modelica.Blocks.Sources.TimeTable loadTab_node_demand_011(table=[0.0, 0.0000; 1680.0, 0.0000; 3360.0, 0.0000; 5040.0, 0.0000; 6720.0, 0.0000; 8400.0, 0.0000; 10080.0, 0.0000; 11760.0, 0.0122; 13440.0, 0.1234; 15120.0, 0.2442; 16800.0, 0.3728; 18480.0, 0.5072; 20160.0, 0.6455; 21840.0, 0.7856; 23520.0, 0.9254; 25200.0, 1.0628; 26880.0, 1.1957; 28560.0, 1.3223; 30240.0, 1.4405; 31920.0, 1.5487; 33600.0, 1.6452; 35280.0, 1.7286; 36960.0, 1.7977; 38640.0, 1.8513; 40320.0, 1.8888; 42000.0, 1.9095; 43680.0, 1.9132; 45360.0, 1.8997; 47040.0, 1.8694; 48720.0, 1.8226; 50400.0, 1.7600; 52080.0, 1.6826; 53760.0, 1.5916; 55440.0, 1.4882; 57120.0, 1.3741; 58800.0, 1.2509; 60480.0, 1.1204; 62160.0, 0.9847; 63840.0, 0.8457; 65520.0, 0.7055; 67200.0, 0.5661; 68880.0, 0.4298; 70560.0, 0.2985; 72240.0, 0.1741; 73920.0, 0.0586; 75600.0, 0.0000; 77280.0, 0.0000; 78960.0, 0.0000; 80640.0, 0.0000; 82320.0, 0.0000; 84000.0, 0.0000; 85680.0, 0.0000]); Buildings.Fluid.Sources.MassFlowSource_T sink_node_demand_011( redeclare package Medium = Medium, use_m_flow_in=true, T=273.15+45, nPorts=1); Modelica.Blocks.Sources.TimeTable loadTab_node_demand_012(table=[0.0, 0.0000; 1680.0, 0.0000; 3360.0, 0.0000; 5040.0, 0.0000; 6720.0, 0.0000; 8400.0, 0.0000; 10080.0, 0.0000; 11760.0, 0.0095; 13440.0, 0.0964; 15120.0, 0.1908; 16800.0, 0.2912; 18480.0, 0.3963; 20160.0, 0.5043; 21840.0, 0.6137; 23520.0, 0.7229; 25200.0, 0.8303; 26880.0, 0.9342; 28560.0, 1.0330; 30240.0, 1.1254; 31920.0, 1.2099; 33600.0, 1.2853; 35280.0, 1.3505; 36960.0, 1.4044; 38640.0, 1.4463; 40320.0, 1.4756; 42000.0, 1.4918; 43680.0, 1.4947; 45360.0, 1.4842; 47040.0, 1.4605; 48720.0, 1.4239; 50400.0, 1.3750; 52080.0, 1.3146; 53760.0, 1.2434; 55440.0, 1.1627; 57120.0, 1.0735; 58800.0, 0.9772; 60480.0, 0.8753; 62160.0, 0.7693; 63840.0, 0.6607; 65520.0, 0.5511; 67200.0, 0.4423; 68880.0, 0.3358; 70560.0, 0.2332; 72240.0, 0.1360; 73920.0, 0.0458; 75600.0, 0.0000; 77280.0, 0.0000; 78960.0, 0.0000; 80640.0, 0.0000; 82320.0, 0.0000; 84000.0, 0.0000; 85680.0, 0.0000]); Buildings.Fluid.Sources.MassFlowSource_T sink_node_demand_012( redeclare package Medium = Medium, use_m_flow_in=true, T=273.15+45, nPorts=1); Modelica.Blocks.Sources.TimeTable loadTab_node_demand_013(table=[0.0, 0.0000; 1680.0, 0.0000; 3360.0, 0.0000; 5040.0, 0.0000; 6720.0, 0.0000; 8400.0, 0.0000; 10080.0, 0.0000; 11760.0, 0.0152; 13440.0, 0.1543; 15120.0, 0.3053; 16800.0, 0.4660; 18480.0, 0.6340; 20160.0, 0.8069; 21840.0, 0.9820; 23520.0, 1.1567; 25200.0, 1.3284; 26880.0, 1.4947; 28560.0, 1.6528; 30240.0, 1.8006; 31920.0, 1.9359; 33600.0, 2.0565; 35280.0, 2.1608; 36960.0, 2.2471; 38640.0, 2.3141; 40320.0, 2.3610; 42000.0, 2.3869; 43680.0, 2.3915; 45360.0, 2.3747; 47040.0, 2.3367; 48720.0, 2.2782; 50400.0, 2.2000; 52080.0, 2.1033; 53760.0, 1.9895; 55440.0, 1.8603; 57120.0, 1.7176; 58800.0, 1.5636; 60480.0, 1.4005; 62160.0, 1.2308; 63840.0, 1.0571; 65520.0, 0.8818; 67200.0, 0.7077; 68880.0, 0.5373; 70560.0, 0.3731; 72240.0, 0.2176; 73920.0, 0.0732; 75600.0, 0.0000; 77280.0, 0.0000; 78960.0, 0.0000; 80640.0, 0.0000; 82320.0, 0.0000; 84000.0, 0.0000; 85680.0, 0.0000]); Buildings.Fluid.Sources.MassFlowSource_T sink_node_demand_013( redeclare package Medium = Medium, use_m_flow_in=true, T=273.15+45, nPorts=1); // ===== 泵站 ===== Buildings.Fluid.Movers.SpeedControlled_y pump_node_pump_001( redeclare package Medium = Medium, energyDynamics=Modelica.Fluid.Types.Dynamics.SteadyState, per.pressure(V_flow={0, 0.9}, dp={0, 294300})) "物联网热源厂主泵"; Buildings.Fluid.Movers.SpeedControlled_y pump_node_pump_002( redeclare package Medium = Medium, energyDynamics=Modelica.Fluid.Types.Dynamics.SteadyState, per.pressure(V_flow={0, 0.9}, dp={0, 274680})) "彩虹热源厂主泵"; // ===== 连接节点 ===== Buildings.Fluid.FixedResistances.Junction jun_1_1( redeclare package Medium = Medium, m_flow_nominal={m_flow_nominal, m_flow_nominal, m_flow_nominal}, dp_nominal={dp_nominal, dp_nominal, dp_nominal}) "江陵路节点1"; Buildings.Fluid.FixedResistances.Junction jun_1_2( redeclare package Medium = Medium, m_flow_nominal={m_flow_nominal, m_flow_nominal, m_flow_nominal}, dp_nominal={dp_nominal, dp_nominal, dp_nominal}) "江陵路节点2"; Buildings.Fluid.FixedResistances.Junction jun_2_1( redeclare package Medium = Medium, m_flow_nominal={m_flow_nominal, m_flow_nominal, m_flow_nominal}, dp_nominal={dp_nominal, dp_nominal, dp_nominal}) "滨和路节点1"; Buildings.Fluid.FixedResistances.Junction jun_2_2( redeclare package Medium = Medium, m_flow_nominal={m_flow_nominal, m_flow_nominal, m_flow_nominal}, dp_nominal={dp_nominal, dp_nominal, dp_nominal}) "滨和路节点2"; Buildings.Fluid.FixedResistances.Junction jun_2_3( redeclare package Medium = Medium, m_flow_nominal={m_flow_nominal, m_flow_nominal, m_flow_nominal}, dp_nominal={dp_nominal, dp_nominal, dp_nominal}) "滨和路节点3"; Buildings.Fluid.FixedResistances.Junction jun_3( redeclare package Medium = Medium, m_flow_nominal={m_flow_nominal, m_flow_nominal, m_flow_nominal}, dp_nominal={dp_nominal, dp_nominal, dp_nominal}) "长河路节点"; // ===== 泵站控制信号 ===== Modelica.Blocks.Sources.Constant pump_speed_001(k=0.85); Modelica.Blocks.Sources.Constant pump_speed_002(k=0.78); // ===== 水力计算变量 ===== Real total_pressure_loss[13]; Real flow_rates[13]; Real node_pressures[22]; Real Re[13]; Real friction_factor[13]; Real velocity[13]; Real total_source_flow; Real total_demand_flow; Real flow_balance_error; Real flow_balance_relative_error; Real source_flow_001; Real source_flow_002; Real source_flow_003; Real source_flow_004; Real source_flow_ratio[4]; Real average_pressure; Real pressure_variance; Real pressure_std_dev; Real system_pressure_drop; Real hydraulic_efficiency; String monitoring_summary; Boolean pressure_anomaly_detected; String anomaly_message; constant Real pi = 3.141592653589793; constant Real g = 9.81; parameter Real fluid_density = 1000; parameter Real fluid_viscosity = 0.001; // ===== 摩擦系数计算函数 ===== function calculateFrictionFactor input Real Re_val; input Real roughness_ratio; output Real f_val; protected Real Re_safe; algorithm Re_safe := max(abs(Re_val), 1e-3); if Re_safe <= 2300 then f_val := 64 / Re_safe; else f_val := 0.3086 / (log10(6.9/Re_safe + (roughness_ratio/3.7)^1.11))^2; end if; f_val := min(max(f_val, 0.001), 0.1); end calculateFrictionFactor; equation // ===== 连接关系 ===== // 热源连接 connect(source_node_source_001.ports[1], pump_node_pump_001.port_a); connect(pump_node_pump_001.port_b, pipe_pipe_main_001.port_a); connect(source_node_source_002.ports[1], pipe_pipe_xiaoshan_001.port_a); connect(source_node_source_003.ports[1], pump_node_pump_002.port_a); connect(pump_node_pump_002.port_b, pipe_pipe_rainbow_001.port_a); connect(source_node_source_004.ports[1], pipe_pipe_yanjiang_001.port_a); // 主干管网连接 connect(pipe_pipe_main_001.port_b, jun_1_1.port_1); connect(jun_1_1.port_2, jun_1_2.port_1); connect(jun_1_2.port_2, pipe_pipe_main_002.port_a); connect(pipe_pipe_main_002.port_b, jun_2_1.port_1); connect(jun_2_1.port_2, jun_2_2.port_1); connect(jun_2_2.port_2, jun_2_3.port_1); connect(jun_2_3.port_2, pipe_pipe_main_003.port_a); connect(pipe_pipe_main_003.port_b, jun_3.port_1); // 分支管网连接 connect(jun_1_1.port_3, pipe_pipe_branch_001.port_a); connect(jun_1_2.port_3, pipe_pipe_branch_002.port_a); connect(jun_2_1.port_3, pipe_pipe_branch_003.port_a); connect(jun_2_2.port_3, pipe_pipe_branch_004.port_a); connect(jun_2_3.port_3, pipe_pipe_branch_005.port_a); connect(jun_3.port_3, pipe_pipe_branch_006.port_a); connect(pipe_pipe_rainbow_001.port_b, pipe_pipe_rainbow_002.port_a); // 需求终端连接 connect(pipe_pipe_branch_001.port_b, sink_node_demand_001.ports[1]); connect(pipe_pipe_branch_002.port_b, sink_node_demand_002.ports[1]); connect(pipe_pipe_branch_003.port_b, sink_node_demand_003.ports[1]); connect(pipe_pipe_branch_004.port_b, sink_node_demand_004.ports[1]); connect(pipe_pipe_branch_005.port_b, sink_node_demand_005.ports[1]); connect(pipe_pipe_branch_006.port_b, sink_node_demand_006.ports[1]); connect(pipe_pipe_rainbow_002.port_b, sink_node_demand_011.ports[1]); connect(jun_3.port_2, sink_node_demand_012.ports[1]); connect(pipe_pipe_xiaoshan_001.port_b, sink_node_demand_013.ports[1]); connect(pipe_pipe_yanjiang_001.port_b, sink_yanjiang_boundary.ports[1]); // 负载信号连接 connect(loadTab_node_demand_001.y, sink_node_demand_001.m_flow_in); connect(loadTab_node_demand_002.y, sink_node_demand_002.m_flow_in); connect(loadTab_node_demand_003.y, sink_node_demand_003.m_flow_in); connect(loadTab_node_demand_004.y, sink_node_demand_004.m_flow_in); connect(loadTab_node_demand_005.y, sink_node_demand_005.m_flow_in); connect(loadTab_node_demand_006.y, sink_node_demand_006.m_flow_in); connect(loadTab_node_demand_011.y, sink_node_demand_011.m_flow_in); connect(loadTab_node_demand_012.y, sink_node_demand_012.m_flow_in); connect(loadTab_node_demand_013.y, sink_node_demand_013.m_flow_in); // 泵站控制信号连接 connect(pump_speed_001.y, pump_node_pump_001.y); connect(pump_speed_002.y, pump_node_pump_002.y); // ===== 管道水力计算 ===== // 管道 1: 主干管-物联网热源厂至江陵路 velocity[1] = abs(pipe_pipe_main_001.port_a.m_flow) / (fluid_density * pi * (0.800/2)^2); Re[1] = fluid_density * velocity[1] * 0.800 / max(fluid_viscosity, 1e-10); friction_factor[1] = calculateFrictionFactor(Re[1], 1.875000e-04); total_pressure_loss[1] = friction_factor[1] * 1469.63 / 0.800 * 0.5 * fluid_density * velocity[1]^2; flow_rates[1] = pipe_pipe_main_001.port_a.m_flow; // 管道 2: 主干管-江陵路至滨和路 velocity[2] = abs(pipe_pipe_main_002.port_a.m_flow) / (fluid_density * pi * (0.800/2)^2); Re[2] = fluid_density * velocity[2] * 0.800 / max(fluid_viscosity, 1e-10); friction_factor[2] = calculateFrictionFactor(Re[2], 1.875000e-04); total_pressure_loss[2] = friction_factor[2] * 881.81 / 0.800 * 0.5 * fluid_density * velocity[2]^2; flow_rates[2] = pipe_pipe_main_002.port_a.m_flow; // 管道 3: 主干管-滨和路至长河路 velocity[3] = abs(pipe_pipe_main_003.port_a.m_flow) / (fluid_density * pi * (0.700/2)^2); Re[3] = fluid_density * velocity[3] * 0.700 / max(fluid_viscosity, 1e-10); friction_factor[3] = calculateFrictionFactor(Re[3], 2.142857e-04); total_pressure_loss[3] = friction_factor[3] * 881.83 / 0.700 * 0.5 * fluid_density * velocity[3]^2; flow_rates[3] = pipe_pipe_main_003.port_a.m_flow; // 管道 4: 支管-体育场小区 velocity[4] = abs(pipe_pipe_branch_001.port_a.m_flow) / (fluid_density * pi * (0.300/2)^2); Re[4] = fluid_density * velocity[4] * 0.300 / max(fluid_viscosity, 1e-10); friction_factor[4] = calculateFrictionFactor(Re[4], 2.333333e-05); total_pressure_loss[4] = friction_factor[4] * 293.93 / 0.300 * 0.5 * fluid_density * velocity[4]^2; flow_rates[4] = pipe_pipe_branch_001.port_a.m_flow; // 管道 5: 支管-缤纷小区 velocity[5] = abs(pipe_pipe_branch_002.port_a.m_flow) / (fluid_density * pi * (0.300/2)^2); Re[5] = fluid_density * velocity[5] * 0.300 / max(fluid_viscosity, 1e-10); friction_factor[5] = calculateFrictionFactor(Re[5], 2.333333e-05); total_pressure_loss[5] = friction_factor[5] * 146.96 / 0.300 * 0.5 * fluid_density * velocity[5]^2; flow_rates[5] = pipe_pipe_branch_002.port_a.m_flow; // 管道 6: 支管-绿城明月江南 velocity[6] = abs(pipe_pipe_branch_003.port_a.m_flow) / (fluid_density * pi * (0.400/2)^2); Re[6] = fluid_density * velocity[6] * 0.400 / max(fluid_viscosity, 1e-10); friction_factor[6] = calculateFrictionFactor(Re[6], 1.750000e-05); total_pressure_loss[6] = friction_factor[6] * 293.94 / 0.400 * 0.5 * fluid_density * velocity[6]^2; flow_rates[6] = pipe_pipe_branch_003.port_a.m_flow; // 管道 7: 支管-富康苑 velocity[7] = abs(pipe_pipe_branch_004.port_a.m_flow) / (fluid_density * pi * (0.250/2)^2); Re[7] = fluid_density * velocity[7] * 0.250 / max(fluid_viscosity, 1e-10); friction_factor[7] = calculateFrictionFactor(Re[7], 2.800000e-05); total_pressure_loss[7] = friction_factor[7] * 146.97 / 0.250 * 0.5 * fluid_density * velocity[7]^2; flow_rates[7] = pipe_pipe_branch_004.port_a.m_flow; // 管道 8: 支管-自来水小区 velocity[8] = abs(pipe_pipe_branch_005.port_a.m_flow) / (fluid_density * pi * (0.300/2)^2); Re[8] = fluid_density * velocity[8] * 0.300 / max(fluid_viscosity, 1e-10); friction_factor[8] = calculateFrictionFactor(Re[8], 2.333333e-05); total_pressure_loss[8] = friction_factor[8] * 146.97 / 0.300 * 0.5 * fluid_density * velocity[8]^2; flow_rates[8] = pipe_pipe_branch_005.port_a.m_flow; // 管道 9: 支管-滨兴东苑 velocity[9] = abs(pipe_pipe_branch_006.port_a.m_flow) / (fluid_density * pi * (0.300/2)^2); Re[9] = fluid_density * velocity[9] * 0.300 / max(fluid_viscosity, 1e-10); friction_factor[9] = calculateFrictionFactor(Re[9], 2.333333e-05); total_pressure_loss[9] = friction_factor[9] * 146.97 / 0.300 * 0.5 * fluid_density * velocity[9]^2; flow_rates[9] = pipe_pipe_branch_006.port_a.m_flow; // 管道 10: 彩虹热源厂主干管 velocity[10] = abs(pipe_pipe_rainbow_001.port_a.m_flow) / (fluid_density * pi * (0.600/2)^2); Re[10] = fluid_density * velocity[10] * 0.600 / max(fluid_viscosity, 1e-10); friction_factor[10] = calculateFrictionFactor(Re[10], 2.500000e-04); total_pressure_loss[10] = friction_factor[10] * 587.90 / 0.600 * 0.5 * fluid_density * velocity[10]^2; flow_rates[10] = pipe_pipe_rainbow_001.port_a.m_flow; // 管道 11: 彩虹热源厂支管-湘湖印象 velocity[11] = abs(pipe_pipe_rainbow_002.port_a.m_flow) / (fluid_density * pi * (0.300/2)^2); Re[11] = fluid_density * velocity[11] * 0.300 / max(fluid_viscosity, 1e-10); friction_factor[11] = calculateFrictionFactor(Re[11], 2.333333e-05); total_pressure_loss[11] = friction_factor[11] * 146.98 / 0.300 * 0.5 * fluid_density * velocity[11]^2; flow_rates[11] = pipe_pipe_rainbow_002.port_a.m_flow; // 管道 12: 萧山热源厂主干管 velocity[12] = abs(pipe_pipe_xiaoshan_001.port_a.m_flow) / (fluid_density * pi * (0.700/2)^2); Re[12] = fluid_density * velocity[12] * 0.700 / max(fluid_viscosity, 1e-10); friction_factor[12] = calculateFrictionFactor(Re[12], 2.142857e-04); total_pressure_loss[12] = friction_factor[12] * 881.83 / 0.700 * 0.5 * fluid_density * velocity[12]^2; flow_rates[12] = pipe_pipe_xiaoshan_001.port_a.m_flow; // 管道 13: 沿江热源厂主干管 velocity[13] = abs(pipe_pipe_yanjiang_001.port_a.m_flow) / (fluid_density * pi * (0.600/2)^2); Re[13] = fluid_density * velocity[13] * 0.600 / max(fluid_viscosity, 1e-10); friction_factor[13] = calculateFrictionFactor(Re[13], 2.500000e-04); total_pressure_loss[13] = friction_factor[13] * 4335.92 / 0.600 * 0.5 * fluid_density * velocity[13]^2; flow_rates[13] = pipe_pipe_yanjiang_001.port_a.m_flow; // ===== 节点压力计算 ===== // 主干管网节点压力 node_pressures[1] = jun_1_1.port_1.p; // 物联网热源厂出口 node_pressures[2] = jun_1_1.port_2.p; // 江陵路节点1 node_pressures[3] = jun_1_2.port_2.p; // 江陵路节点2 node_pressures[4] = jun_2_1.port_2.p; // 滨和路节点1 node_pressures[5] = jun_2_2.port_2.p; // 滨和路节点2 node_pressures[6] = jun_2_3.port_2.p; // 滨合路节点3 node_pressures[7] = jun_3.port_1.p; // 长河路节点 // 分支节点压力 node_pressures[8] = jun_1_1.port_3.p; // 体育场小区分支 node_pressures[9] = jun_1_2.port_3.p; // 缤纷小区分支 node_pressures[10] = jun_2_1.port_3.p; // 绿城明月江南分支 node_pressures[11] = jun_2_2.port_3.p; // 富康苑分支 node_pressures[12] = jun_2_3.port_3.p; // 自来水小区分支 node_pressures[13] = jun_3.port_3.p; // 滨兴东苑分支 // 需求节点压力 node_pressures[14] = sink_node_demand_001.ports[1].p; // 体育场小区 node_pressures[15] = sink_node_demand_002.ports[1].p; // 缤纷小区 node_pressures[16] = sink_node_demand_003.ports[1].p; // 绿城明月江南 node_pressures[17] = sink_node_demand_004.ports[1].p; // 富康苑 node_pressures[18] = sink_node_demand_005.ports[1].p; // 自来水小区 node_pressures[19] = sink_node_demand_006.ports[1].p; // 滨兴东苑 node_pressures[20] = sink_node_demand_011.ports[1].p; // 湘湖印象 node_pressures[21] = sink_node_demand_012.ports[1].p; // 长河路终端 node_pressures[22] = sink_node_demand_013.ports[1].p; // 萧山终端 // ===== 压力约束与验证 ===== // 最小压力约束 - 居民区 (250 kPa) assert(sink_node_demand_001.ports[1].p >= 250000, "体育场小区压力低于最小值 250 kPa"); assert(sink_node_demand_002.ports[1].p >= 250000, "缤纷小区压力低于最小值 250 kPa"); assert(sink_node_demand_003.ports[1].p >= 250000, "绿城明月江南压力低于最小值 250 kPa"); assert(sink_node_demand_004.ports[1].p >= 250000, "富康苑压力低于最小值 250 kPa"); assert(sink_node_demand_005.ports[1].p >= 250000, "自来水小区压力低于最小值 250 kPa"); assert(sink_node_demand_006.ports[1].p >= 250000, "滨兴东苑压力低于最小值 250 kPa"); assert(sink_node_demand_011.ports[1].p >= 250000, "湘湖印象压力低于最小值 250 kPa"); assert(sink_node_demand_012.ports[1].p >= 250000, "长河路终端压力低于最小值 250 kPa"); assert(sink_node_demand_013.ports[1].p >= 250000, "萧山终端压力低于最小值 250 kPa"); // 泵站工作压力范围 assert(pump_node_pump_001.port_a.p >= 100000, "泵站1入口压力过低"); assert(pump_node_pump_001.port_b.p <= 800000, "泵站1出口压力过高"); assert(pump_node_pump_002.port_a.p >= 100000, "泵站2入口压力过低"); assert(pump_node_pump_002.port_b.p <= 800000, "泵站2出口压力过高"); // ===== 流量平衡检查 ===== // 系统总流量平衡计算 total_source_flow = (-source_node_source_001.ports[1].m_flow) + (-source_node_source_002.ports[1].m_flow) + (-source_node_source_003.ports[1].m_flow) + (-source_node_source_004.ports[1].m_flow); total_demand_flow = loadTab_node_demand_001.y + loadTab_node_demand_002.y + loadTab_node_demand_003.y + loadTab_node_demand_004.y + loadTab_node_demand_005.y + loadTab_node_demand_006.y + loadTab_node_demand_011.y + loadTab_node_demand_012.y + loadTab_node_demand_013.y; // 流量平衡验证(允许1%的相对误差) flow_balance_error = abs(total_source_flow - total_demand_flow); flow_balance_relative_error = flow_balance_error / max(abs(total_source_flow), 1e-6); assert(flow_balance_relative_error < 0.01, "系统流量不平衡,相对误差: " + String(flow_balance_relative_error*100) + "%"); // 各热源厂流量分配监测 source_flow_001 = -source_node_source_001.ports[1].m_flow; source_flow_002 = -source_node_source_002.ports[1].m_flow; source_flow_003 = -source_node_source_003.ports[1].m_flow; source_flow_004 = -source_node_source_004.ports[1].m_flow; // 流量分配比例 source_flow_ratio[1] = source_flow_001 / max(total_source_flow, 1e-6); source_flow_ratio[2] = source_flow_002 / max(total_source_flow, 1e-6); source_flow_ratio[3] = source_flow_003 / max(total_source_flow, 1e-6); source_flow_ratio[4] = source_flow_004 / max(total_source_flow, 1e-6); // ===== 系统性能指标 ===== // 平均管网压力 average_pressure = sum(node_pressures[14:22]) / 9; // 压力均匀性指标(标准差) pressure_variance = 0; for i in 14:22 loop pressure_variance = pressure_variance + (node_pressures[i] - average_pressure)^2; end for; pressure_std_dev = sqrt(pressure_variance / 9); // 系统压降 system_pressure_drop = max(node_pressures[1:7]) - min(node_pressures[14:22]); // 水力效率指标 hydraulic_efficiency = (average_pressure - 250000) / system_pressure_drop; // ===== 实时监测输出 ===== // 关键性能指标实时显示 monitoring_summary = "系统状态 - 平均压力: " + String(average_pressure/1000) + " kPa, " + "压降: " + String(system_pressure_drop/1000) + " kPa, " + "总流量: " + String(total_source_flow*3600) + " m³/h, " + "平衡误差: " + String(flow_balance_relative_error*100) + "%"; // 压力异常检测 pressure_anomaly_detected = false; for i in 14:22 loop if node_pressures[i] < 240000 or node_pressures[i] > 650000 then pressure_anomaly_detected = true; anomaly_message = "节点 " + String(i) + " 压力异常: " + String(node_pressures[i]/1000) + " kPa"; end if; end for; end District; [1] 13:49:02 脚本 提示 Buildings requested package Modelica of version 4.0.0. Modelica 4.1.0 is used instead which states that it is fully compatible without conversion script needed. [2] 13:49:02 符号 错误 Too many equations, over-determined system. The model has 9117 equation(s) and 9109 variable(s). [3] 13:49:02 脚本 错误 Translation of District failed.
11-04
import numpy as np import cv2 import glob import os def convert_raw_to_png(): """将RAW格式图像批量转换为PNG格式""" folder = 'stereo' # 原始图像文件夹 left_output_dir = 'left_camera_images' # 左相机输出文件夹 right_output_dir = 'right_camera_images' # 右相机输出文件夹 # 创建输出目录 os.makedirs(left_output_dir, exist_ok=True) os.makedirs(right_output_dir, exist_ok=True) # 获取所有RAW文件 raw_files = sorted(glob.glob(os.path.join(folder, '*.raw'))) print(f"找到 {len(raw_files)} 个RAW文件,开始转换...") # 假设图像尺寸(需要根据实际相机设置) IMG_WIDTH = 1280 IMG_HEIGHT = 720 for i, raw_file in enumerate(raw_files): # 读取RAW文件(假设为16位灰度图像) with open(raw_file, 'rb') as f: data = np.fromfile(f, dtype=np.uint16) # 重塑为图像形状 if data.size == IMG_WIDTH * IMG_HEIGHT: img = data.reshape((IMG_HEIGHT, IMG_WIDTH)) else: print(f"警告: {raw_file} 尺寸不符 ({data.size} vs {IMG_WIDTH * IMG_HEIGHT})") continue # 归一化到8位范围 (0-255) img_8bit = cv2.normalize(img, None, 0, 255, cv2.NORM_MINMAX, dtype=cv2.CV_8U) # 提取文件名并判断属于左/右相机 filename = os.path.basename(raw_file) if 'left' in filename.lower(): output_path = os.path.join(left_output_dir, f"left_{i:03d}.png") elif 'right' in filename.lower(): output_path = os.path.join(right_output_dir, f"right_{i:03d}.png") else: # 自动分配左右相机图像(假设文件按顺序排列) if i % 2 == 0: output_path = os.path.join(left_output_dir, f"left_{i // 2:03d}.png") else: output_path = os.path.join(right_output_dir, f"right_{i // 2:03d}.png") # 保存为PNG cv2.imwrite(output_path, img_8bit) print(f"已转换: {raw_file} -> {output_path}") print("所有RAW文件转换完成!") return left_output_dir, right_output_dir # 下面是原有的双目标定代码(保持不变) CHECKERBOARD = (7, 9) # 棋盘格内部角点数量 (宽度, 高度) SQUARE_SIZE = 25 # 棋盘格方块实际尺寸 (毫米) def stereo_calibrate(left_dir, right_dir): rows, cols, square = 6, 8, 25 # 内角点数量 + 格长(mm) folder = 'stereo' # 修改为使用参数 left_dir/right_dir 更合理 # ... 嵌套函数 read_corner 保持不变 ... # 调用检测函数 obj_l, img_l, imgSize = read_corner('left') obj_r, img_r, _ = read_corner('right') print('>>> 角点检测成功:left=', len(obj_l), 'right=', len(obj_r)) assert len(obj_l) == len(obj_r), "左右图像数量不等" # 标定流程 _, K_l, d_l, _, _ = cv2.calibrateCamera(obj_l, img_l, imgSize, None, None) _, K_r, d_r, _, _ = cv2.calibrateCamera(obj_r, img_r, imgSize, None, None) rms, K_l, d_l, K_r, d_r, R, T, _, _ = cv2.stereoCalibrate( obj_l, img_l, img_r, K_l, d_l, K_r, d_r, imgSize, flags=cv2.CALIB_FIX_INTRINSIC) print(">>> 标定误差 rms=", rms) # 目标一般小于0.5像素 # 保存标定结果 np.savez("stereo_calib.npz", K_l=K_l, d_l=d_l, K_r=K_r, d_r=d_r, R=R, T=T) # 返回标定结果(供主程序使用) return K_l, d_l, K_r, d_r, R, T # ================ 关键修复:这里必须有空行 ================ if __name__ == "__main__": # 转换RAW图像 left_dir, right_dir = convert_raw_to_png() # 执行双目标定(接收返回值) calibration_results = stereo_calibrate(left_dir, right_dir) # 保存完整标定结果 np.savez("stereo_calibration.npz", mtxL=calibration_results[0], distL=calibration_results[1], mtxR=calibration_results[2], distR=calibration_results[3], R=calibration_results[4], T=calibration_results[5]) 前面这段代码出现找到 50 个RAW文件,开始转换... 警告: stereo\left_00.raw 尺寸不符 (2506752 vs 921600) 警告: stereo\left_01.raw 尺寸不符 (2506752 vs 921600) 警告: stereo\left_02.raw 尺寸不符 (2506752 vs 921600) 警告: stereo\left_03.raw 尺寸不符 (2506752 vs 921600) 警告: stereo\left_04.raw 尺寸不符 (2506752 vs 921600) 警告: stereo\left_05.raw 尺寸不符 (2506752 vs 921600) 警告: stereo\left_06.raw 尺寸不符 (2506752 vs 921600) 警告: stereo\left_07.raw 尺寸不符 (2506752 vs 921600) 警告: stereo\left_08.raw 尺寸不符 (2506752 vs 921600) 警告: stereo\left_09.raw 尺寸不符 (2506752 vs 921600) 警告: stereo\left_10.raw 尺寸不符 (2506752 vs 921600) 警告: stereo\left_11.raw 尺寸不符 (2506752 vs 921600) 警告: stereo\left_12.raw 尺寸不符 (2506752 vs 921600) 警告: stereo\left_13.raw 尺寸不符 (2506752 vs 921600) 警告: stereo\left_14.raw 尺寸不符 (2506752 vs 921600) 警告: stereo\left_15.raw 尺寸不符 (2506752 vs 921600) 警告: stereo\left_16.raw 尺寸不符 (2506752 vs 921600) 警告: stereo\left_17.raw 尺寸不符 (2506752 vs 921600) 警告: stereo\left_18.raw 尺寸不符 (2506752 vs 921600) 警告: stereo\left_19.raw 尺寸不符 (2506752 vs 921600) 警告: stereo\left_20.raw 尺寸不符 (2506752 vs 921600) 警告: stereo\left_21.raw 尺寸不符 (2506752 vs 921600) 警告: stereo\left_22.raw 尺寸不符 (2506752 vs 921600) 警告: stereo\left_23.raw 尺寸不符 (2506752 vs 921600) 警告: stereo\left_24.raw 尺寸不符 (2506752 vs 921600) 警告: stereo\right_00.raw 尺寸不符 (2506752 vs 921600) 警告: stereo\right_01.raw 尺寸不符 (2506752 vs 921600) 警告: stereo\right_02.raw 尺寸不符 (2506752 vs 921600) 警告: stereo\right_03.raw 尺寸不符 (2506752 vs 921600) 警告: stereo\right_04.raw 尺寸不符 (2506752 vs 921600) 警告: stereo\right_05.raw 尺寸不符 (2506752 vs 921600) 警告: stereo\right_06.raw 尺寸不符 (2506752 vs 921600) 警告: stereo\right_07.raw 尺寸不符 (2506752 vs 921600) 警告: stereo\right_08.raw 尺寸不符 (2506752 vs 921600) Traceback (most recent call last): File "F:\calib\shuangmubiaoding.py", line 95, in <module> left_dir, right_dir = convert_raw_to_png() File "F:\calib\shuangmubiaoding.py", line 28, in convert_raw_to_png data = np.fromfile(f, dtype=np.uint16) OSError: could not seek in file这样的错误应该怎样解决
最新发布
11-07
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值