Fix action smoothing history and viewer timing control
This commit is contained in:
@@ -201,6 +201,10 @@ def parse_args():
|
||||
)
|
||||
parser.add_argument("--timeout", type=float, default=30.0, help="validation timeout in simulation seconds")
|
||||
parser.add_argument("--log-interval", type=float, default=0.5, help="pose log interval in simulation seconds")
|
||||
parser.add_argument(
|
||||
"--realtime-factor", type=float, default=1.0,
|
||||
help="viewer playback speed relative to wall time (default: 1.0)",
|
||||
)
|
||||
parser.add_argument("--manual", action="store_true", help="start with zero velocity and use keyboard commands")
|
||||
parser.add_argument("--headless", action="store_true", help="run validation without viewer or real-time delay")
|
||||
parser.add_argument("--no-validation", action="store_true", help="do not stop with automatic PASS/FAIL")
|
||||
@@ -217,6 +221,9 @@ def main():
|
||||
if args.headless and args.no_validation:
|
||||
print("[ERROR] --headless requires automatic validation", file=sys.stderr)
|
||||
return 2
|
||||
if args.realtime_factor <= 0.0:
|
||||
print("[ERROR] --realtime-factor must be positive", file=sys.stderr)
|
||||
return 2
|
||||
|
||||
terrain_map = {
|
||||
"flat": "scene_dreamwaq_flat.xml",
|
||||
@@ -292,6 +299,7 @@ def main():
|
||||
"down={platform_end:.2f}->{down_end:.2f}m pass_x={pass_x:.2f}m".format(**course)
|
||||
)
|
||||
if not args.headless:
|
||||
print(f"[Viewer] realtime_factor={args.realtime_factor:.2f}x")
|
||||
print("[CTRL] W/S forward/back, Q/E lateral, A/D yaw, Space stop, R reset, Esc quit")
|
||||
|
||||
keyboard = None
|
||||
@@ -423,7 +431,7 @@ def main():
|
||||
|
||||
if view is not None:
|
||||
view.sync()
|
||||
deadline = wall_start + data.time
|
||||
deadline = wall_start + data.time / args.realtime_factor
|
||||
remaining = deadline - time.monotonic()
|
||||
if remaining > 0:
|
||||
time.sleep(remaining)
|
||||
|
||||
@@ -11,6 +11,7 @@ terrain="stairs_box"
|
||||
level="0"
|
||||
forward_speed="0.5"
|
||||
timeout="30"
|
||||
realtime_factor="1.0"
|
||||
export_only=false
|
||||
manual=false
|
||||
headless=false
|
||||
@@ -31,6 +32,8 @@ Options:
|
||||
-l, --level N Terrain difficulty level passed to sim2sim. Default: 0.
|
||||
--speed MPS Autonomous forward command. Default: 0.5.
|
||||
--timeout SEC Validation timeout in simulation seconds. Default: 30.
|
||||
--realtime-factor X
|
||||
Viewer playback speed. Default: 1.0 (real time).
|
||||
--manual Start at zero velocity and use keyboard commands.
|
||||
--headless Run validation without a viewer or real-time delay.
|
||||
--no-validation Run until the viewer closes instead of returning PASS/FAIL.
|
||||
@@ -82,6 +85,11 @@ while (($#)); do
|
||||
timeout="$2"
|
||||
shift 2
|
||||
;;
|
||||
--realtime-factor)
|
||||
(($# >= 2)) || die "$1 requires a number"
|
||||
realtime_factor="$2"
|
||||
shift 2
|
||||
;;
|
||||
--manual)
|
||||
manual=true
|
||||
shift
|
||||
@@ -115,6 +123,8 @@ esac
|
||||
[[ "$level" =~ ^[0-9]+$ ]] || die "level must be a non-negative integer: ${level}"
|
||||
[[ "$forward_speed" =~ ^[0-9]+([.][0-9]+)?$ ]] || die "speed must be a non-negative number: ${forward_speed}"
|
||||
[[ "$timeout" =~ ^[0-9]+([.][0-9]+)?$ ]] || die "timeout must be a non-negative number: ${timeout}"
|
||||
[[ "$realtime_factor" =~ ^[0-9]+([.][0-9]+)?$ ]] || die "realtime-factor must be a positive number: ${realtime_factor}"
|
||||
[[ "$realtime_factor" != "0" && "$realtime_factor" != "0.0" ]] || die "realtime-factor must be positive"
|
||||
command -v uv >/dev/null 2>&1 || die "uv is not available in PATH"
|
||||
|
||||
if [[ -z "$checkpoint" ]]; then
|
||||
@@ -159,6 +169,7 @@ sim_args=(
|
||||
--level "$level"
|
||||
--forward-speed "$forward_speed"
|
||||
--timeout "$timeout"
|
||||
--realtime-factor "$realtime_factor"
|
||||
)
|
||||
[[ "$manual" == true ]] && sim_args+=(--manual)
|
||||
[[ "$headless" == true ]] && sim_args+=(--headless)
|
||||
|
||||
Reference in New Issue
Block a user