|
@@ -11,21 +11,23 @@ from scenariogeneration import xosc
|
|
from scenariogeneration import ScenarioGenerator
|
|
from scenariogeneration import ScenarioGenerator
|
|
from scenariogeneration.xodr import RoadSide, Object, ObjectType, Dynamic, Orientation
|
|
from scenariogeneration.xodr import RoadSide, Object, ObjectType, Dynamic, Orientation
|
|
import math, os
|
|
import math, os
|
|
|
|
+# from xodr_generator2 import road_detector_new
|
|
from datetime import datetime
|
|
from datetime import datetime
|
|
import traceback
|
|
import traceback
|
|
import json
|
|
import json
|
|
import pandas as pd
|
|
import pandas as pd
|
|
from enum import Enum
|
|
from enum import Enum
|
|
|
|
+import elevation_0323 as el
|
|
from xml.sax.saxutils import escape
|
|
from xml.sax.saxutils import escape
|
|
|
|
|
|
import warnings
|
|
import warnings
|
|
warnings.filterwarnings("ignore")
|
|
warnings.filterwarnings("ignore")
|
|
|
|
|
|
-xodr_list = ['/home/hancheng/taiheqiao_map/thq_1116.xodr', '/home/hancheng/gongyuanbeihuan_map/OD/OpenDRIVE.xodr','/home/hancheng/glyt_map/OpenDRIVE/OpenDRIVE2.xodr']
|
|
|
|
-osgb_list = ['/home/hancheng/taiheqiao_map/thq_1116.opt.osgb', '/home/hancheng/gongyuanbeihuan_map/osgb/GJBM_20km_0822.opt.osgb', '/home/hancheng/glyt_map/OSGB/jinlong_20231129_2_guazai.opt.osgb']
|
|
|
|
|
|
+xodr_list = ['/mnt/disk001/simulation_outdoor/thq_1116.xodr', '/mnt/disk001/simulation_outdoor/anqing.xodr']
|
|
|
|
+osgb_list = ['/mnt/disk001/simulation_outdoor/thq_1116.opt.osgb', '/mnt/disk001/simulation_outdoor/anqing.osgb']
|
|
|
|
|
|
class Scenario(ScenarioGenerator):
|
|
class Scenario(ScenarioGenerator):
|
|
- def __init__(self, gps, obs, gps_time, ego_speed, work_mode, period, abspath, timeofday, vehicle_type):
|
|
|
|
|
|
+ def __init__(self, gps, obs, gps_time, ego_speed, work_mode, period, abspath, timeofday, vehicle_type, map_id):
|
|
ScenarioGenerator.__init__(self)
|
|
ScenarioGenerator.__init__(self)
|
|
self.gps = gps
|
|
self.gps = gps
|
|
self.obs = obs
|
|
self.obs = obs
|
|
@@ -38,6 +40,7 @@ class Scenario(ScenarioGenerator):
|
|
self.visual_fog_range = 20000 # 正常的能见度,没有雾
|
|
self.visual_fog_range = 20000 # 正常的能见度,没有雾
|
|
self.time = 43200 # 强制为白天
|
|
self.time = 43200 # 强制为白天
|
|
self.vehicle_type = vehicle_type
|
|
self.vehicle_type = vehicle_type
|
|
|
|
+ self.map_id = map_id
|
|
# self.map_id = map_id
|
|
# self.map_id = map_id
|
|
# self.ObjectID = ObjectID
|
|
# self.ObjectID = ObjectID
|
|
# self.Speed = Speed
|
|
# self.Speed = Speed
|
|
@@ -213,8 +216,7 @@ class Scenario(ScenarioGenerator):
|
|
|
|
|
|
print(laneDF[laneDF['FrameID']>1860][['FrameID', 'LaneID', 'LanePosition']].head(50))
|
|
print(laneDF[laneDF['FrameID']>1860][['FrameID', 'LaneID', 'LanePosition']].head(50))
|
|
print('road_label: ', road_label)
|
|
print('road_label: ', road_label)
|
|
-
|
|
|
|
-
|
|
|
|
|
|
+
|
|
return laneDF
|
|
return laneDF
|
|
|
|
|
|
# def road_new(self, **kwargs):
|
|
# def road_new(self, **kwargs):
|
|
@@ -340,26 +342,52 @@ class Scenario(ScenarioGenerator):
|
|
init_flag = True
|
|
init_flag = True
|
|
|
|
|
|
# two method to set z value
|
|
# two method to set z value
|
|
- for row in egodata.iterrows():
|
|
|
|
- hhh = math.radians(row[1][h])
|
|
|
|
- if init_flag:
|
|
|
|
- position.append(xosc.WorldPosition(x=float(row[1][e]), y=float(row[1][n]), z=float(row[1][z]), h=hhh, p=0, r=0))
|
|
|
|
- init_flag = False
|
|
|
|
- else:
|
|
|
|
- if float(row[1][h]) - lasth > 300:
|
|
|
|
- hhh = math.radians(float(row[1][h]) - 360)
|
|
|
|
- elif float(row[1][h]) - lasth < -300:
|
|
|
|
- hhh = math.radians(float(row[1][h]) + 360)
|
|
|
|
- position.append(xosc.WorldPosition(x=float(row[1][e]), y=float(row[1][n]), z=float(row[1][z]), h=hhh, p=0, r=0))
|
|
|
|
- lasth = float(row[1][h])
|
|
|
|
- time.append(float(row[1][t]))
|
|
|
|
- # time.append(cur_time)
|
|
|
|
- # cur_time += 0.1
|
|
|
|
- return position, time, ego_type
|
|
|
|
|
|
+ zflag = 0 # 1
|
|
|
|
+ if zflag:
|
|
|
|
+ # 根据地图的xy值计算z值
|
|
|
|
+ zfile = '/home/hancheng/weihao/gongyuanbei_elevation.csv'
|
|
|
|
+ # zfile = '/home/hancheng/simulation_dynamic/elevation_df_taiheqiao.csv'
|
|
|
|
+ zdata = pd.read_csv(zfile)
|
|
|
|
+
|
|
|
|
+ for row in egodata.iterrows():
|
|
|
|
+ hhh = math.radians(row[1][h])
|
|
|
|
+ xodr_z = el.cal_elevation(zdata, float(row[1][e]), float(row[1][n]))
|
|
|
|
+ if init_flag:
|
|
|
|
+ position.append(xosc.WorldPosition(x=float(row[1][e]), y=float(row[1][n]), z=xodr_z, h=hhh, p=0, r=0))
|
|
|
|
+ init_flag = False
|
|
|
|
+ else:
|
|
|
|
+ if float(row[1][h]) - lasth > 300:
|
|
|
|
+ hhh = math.radians(float(row[1][h]) - 360)
|
|
|
|
+ elif float(row[1][h]) - lasth < -300:
|
|
|
|
+ hhh = math.radians(float(row[1][h]) + 360)
|
|
|
|
+ position.append(xosc.WorldPosition(x=float(row[1][e]), y=float(row[1][n]), z=xodr_z, h=hhh, p=0, r=0))
|
|
|
|
+ lasth = float(row[1][h])
|
|
|
|
+ time.append(float(row[1][t]))
|
|
|
|
+ # time.append(cur_time)
|
|
|
|
+ # cur_time += 0.1
|
|
|
|
+ return position, time, ego_type
|
|
|
|
+ else:
|
|
|
|
+ # z = 0
|
|
|
|
+ for row in egodata.iterrows():
|
|
|
|
+ hhh = math.radians(row[1][h])
|
|
|
|
+ if init_flag:
|
|
|
|
+ position.append(xosc.WorldPosition(x=float(row[1][e]), y=float(row[1][n]), z=float(row[1][z]), h=hhh, p=0, r=0))
|
|
|
|
+ init_flag = False
|
|
|
|
+ else:
|
|
|
|
+ if float(row[1][h]) - lasth > 300:
|
|
|
|
+ hhh = math.radians(float(row[1][h]) - 360)
|
|
|
|
+ elif float(row[1][h]) - lasth < -300:
|
|
|
|
+ hhh = math.radians(float(row[1][h]) + 360)
|
|
|
|
+ position.append(xosc.WorldPosition(x=float(row[1][e]), y=float(row[1][n]), z=float(row[1][z]), h=hhh, p=0, r=0))
|
|
|
|
+ lasth = float(row[1][h])
|
|
|
|
+ time.append(float(row[1][t]))
|
|
|
|
+ # time.append(cur_time)
|
|
|
|
+ # cur_time += 0.1
|
|
|
|
+ return position, time, ego_type
|
|
|
|
|
|
def scenario(self, **kwargs):
|
|
def scenario(self, **kwargs):
|
|
- road = xosc.RoadNetwork(roadfile='/home/hancheng/maps/taiheqiao_map/thq_1116.xodr',
|
|
|
|
- scenegraph='/home/hancheng/maps/taiheqiao_map/thq_1116.opt.osgb')
|
|
|
|
|
|
+ road = xosc.RoadNetwork(roadfile=xodr_list[self.map_id],
|
|
|
|
+ scenegraph=osgb_list[self.map_id])
|
|
catalog = xosc.Catalog()
|
|
catalog = xosc.Catalog()
|
|
catalog.add_catalog('VehicleCatalog', 'Distros/Current/Config/Players/Vehicles')
|
|
catalog.add_catalog('VehicleCatalog', 'Distros/Current/Config/Players/Vehicles')
|
|
catalog.add_catalog('PedestrianCatalog', 'Distros/Current/Config/Players/Pedestrians')
|
|
catalog.add_catalog('PedestrianCatalog', 'Distros/Current/Config/Players/Pedestrians')
|
|
@@ -620,7 +648,7 @@ class Scenario(ScenarioGenerator):
|
|
|
|
|
|
sce = xosc.Scenario('my scenario', 'Maggie', paramet, entities, sb, road, catalog)
|
|
sce = xosc.Scenario('my scenario', 'Maggie', paramet, entities, sb, road, catalog)
|
|
return sce
|
|
return sce
|
|
-
|
|
|
|
|
|
+
|
|
def createUDAction(self, name):
|
|
def createUDAction(self, name):
|
|
# tree = ET.parse('./models/ped_CDATA.xosc')
|
|
# tree = ET.parse('./models/ped_CDATA.xosc')
|
|
# root = tree.getroot()
|
|
# root = tree.getroot()
|
|
@@ -640,12 +668,14 @@ class Scenario(ScenarioGenerator):
|
|
newnode.text = "<![CDATA[\n{}]\n]>".format(text)
|
|
newnode.text = "<![CDATA[\n{}]\n]>".format(text)
|
|
return newnode
|
|
return newnode
|
|
|
|
|
|
|
|
+
|
|
class WorkMode(Enum):
|
|
class WorkMode(Enum):
|
|
cicv = 0 # CICV车端
|
|
cicv = 0 # CICV车端
|
|
roadside = 1 # 车网路端
|
|
roadside = 1 # 车网路端
|
|
car = 2 # 车网车端
|
|
car = 2 # 车网车端
|
|
merge = 3 # 车网车端路端融合
|
|
merge = 3 # 车网车端路端融合
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+
|
|
def get_obj_type(mode):
|
|
def get_obj_type(mode):
|
|
if mode == WorkMode.cicv.value:
|
|
if mode == WorkMode.cicv.value:
|
|
# CICV车端
|
|
# CICV车端
|
|
@@ -681,6 +711,7 @@ def get_obj_type(mode):
|
|
cone_type = [103]
|
|
cone_type = [103]
|
|
return ped_type, car_type, bicycle_motor_type, bus_type, truck_type, cone_type
|
|
return ped_type, car_type, bicycle_motor_type, bus_type, truck_type, cone_type
|
|
|
|
|
|
|
|
+
|
|
# 创建道路旁静止的场景
|
|
# 创建道路旁静止的场景
|
|
def create_static_object(road, object_dict):
|
|
def create_static_object(road, object_dict):
|
|
for single_object in object_dict:
|
|
for single_object in object_dict:
|