Skip to content

Commit 75f392a

Browse files
committed
Fix running as a subcommand and add optional t0, t1 (SDK 1.35+)
1 parent 33ebe1c commit 75f392a

File tree

1 file changed

+23
-5
lines changed

1 file changed

+23
-5
lines changed

python/cli/smooth.py

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
"""
2-
Post-process a session and generate a smoothed trajectory
2+
Post-process a session and generate a smoothed trajectory with all frames
33
"""
44
import json
5-
from process.process import parse_input_dir, auto_config
65

7-
# --- The following mechanism allows using this both as a stand-alone
8-
# script and as a subcommand in sai-cli.
6+
try:
7+
from process.process import parse_input_dir, auto_config
8+
except ImportError:
9+
# hacky: The following mechanism allows using this both as a stand-alone
10+
# script and as a subcommand in sai-cli.
11+
from .process.process import parse_input_dir, auto_config
912

1013
def define_args(parser):
1114
parser.add_argument("input", help="Path to folder with session to process")
@@ -14,6 +17,8 @@ def define_args(parser):
1417
parser.add_argument("--key_frame_distance", help="Minimum distance between keyframes (meters)", type=float, default=0.15)
1518
parser.add_argument('--fast', action='store_true', help='Fast but lower quality settings')
1619
parser.add_argument('--internal', action='append', type=str, help='Internal override parameters in the form --internal=name:value')
20+
parser.add_argument('-t0', '--start_time', type=float, default=None, help='Start time in seconds')
21+
parser.add_argument('-t1', '--stop_time', type=float, default=None, help='Stop time in seconds')
1722
parser.add_argument("--preview", help="Show current key frame", action="store_true")
1823
parser.add_argument("--preview3d", help="Show 3D visualization", action="store_true")
1924
return parser
@@ -187,7 +192,20 @@ def on_mapping_output(output):
187192

188193
print(config)
189194

190-
replay = spectacularAI.Replay(args.input, mapperCallback = on_mapping_output, configuration = config, ignoreFolderConfiguration = True)
195+
replayArgs = dict(
196+
mapperCallback=on_mapping_output,
197+
configuration=config,
198+
ignoreFolderConfiguration=True
199+
)
200+
201+
# Requires SDK 1.35+
202+
if args.start_time is not None:
203+
replayArgs['startTime'] = args.start_time
204+
if args.stop_time is not None:
205+
replayArgs['stopTime'] = args.stop_time
206+
207+
replay = spectacularAI.Replay(args.input, **replayArgs)
208+
replay.setPlaybackSpeed(-1) # full speed
191209
replay.setOutputCallback(on_vio_output)
192210

193211
try:

0 commit comments

Comments
 (0)