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 45b8851
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions bitbots_dynamic_kick/scripts/dummy_client.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
#!/usr/bin/env python3

from __future__ import print_function
import sys

import actionlib
import argparse
import math
from time import sleep
import os
import random
import rospy
import actionlib
import os
import sys
from time import sleep

from actionlib_msgs.msg import GoalStatus
from geometry_msgs.msg import Vector3, Quaternion
Expand All @@ -20,6 +19,11 @@
showing_feedback = False

if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument('ball_y', type=float, help='y position of the ball [m]', default=0)
parser.add_argument('kick_direction', 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 +83,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 45b8851

Please sign in to comment.