#!/usr/bin/env python3

"""       █████╗ ████████╗ ██████╗ ███╗   ███╗
         ██╔══██╗╚══██╔══╝██╔═══██╗████╗ ████║
         ███████║   ██║   ██║   ██║██╔████╔██║
         ██╔══██║   ██║   ██║   ██║██║╚██╔╝██║
  __     ██║  ██║   ██║   ╚██████╔╝██║ ╚═╝ ██║    _
 / _|    ╚═╝  ╚═╝   ╚═╝    ╚═════╝ ╚═╝     ╚═╝   | |
 | |_ _ __ __ _ _ __ ___   _____      _____  _ __| | __
 |  _| '__/ _` | '_ ` _ \ / _ \ \ /\ / / _ \| '__| |/ /
 | | | | | (_| | | | | | |  __/\ V  V / (_) | |  |   <
 |_| |_|  \__,_|_| |_| |_|\___| \_/\_/ \___/|_|  |_|\_\
 https://github.com/lardemua/atom

WARNING WARNING WARNING WARNING
Auto-generated file on {{ c.date }}
Only modify this file if you know what you are doing!
"""

import argparse

from atom_core.system import execute

def main():

    # ---------------------------------------------------
    # Handle command line arguments
    # ---------------------------------------------------
    parser = argparse.ArgumentParser(
        description='Configure {{ c.package_name }} calibration package. See  https://lardemua.github.io/atom_documentation/procedures/#configure-a-calibration-package for more info.')
    
    parser.add_argument("-cgt", "--collect_ground_truth", action="store_true",
                        help='Assume transformations (\\tf and \\tf_static) in the bag file to be perfect, and collect them as ground truth for ATOM datasets. Useful for evaluating the calibration against ground truth.')

    parser.add_argument('-cfg', '--config_file', type=str,
                        help='Uses a custom calibration config.yml file.', default=None)

    args = vars(parser.parse_args())

    # ---------------------------------------------------
    # Prepare command to run
    # ---------------------------------------------------
    command = 'rosrun atom_calibration configure_calibration_pkg -n {{ c.package_name }}'

    if args['collect_ground_truth']:  # Add -utf flag if that's the case
        command += ' --cgt'

    if args['config_file'] is not None:  # Add custom config file if needed
        command += ' --config_file ' + args['config_file']

    # ---------------------------------------------------
    # Execute command
    # ---------------------------------------------------
    execute(command)


if __name__ == '__main__':
    main()
