From ef5c38fad5a175b6afca1dfa718d9e22d98828a2 Mon Sep 17 00:00:00 2001 From: Jonas Date: Fri, 22 Jun 2018 19:05:58 +0200 Subject: [PATCH] modified input parser --- pykick/striker.py | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/pykick/striker.py b/pykick/striker.py index a10bf07..57c5eec 100644 --- a/pykick/striker.py +++ b/pykick/striker.py @@ -278,28 +278,30 @@ if __name__ == '__main__': # rest # kick - # try to readout arguments - try: - args=sys.argv[1] - except NameError: - args='' + parser = argparse.ArgumentParser() + parser.add_argument("-s", "--stand", action="store_true", + help="let the robot stand up") + parser.add_argument("-k", "--kick", action="store_true", + help="let the robot do a fancy kick") + parser.add_argument("-r", "--rest", action="store_true", + help="let the robot rest") + + args = parser.parse_args() - # check input argument - if args: + # bring robot in stand_up position + if args.stand: + striker.mover.stand_up() - # bring robot in stand_up position - if args == 'stand': - striker.mover.stand_up() + # bring robot in rest postion + elif args.rest: + striker.mover.rest() - # bring robot in rest postion - elif args == 'rest': - striker.mover.rest() - - # perform a fancy kick - elif args == 'kick': - striker.mover.stand_up() - striker.mover.kick() - striker.mover.rest() + # perform a fancy kick + elif args.kick: + striker.mover.stand_up() + striker.mover.kick() + striker.mover.rest() + # perform normal state-machine if no input argument is given else: