完善双雷达仿真与自动上坡任务,更新使用文档
加入下置 MID360 前向补盲与双雷达融合,修复北侧走廊导航、坐标适配和数据时效处理。 实现接近坡脚、姿态辅助上坡与平台停车任务,增加独立快模式、命令仲裁及失效停车保护,保留测试与分阶段验收记录。 同步实车尺寸及雷达安装参数,调整 Gazebo 红方默认视角,完善根目录 README、仿真使用和实车迁移说明。
This commit is contained in:
@@ -23,26 +23,27 @@ class Recorder:
|
||||
|
||||
class GeometryTests(unittest.TestCase):
|
||||
def test_known_start_maps_imu_and_optical_origins(self):
|
||||
imu=np.array([.011,.02329,.25588]);prior=np.array([-4.5,4.5,.15,math.pi/2])
|
||||
imu=np.array([.026,.02329,.28588]);prior=np.array([-4.5,4.5,.15,math.pi/2])
|
||||
p=np.array([.2,-.3,.02]);q=np.array([0.,0.,math.sin(.35),math.cos(.35)])
|
||||
a=FixedAlignment(prior,imu,p,q)
|
||||
base,bq=a.pose(p,q,-imu);lidar,_=a.pose(p,q,np.array([0.,0.,.3])-imu)
|
||||
base,bq=a.pose(p,q,-imu);lidar,_=a.pose(p,q,np.array([.015,0.,.33])-imu)
|
||||
np.testing.assert_allclose(base,prior[:3],atol=1e-12)
|
||||
np.testing.assert_allclose(lidar,prior[:3]+[0,0,.3],atol=1e-12)
|
||||
np.testing.assert_allclose(lidar,prior[:3]+[0,.015,.33],atol=1e-12)
|
||||
self.assertAlmostEqual(math.atan2(rotation(bq)[1,0],rotation(bq)[0,0]),math.pi/2)
|
||||
old_t=a.t.copy();later,_=a.pose(p+[1,0,0],q,-imu)
|
||||
np.testing.assert_allclose(later-base,a.R@[1,0,0],atol=1e-12)
|
||||
np.testing.assert_array_equal(a.t,old_t)
|
||||
|
||||
def test_rotating_imu_lever_arm_by_finite_difference(self):
|
||||
offset=np.array([.011,.02329,.25588]);yaw=.8;w=.4;dt=1e-6
|
||||
offset=np.array([.026,.02329,.28588]);yaw=.8;w=.4;dt=1e-6
|
||||
def R(y):return np.array([[math.cos(y),-math.sin(y),0],[math.sin(y),math.cos(y),0],[0,0,1]])
|
||||
imu_world_velocity=(R(yaw+w*dt)@offset-R(yaw-w*dt)@offset)/(2*dt)
|
||||
imu_body_velocity=R(yaw).T@imu_world_velocity
|
||||
base=shifted_twist(imu_body_velocity,[0,0,w],-offset)
|
||||
np.testing.assert_allclose(base,[0,0,0],atol=1e-10)
|
||||
lidar=shifted_twist(imu_body_velocity,[0,0,w],np.array([0,0,.3])-offset)
|
||||
np.testing.assert_allclose(lidar,[0,0,0],atol=1e-10)
|
||||
lidar=shifted_twist(imu_body_velocity,[0,0,w],np.array([.015,0,.33])-offset)
|
||||
# A forward-offset optical origin has a genuine lateral velocity when yawing.
|
||||
np.testing.assert_allclose(lidar,[0,.015*w,0],atol=1e-10)
|
||||
|
||||
def test_invalid_quaternions_are_rejected(self):
|
||||
for values in ([0,0,0,0],[0,0,0,2],[float('nan'),0,0,1]):
|
||||
@@ -66,6 +67,30 @@ class AdapterTests(unittest.TestCase):
|
||||
for t in np.arange(1.,2.11,.05):self.node.on_odom(self.odom(float(t)))
|
||||
self.assertIsNotNone(self.node.alignment)
|
||||
|
||||
def test_stationary_velocity_jitter_allows_fixed_start(self):
|
||||
for i,t in enumerate(np.arange(1.,2.11,.01)):
|
||||
m=self.odom(float(t));m.twist.twist.linear.x=.03 if i%2 else -.03
|
||||
self.node.on_odom(m)
|
||||
self.assertIsNotNone(self.node.alignment)
|
||||
|
||||
def test_moving_vehicle_cannot_lock_fixed_start(self):
|
||||
for t in np.arange(1.,3.11,.01):
|
||||
m=self.odom(float(t));m.pose.pose.position.x=.03*(t-1.)
|
||||
m.twist.twist.linear.x=.03;self.node.on_odom(m)
|
||||
self.assertIsNone(self.node.alignment)
|
||||
self.assertFalse(self.node.fault)
|
||||
# Small position drift must not hide a sustained speed above threshold.
|
||||
for t in np.arange(3.12,4.31,.01):
|
||||
m=self.odom(float(t));m.twist.twist.linear.x=.03;self.node.on_odom(m)
|
||||
self.assertIsNone(self.node.alignment)
|
||||
|
||||
def test_position_motion_rejects_even_with_zero_mean_velocity(self):
|
||||
for i,t in enumerate(np.arange(1.,3.11,.01)):
|
||||
m=self.odom(float(t));m.pose.pose.position.x=.03*(t-1.)
|
||||
m.twist.twist.linear.x=.03 if i%2 else -.03
|
||||
self.node.on_odom(m)
|
||||
self.assertIsNone(self.node.alignment)
|
||||
|
||||
def test_stale_and_discontinuous_odometry_never_reanchors(self):
|
||||
self.anchor();t=self.node.odom_stamp;translation=self.node.alignment.t.copy()
|
||||
stale=self.odom(t);self.time=t+.3;count=len(self.node.body_pub.messages)
|
||||
@@ -81,6 +106,8 @@ class AdapterTests(unittest.TestCase):
|
||||
self.anchor();n=111;data=np.zeros((n,6),dtype='<f4');data[:,3]=1.
|
||||
data[0,3:]=[0,0,-.3] # self return, regardless of latest robot pose
|
||||
data[1,2]=-self.node.alignment.t[2] # world ground
|
||||
data[2,3:]=[-.43,0,-.07] # new 41 cm roof, rear edge inside 2 cm margin
|
||||
data[3,3:]=[.42,0,-.07] # outside front margin after optical x=.015 shift
|
||||
m=PointCloud2();m.header.frame_id='camera_init';m.header.stamp=self.odom(self.time).header.stamp
|
||||
m.height=1;m.width=n;m.point_step=24;m.row_step=24*n
|
||||
m.fields=[PointField(name=name,offset=i*4,datatype=PointField.FLOAT32,count=1) for i,name in enumerate(('x','y','z','lidar_x','lidar_y','lidar_z'))]
|
||||
@@ -89,7 +116,7 @@ class AdapterTests(unittest.TestCase):
|
||||
full=self.node.world_pub.messages[-1];filtered=self.node.planning_pub.messages[-1]
|
||||
self.assertEqual(filtered.header.stamp,m.header.stamp)
|
||||
xyz=np.stack(float_fields(filtered,('x','y','z')),axis=-1).reshape(n,3)
|
||||
self.assertTrue(np.isnan(xyz[:2]).all());self.assertTrue(np.isfinite(xyz[2:]).all())
|
||||
self.assertTrue(np.isnan(xyz[:3]).all());self.assertTrue(np.isfinite(xyz[3:]).all())
|
||||
for a,b in zip(float_fields(full,('lidar_x','lidar_y','lidar_z')),float_fields(filtered,('lidar_x','lidar_y','lidar_z'))):np.testing.assert_array_equal(a,b)
|
||||
|
||||
def test_wrong_source_frame_latches_stop(self):
|
||||
@@ -125,6 +152,69 @@ class AdapterTests(unittest.TestCase):
|
||||
self.node.health();self.assertTrue(self.node.ready_pub.messages[-1].data)
|
||||
self.time+=.02;self.node.odom_stamp=self.time;self.node.cloud_stamp=self.time
|
||||
self.node.health();self.assertFalse(self.node.ready_pub.messages[-1].data)
|
||||
def test_selected_fused_cloud_not_display_cloud_controls_readiness(self):
|
||||
self.anchor();self.node.planning_topic='/sim/navigation/terrain_planning_cloud'
|
||||
self.node.cloud_stamp=self.time-1.;self.node.downstream_stamp=self.time
|
||||
self.node.health();self.assertTrue(self.node.ready_pub.messages[-1].data)
|
||||
self.time+=.31;self.node.odom_stamp=self.time;self.node.cloud_stamp=self.time
|
||||
self.node.health();self.assertFalse(self.node.ready_pub.messages[-1].data)
|
||||
def test_future_downstream_cloud_waits_for_clock(self):
|
||||
self.anchor();previous=self.time;self.node.downstream_stamp=previous
|
||||
m=PointCloud2();m.header.frame_id='world';m.width=1;m.height=1
|
||||
m.header.stamp.sec=int(previous+.08);m.header.stamp.nanosec=round(((previous+.08)%1)*1e9)
|
||||
self.node.on_planning_cloud(m);self.assertEqual(self.node.downstream_stamp,previous)
|
||||
self.time=previous+.08;self.node.health();self.assertAlmostEqual(self.node.downstream_stamp,self.time)
|
||||
|
||||
|
||||
def test_odom_before_clock_waits_then_keeps_original_stamp(self):
|
||||
self.anchor();previous=self.time;m=self.odom(previous+.08);self.time=previous
|
||||
count=len(self.node.body_pub.messages);self.node.on_odom(m)
|
||||
self.assertEqual(len(self.node.body_pub.messages),count)
|
||||
self.node.health();self.assertEqual(len(self.node.body_pub.messages),count)
|
||||
self.time=previous+.08;self.node.health()
|
||||
self.assertEqual(len(self.node.body_pub.messages),count+1)
|
||||
self.assertEqual(self.node.body_pub.messages[-1].header.stamp,m.header.stamp)
|
||||
self.assertFalse(self.node.pending_odom)
|
||||
|
||||
def test_cloud_before_clock_is_deferred_without_timestamp_rewrite(self):
|
||||
self.anchor();previous=self.time;odom=self.odom(previous+.08);self.time=previous
|
||||
self.node.on_odom(odom)
|
||||
data=np.ones((111,6),dtype='<f4');m=PointCloud2();m.header=copy.deepcopy(odom.header)
|
||||
m.height=1;m.width=len(data);m.point_step=24;m.row_step=24*len(data)
|
||||
m.fields=[PointField(name=n,offset=i*4,datatype=PointField.FLOAT32,count=1) for i,n in enumerate(('x','y','z','lidar_x','lidar_y','lidar_z'))]
|
||||
m.data=array('B',data.tobytes());self.node.on_cloud(m)
|
||||
self.assertFalse(self.node.world_pub.messages)
|
||||
self.time=previous+.08;self.node.health()
|
||||
self.assertEqual(self.node.world_pub.messages[-1].header.stamp,m.header.stamp)
|
||||
self.assertFalse(self.node.pending_cloud)
|
||||
|
||||
def test_expired_pending_data_does_not_become_fresh_after_clock_jump(self):
|
||||
self.anchor();previous=self.time;m=self.odom(previous+.08);self.time=previous
|
||||
count=len(self.node.body_pub.messages);self.node.on_odom(m)
|
||||
self.time=previous+.4;self.node.health()
|
||||
self.assertEqual(len(self.node.body_pub.messages),count)
|
||||
self.assertFalse(self.node.ready_pub.messages[-1].data)
|
||||
|
||||
def test_pending_source_order_cannot_hide_backwards_time(self):
|
||||
self.anchor();previous=self.time
|
||||
a=self.odom(previous+.08);b=self.odom(previous+.04);self.time=previous
|
||||
self.node.on_odom(a);self.node.on_odom(b)
|
||||
self.time=previous+.08;self.node.health()
|
||||
self.assertIn('backwards',self.node.fault)
|
||||
|
||||
def test_far_future_samples_do_not_publish_or_fill_pending_queue(self):
|
||||
self.anchor();previous=self.time;m=self.odom(previous+1.);self.time=previous
|
||||
count=len(self.node.body_pub.messages);self.node.on_odom(m)
|
||||
self.assertFalse(self.node.pending_odom);self.assertEqual(self.node.future_dropped,1)
|
||||
self.assertEqual(len(self.node.body_pub.messages),count)
|
||||
|
||||
def test_stopped_clock_pending_queue_is_bounded_and_fails_closed(self):
|
||||
self.anchor();previous=self.time;m=self.odom(previous+.08);self.time=previous
|
||||
count=len(self.node.body_pub.messages)
|
||||
for _ in range(65):self.node.on_odom(copy.deepcopy(m))
|
||||
self.assertEqual(len(self.node.pending_odom),64)
|
||||
self.assertIn('queue overflow',self.node.fault)
|
||||
self.assertEqual(len(self.node.body_pub.messages),count)
|
||||
|
||||
|
||||
if __name__=='__main__':unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user