fix(basic): accept --target option
This commit is contained in:
+16
-1
@@ -176,6 +176,9 @@ class ArucoDrive(Node):
|
||||
)
|
||||
|
||||
def on_odometry(self, message):
|
||||
frame = message.header.frame_id.strip("/")
|
||||
if frame:
|
||||
self.odom_frame = frame
|
||||
pose = message.pose.pose
|
||||
values = (pose.position.x, pose.position.y, yaw(pose.orientation))
|
||||
if all(math.isfinite(value) for value in values):
|
||||
@@ -318,7 +321,13 @@ class ArucoDrive(Node):
|
||||
|
||||
def arguments():
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument("target", type=int, help="ID целевой ArUco")
|
||||
parser.add_argument("target", nargs="?", type=int, help="ID целевой ArUco")
|
||||
parser.add_argument(
|
||||
"--target",
|
||||
dest="target_option",
|
||||
type=int,
|
||||
help="ID целевой ArUco (альтернатива позиционному аргументу)",
|
||||
)
|
||||
parser.add_argument("--robot", choices=("RMC1", "RMC2"), default="RMC2")
|
||||
parser.add_argument("--rows", type=int)
|
||||
parser.add_argument("--columns", type=int)
|
||||
@@ -334,6 +343,12 @@ def arguments():
|
||||
parser.add_argument("--yes", action="store_true", help="Не ждать Enter")
|
||||
parser.add_argument("--sim", action="store_true", help="Использовать /clock Webots")
|
||||
args = parser.parse_args()
|
||||
if args.target is not None and args.target_option is not None:
|
||||
parser.error("укажите target один раз: позиционно или через --target")
|
||||
if args.target is None:
|
||||
args.target = args.target_option
|
||||
if args.target is None:
|
||||
parser.error("укажите ID цели: TARGET или --target TARGET")
|
||||
if args.rows is None:
|
||||
args.rows = 6 if args.sim else 5
|
||||
if args.columns is None:
|
||||
|
||||
Reference in New Issue
Block a user