(args=None)
| 310 | |
| 311 | |
| 312 | def main(args=None): |
| 313 | rclpy.init(args=args) |
| 314 | |
| 315 | # Parse command line arguments |
| 316 | parser = argparse.ArgumentParser( |
| 317 | description='Publish NPZ motion data as MotionBlock messages') |
| 318 | parser.add_argument('npz_file', help='Path to NPZ motion file') |
| 319 | parser.add_argument( |
| 320 | '--mode', |
| 321 | choices=['single', 'batch'], |
| 322 | default='batch', |
| 323 | help='Publishing mode: single (all at once) or batch (in chunks)') |
| 324 | parser.add_argument( |
| 325 | '--batch_size', |
| 326 | type=int, |
| 327 | default=8, |
| 328 | help='Number of timesteps per batch (only for batch mode)') |
| 329 | parser.add_argument('--rate', |
| 330 | type=float, |
| 331 | default=6.25, |
| 332 | help='Publishing rate in Hz (only for batch mode)') |
| 333 | |
| 334 | # Parse known args to handle ROS2 arguments |
| 335 | parsed_args, unknown = parser.parse_known_args() |
| 336 | |
| 337 | try: |
| 338 | npz_motion_publisher = NPZMotionPublisher( |
| 339 | npz_file_path=parsed_args.npz_file, |
| 340 | mode=parsed_args.mode, |
| 341 | batch_size=parsed_args.batch_size, |
| 342 | publish_rate=parsed_args.rate) |
| 343 | |
| 344 | rclpy.spin(npz_motion_publisher) |
| 345 | |
| 346 | except Exception as e: |
| 347 | print(f'Error: {e}') |
| 348 | return 1 |
| 349 | finally: |
| 350 | if 'npz_motion_publisher' in locals(): |
| 351 | npz_motion_publisher.destroy_node() |
| 352 | rclpy.shutdown() |
| 353 | |
| 354 | return 0 |
| 355 | |
| 356 | |
| 357 | if __name__ == '__main__': |
no test coverage detected