File tree Expand file tree Collapse file tree
driving_log_replayer_v2/driving_log_replayer_v2/launch Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -44,6 +44,7 @@ Evaluation:
4444 DirectInitialPose : Dictionary # optional; omit this key or use {} to disable the pose
4545 GoalPose : Dictionary # optional; omit this key or use {} to disable the pose
4646 goal_method : String # optional, default: set_goal_from_scenario
47+ time_offset : Dictionary # optional, default: {}
4748include_use_case :
4849 UseCaseName : String
4950 UseCaseFormatVersion : String
@@ -185,6 +186,16 @@ GoalPose:
185186| `set_goal_from_scenario` | (Default) Use `GoalPose` from scenario to set goal. Skip setting goal if `GoalPose` is not specified. |
186187| `set_goal_from_rosbag` | Read the last `/localization/kinematic_state` from rosbag and use its position as the goal. Even if `GoalPose` is specified ignore it. |
187188
189+ # ### time_offset
190+
191+ (Optional) Specify the start time and duration of rosbag playback. The start time is specified as a relative time from the start of the rosbag, not based on timestamp. Place it at the same level as `GoalPose` in the dataset section of the scenario YAML.
192+
193+ ` ` ` yaml
194+ time_offset:
195+ start: float # the start time [s]
196+ duration: float # the duration [s]
197+ ` ` `
198+
188199# ## include_use_case
189200
190201Use this when you want to perform evaluation with a different use case simultaneously with the use case specified in Evaluation.
Original file line number Diff line number Diff line change @@ -44,6 +44,7 @@ Evaluation:
4444 DirectInitialPose : Dictionary # optional, 省略時は {} として扱われる (無効化する場合はキーを省略するか {} を指定すること)
4545 GoalPose : Dictionary # optional, 省略時は {} として扱われる (無効化する場合はキーを省略するか {} を指定すること)
4646 goal_method : String # optional, default: set_goal_from_scenario
47+ time_offset : Dictionary # optional, default: {}
4748include_use_case :
4849 UseCaseName : String
4950 UseCaseFormatVersion : String
@@ -184,6 +185,16 @@ GoalPose:
184185| `set_goal_from_scenario` | (デフォルト)シナリオの `GoalPose` を使用してゴールを設定する。`GoalPose` が未指定の場合は何もしない。 |
185186| `set_goal_from_rosbag` | rosbagの最後の `/localization/kinematic_state` を読み取り、その位置をゴールとして使用する。 `GoalPose` が指定されていても無視する。 |
186187
188+ # ### time_offset
189+
190+ (オプション)rosbagの再生開始時刻と再生時間を指定する。前者はtimestamp基準ではなく、rosbagの開始からの相対時間で指定する。シナリオYAMLのデータセットセクションで `GoalPose` と同じ階層に配置する。
191+
192+ ` ` ` yaml
193+ time_offset:
194+ start: float # rosbag再生開始時刻 [s]
195+ duration: float # rosbag再生時間 [s]
196+ ` ` `
197+
187198# ## include_use_case
188199
189200Evaluationで指定したユースケースとは別のユースケースの評価を同時に行う場合に使用する。
Original file line number Diff line number Diff line change @@ -232,6 +232,7 @@ def update_conf_with_dataset_info(
232232 conf ["direct_initial_pose" ] = json .dumps (dataset_info .get ("DirectInitialPose" , {}))
233233 conf ["goal_pose" ] = json .dumps (dataset_info .get ("GoalPose" , {}))
234234 conf ["goal_method" ] = dataset_info .get ("goal_method" , "set_goal_from_scenario" )
235+ conf ["time_offset" ] = json .dumps (dataset_info .get ("time_offset" , {}))
235236 conf ["t4_dataset_path" ] = t4_dataset_path .as_posix ()
236237 if "vehicle_model" not in conf :
237238 conf ["vehicle_model" ] = yaml_obj ["VehicleModel" ]
@@ -299,6 +300,9 @@ def ensure_arg_compatibility(context: LaunchContext) -> list:
299300 LogInfo (
300301 msg = f"{ check_launch_component (conf )= } " ,
301302 ),
303+ LogInfo (
304+ msg = f"{ conf ['time_offset' ]= } " ,
305+ ),
302306 LogInfo (
303307 msg = f"{ conf ['initial_pose' ]= } , { conf ['direct_initial_pose' ]= } " ,
304308 ),
Original file line number Diff line number Diff line change 1313# limitations under the License.
1414
1515from importlib import import_module
16+ import json
1617from pathlib import Path
1718
1819from ament_index_python .packages import get_package_prefix
@@ -139,6 +140,20 @@ def get_pre_task_before_play_rosbag(
139140 )
140141
141142
143+ def get_rosbag_timestamp_offset (play_cmd : list [str ], context : LaunchContext ) -> list [str ]:
144+ conf = context .launch_configurations
145+ if conf ["time_offset" ] == "{}" :
146+ return play_cmd
147+ time_offset = json .loads (conf ["time_offset" ])
148+ start = time_offset .get ("start" , None )
149+ if start is not None :
150+ play_cmd .extend (["--start-offset" , str (start )])
151+ duration = time_offset .get ("duration" , None )
152+ if duration is not None :
153+ play_cmd = ["timeout" , "--preserve-status" , str (duration ), * play_cmd ]
154+ return play_cmd
155+
156+
142157def launch_bag_player (
143158 context : LaunchContext ,
144159) -> IncludeLaunchDescription :
@@ -155,6 +170,8 @@ def launch_bag_player(
155170 "--qos-profile-overrides-path" ,
156171 QOS_PROFILE_PATH_STR ,
157172 ]
173+ # timestamp offset
174+ play_cmd = get_rosbag_timestamp_offset (play_cmd , context )
158175 # topics
159176 publish_list = ["--topics" ]
160177 publish_list .extend (user_defined_publish (conf ))
You can’t perform that action at this time.
0 commit comments