fix(sim): clean up interrupted runs and document usage and migration
Prevent ROS cleanup errors from skipping owned Gazebo process teardown. Reject occupied master ports before launching nodes and stop the stack when its GUI closes. Add --gui to the automatic LIO navigation checks. Expand the root README and add a beginner guide covering manual goals, automatic tests, restart troubleshooting, MID360 assumptions and staged migration to real hardware. Preserve lifecycle and GUI validation evidence. Validation: three navigation restart cycles, two busy-port rejection cases, SIGINT/SIGHUP cleanup and a GUI straight-route check. Current source hashes, Python syntax, documentation shell syntax and local links verified. Hardware migration remains unverified; no push performed.
This commit is contained in:
@@ -17,7 +17,7 @@ from sensor_msgs.msg import PointCloud2
|
||||
from std_msgs.msg import String
|
||||
from rclpy.qos import QoSProfile,DurabilityPolicy,qos_profile_sensor_data
|
||||
|
||||
from check_omni_robot import Sim,sim_env
|
||||
from check_omni_robot import Sim,sim_env, shutdown_probe
|
||||
from check_scan_navigation import NavProbe,run_goal
|
||||
from check_slope_drive import SlopeProbe
|
||||
|
||||
@@ -145,16 +145,17 @@ def main():
|
||||
ap.add_argument('--laps',type=int,default=1)
|
||||
ap.add_argument('--sensor-profile',choices=('ideal','mild','stress'),default='ideal')
|
||||
ap.add_argument('--split',action='store_true')
|
||||
ap.add_argument('--gui',action='store_true',help='Show Gazebo while testing (default: headless)')
|
||||
args=ap.parse_args()
|
||||
if not 1<=args.laps<=5 or (args.laps>1 and (args.straight_only or args.fault_only or args.recovery_only)):
|
||||
ap.error('laps must be 1..5 and multi-lap mode requires complete navigation')
|
||||
out=Path(args.out).resolve();out.mkdir(parents=True,exist_ok=True)
|
||||
os.environ.update(sim_env());os.environ['ROS_LOG_DIR']=str(out/'ros')
|
||||
source=Path(__file__).read_bytes();(out/'collector_snapshot.py').write_bytes(source)
|
||||
report=dict(status='INVALID',cases=[],sensor_profile=args.sensor_profile,laps=args.laps,split=args.split,collector_sha256=hashlib.sha256(source).hexdigest())
|
||||
report=dict(status='INVALID',cases=[],sensor_profile=args.sensor_profile,laps=args.laps,split=args.split,gui=args.gui,collector_sha256=hashlib.sha256(source).hexdigest())
|
||||
sim,p=Sim(str(out/'sim')),None
|
||||
try:
|
||||
ok,why=sim.start(lio_navigation=True,sensor_profile=args.sensor_profile,split=args.split);report['startup']=why
|
||||
ok,why=sim.start(lio_navigation=True,sensor_profile=args.sensor_profile,split=args.split,gui=args.gui);report['startup']=why
|
||||
if not ok:raise RuntimeError(why)
|
||||
rclpy.init();p=LioNavProbe()
|
||||
if not p.wait_clock():raise RuntimeError('missing clock')
|
||||
@@ -200,8 +201,7 @@ def main():
|
||||
except Exception as exc:
|
||||
report['error']=repr(exc);print(report['error'],flush=True)
|
||||
finally:
|
||||
if p is not None:p.send(0.,0.,0.);p.destroy_node()
|
||||
if rclpy.ok():rclpy.shutdown()
|
||||
report['ros_cleanup_errors'] = shutdown_probe(p)
|
||||
report['teardown']=sim.stop();(out/'result.json').write_text(json.dumps(report,indent=2)+'\n')
|
||||
return {'PASS':0,'FAIL':30,'INVALID':40}[report['status']]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user