|
@@ -1047,6 +1047,7 @@ class FinalDataProcessor:
|
|
print(f"Error: Required input file not found: {obj_state_path}")
|
|
print(f"Error: Required input file not found: {obj_state_path}")
|
|
return False
|
|
return False
|
|
# 处理交通灯数据并保存
|
|
# 处理交通灯数据并保存
|
|
|
|
+
|
|
df_traffic = self._process_trafficlight_data()
|
|
df_traffic = self._process_trafficlight_data()
|
|
if not df_traffic.empty:
|
|
if not df_traffic.empty:
|
|
traffic_csv_path = self.output_dir / "Traffic.csv"
|
|
traffic_csv_path = self.output_dir / "Traffic.csv"
|
|
@@ -1054,7 +1055,23 @@ class FinalDataProcessor:
|
|
print(f"Successfully created traffic light data file: {traffic_csv_path}")
|
|
print(f"Successfully created traffic light data file: {traffic_csv_path}")
|
|
# Load and process data
|
|
# Load and process data
|
|
df_object = pd.read_csv(obj_state_path, dtype={"simTime": float}, low_memory=False)
|
|
df_object = pd.read_csv(obj_state_path, dtype={"simTime": float}, low_memory=False)
|
|
-
|
|
|
|
|
|
+ df_ego = df_object[df_object["playerId"] == 1]
|
|
|
|
+ points = df_ego[["posX", "posY"]].values
|
|
|
|
+ window_size = 4
|
|
|
|
+ fitting_instance = PolynomialCurvatureFitting(lane_map_path)
|
|
|
|
+ result_list = fitting_instance.fit_and_project(points, window_size)
|
|
|
|
+
|
|
|
|
+ curvHor_values = [result["curvHor"] for result in result_list]
|
|
|
|
+ curvature_change_value = [result["curvHorDot"] for result in result_list]
|
|
|
|
+ min_distance = [result["laneOffset"] for result in result_list]
|
|
|
|
+
|
|
|
|
+ indices = df_object[df_object["playerId"] == 1].index
|
|
|
|
+ if len(indices) == len(curvHor_values):
|
|
|
|
+ df_object.loc[indices, "curvHor"] = curvHor_values
|
|
|
|
+ df_object.loc[indices, "curvHorDot"] = curvature_change_value
|
|
|
|
+ df_object.loc[indices, "laneOffset"] = min_distance
|
|
|
|
+ else:
|
|
|
|
+ print("计算值的长度与 playerId == 1 的行数不匹配!")
|
|
# Process and merge data
|
|
# Process and merge data
|
|
df_merged = self._merge_optional_data(df_object)
|
|
df_merged = self._merge_optional_data(df_object)
|
|
|
|
|