完善双雷达仿真与自动上坡任务,更新使用文档
加入下置 MID360 前向补盲与双雷达融合,修复北侧走廊导航、坐标适配和数据时效处理。 实现接近坡脚、姿态辅助上坡与平台停车任务,增加独立快模式、命令仲裁及失效停车保护,保留测试与分阶段验收记录。 同步实车尺寸及雷达安装参数,调整 Gazebo 红方默认视角,完善根目录 README、仿真使用和实车迁移说明。
This commit is contained in:
@@ -20,7 +20,7 @@ from check_omni_robot import Sim,sim_env, shutdown_probe
|
||||
from check_slope_drive import SlopeProbe
|
||||
|
||||
ROOT=Path(__file__).resolve().parents[2]
|
||||
MOUNT=np.array([0.,0.,.30])
|
||||
MOUNT=np.array([.015,0.,.33])
|
||||
|
||||
|
||||
def json_value(value):
|
||||
@@ -48,11 +48,12 @@ def interpolate(states,times):
|
||||
return pos[lo]+(pos[hi]-pos[lo])*w[:,None],qq
|
||||
|
||||
|
||||
def scene_shapes():
|
||||
def scene_shapes(model_path=None):
|
||||
"""Read authoritative static primitives and triangles; independent of ODE ray code."""
|
||||
base=ROOT/'sim_ws/src/robocon_gazebo/models/robocon_ground_full'
|
||||
result=[]
|
||||
for c in ET.parse(base/'model.sdf').findall('.//collision'):
|
||||
if model_path is not None:base=Path(model_path).parent
|
||||
for c in ET.parse(base/'model.sdf' if model_path is None else model_path).findall('.//collision'):
|
||||
p=np.fromstring(c.findtext('pose','0 0 0 0 0 0'),sep=' ')
|
||||
r,pitch,y=p[3:];cx,sx=np.cos(r),np.sin(r);cy,sy=np.cos(pitch),np.sin(pitch);cz,sz=np.cos(y),np.sin(y)
|
||||
R=np.array([[cz*cy,cz*sy*sx-sz*cx,cz*sy*cx+sz*sx],
|
||||
@@ -108,6 +109,16 @@ def ray_ranges(origins,directions,shapes):
|
||||
return best
|
||||
|
||||
|
||||
def vehicle_ranges(directions):
|
||||
"""Independent local ray/box intersection, including physical roof returns.
|
||||
|
||||
Measured roof=.41 m, retained base=.15 m, assumed body bottom=.07 m.
|
||||
Raw self hits are valid sensor observations, not outliers to hide.
|
||||
"""
|
||||
body=[(np.array([0.,0.,.09]),np.eye(3),'box',np.array([.4,.4,.17]))]
|
||||
return ray_ranges(np.broadcast_to(MOUNT,directions.shape),directions,body)
|
||||
|
||||
|
||||
class SensorProbe(SlopeProbe):
|
||||
def __init__(self):
|
||||
super().__init__();self.frames=[];self.imus=[];self.sensor_status=[]
|
||||
@@ -153,10 +164,10 @@ def geometry_check(p,record,shapes,out,name):
|
||||
times=f['t']+f['offsets'][idx]*1e-9
|
||||
pos,q=interpolate(states,times)
|
||||
origins=pos+rotate(q,np.broadcast_to(MOUNT,pos.shape));directions=rotate(q,direction)
|
||||
expected=ray_ranges(origins,directions,shapes)
|
||||
expected=np.minimum(ray_ranges(origins,directions,shapes),vehicle_ranges(direction))
|
||||
errors.extend(np.abs(expected-ranges).tolist())
|
||||
end_pos,end_q=interpolate(states,np.full(len(xyz),f['t']+.099))
|
||||
wrong=ray_ranges(end_pos+rotate(end_q,np.broadcast_to(MOUNT,end_pos.shape)),rotate(end_q,direction),shapes)
|
||||
wrong=np.minimum(ray_ranges(end_pos+rotate(end_q,np.broadcast_to(MOUNT,end_pos.shape)),rotate(end_q,direction),shapes),vehicle_ranges(direction))
|
||||
instant_errors.extend(np.abs(wrong-ranges).tolist())
|
||||
saved[str(i)+'_xyz']=f['xyz'];saved[str(i)+'_offset_ns']=f['offsets']
|
||||
saved[str(i)+'_query_t']=times;saved[str(i)+'_expected_range']=expected
|
||||
@@ -207,6 +218,13 @@ def main():
|
||||
if name!='stop':geometry[name]=geometry_check(p,records[name],shapes,out,name)
|
||||
frames=[f for f in p.frames if records['stationary']['t0']<=f['t']<records['stop']['t1']-.1]
|
||||
checks=result['checks']
|
||||
# Verify the actual transient-local TF messages, not only launch text.
|
||||
mounts={item['child']:item for item in p.tf_static_raw if item['frame_id']=='base_link'}
|
||||
for child,expected_mount in (('lidar',MOUNT),('mid360_imu',MOUNT+[.011,.02329,-.04412])):
|
||||
mount=mounts.get(child)
|
||||
checks['tf_'+child]=bool(mount is not None and np.allclose(mount['translation'],expected_mount,atol=1e-9,rtol=0)
|
||||
and np.allclose(mount['rotation'],[0,0,0,1],atol=1e-9,rtol=0))
|
||||
result['runtime_sensor_tf']=mounts
|
||||
checks['geometry']=all(g['ok'] for g in geometry.values())
|
||||
checks['frame_and_count']=all(f['frame']=='lidar' and f['point_num']==len(f['xyz']) and len(f['xyz'])>500 for f in frames)
|
||||
checks['finite_fov']=all(np.isfinite(f['xyz']).all() and np.min(np.arctan2(f['xyz'][:,2],np.linalg.norm(f['xyz'][:,:2],axis=1)))>=math.radians(-7)-1e-6 and np.max(np.arctan2(f['xyz'][:,2],np.linalg.norm(f['xyz'][:,:2],axis=1)))<=math.radians(52)+1e-6 for f in frames)
|
||||
|
||||
Reference in New Issue
Block a user