Skip to content
This repository has been archived by the owner on Jan 23, 2024. It is now read-only.

Commit

Permalink
use argparse for argument parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
timonegk committed Feb 25, 2021
1 parent 4b883bb commit 2a854bd
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions bitbots_dynamic_kick/scripts/dummy_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from __future__ import print_function
import sys

import argparse
import math
from time import sleep
import random
Expand All @@ -20,6 +21,11 @@
showing_feedback = False

if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument('ball_y', nargs=1, type=float, help='y position of the ball [m]', default=0)
parser.add_argument('kick_direction', nargs=1, type=float, help='kick direction [°]', default=0)
args = parser.parse_args()

print("Beware: this script may only work when calling it directly on the robot "
"and will maybe result in tf errors otherwise")
print("[..] Initializing node", end='')
Expand Down Expand Up @@ -79,10 +85,10 @@ def feedback_cb(feedback):
frame_prefix = "" if os.environ.get("ROS_NAMESPACE") is None else os.environ.get("ROS_NAMESPACE") + "/"
goal.header.frame_id = frame_prefix + "base_footprint"
goal.ball_position.x = 0.2
goal.ball_position.y = float(sys.argv[1])
goal.ball_position.y = args.ball_y
goal.ball_position.z = 0

goal.kick_direction = Quaternion(*quaternion_from_euler(0, 0, math.radians(float(sys.argv[2]))))
goal.kick_direction = Quaternion(*quaternion_from_euler(0, 0, math.radians(args.kick_direction)))

goal.kick_speed = 1

Expand Down

0 comments on commit 2a854bd

Please sign in to comment.