更新时间:2024-10-30 GMT+08:00
分享

参数声明(Parameter Declarations)

参数声明格式为“参数名: 参数类型”,可以使用“=”为参数赋值,例如“m_distance: length = 10.0m”。

无论是具体场景还是逻辑场景,都不要对一个参数重复赋值。

具体场景(Concrete scenario)

具体场景的参数声明支持基础类型标量(scalar)类型枚举(enum)类型,和结构(struct)类型

  • 基础类型包含int、float、bool,和string类型。可以直接在等号后赋值。
  • scalar类型包含speed、acceleration、length、time,和angle类型。赋值时需要在值后加上OSC2.0支持的单位(见附录Scalar units)。
  • enum类型包含side_left_right、distance_direction、distance_mode、 lane_change_side、 dynamics_shape和catalog。赋值时必须使用枚举列表内的值(见附录Enum list) 。
  • struct类型包含odr_point、xyz_point、position_3d、road_point、orientation_3d和pose_3d等,可以使用keep创建。此外,odr_point、xyz_point,和road_point分别可以使用map的成员函数create_odr_point 、 create_xyz_point和create_road_point来创建(OSC2.0支持的struct类型详见附录Struct)。
  • 给bool型赋值时必须使用“true”和“false”,如果使用“True”或“False”或拼写错误将使语句无效。

例1:基础类型

m_road_id: string = '0'
Ego_name: string = "Audi_A3_2009_black"
m_lateral: bool = true

例2:scalar类型

v: speed = 5mps
delay: time = 40s
distance: length = 30.0m
m_a: acceleration = 0.01mpss

例3:enum类型

m_side: side_left_right = right
m_direction: distance_direction = longitudinal

例4:struct类型,keep创建

my_odr: odr_point with:
    keep(it.road_id == 0)
    keep(it.lane_id == -1)
    keep(it.s == 3.0m)
    keep(it.t == 0.0m)

my_pos: position_3d with:
    keep(it.x == 1.0m)
    keep(it.y == 2.0m)
    keep(it.z == 3.0m)

my_xyz: xyz_point with:
    keep(it.position == my_pos)

my_road: road_point with:
    keep(it.road_id == '1')
    keep(it.s == 3.0m)
    keep(it.t == 0.0m)

my_orientation: orientation_3d with:
    keep(it.roll == 1.0rad)
    keep(it.pitch == 2.0rad)
    keep(it.yaw == 3.0rad)

my_pose: pose_3d with:
    keep(it.xyz_point == my_xyz)
    keep(it.orientation == m_orientation)

m_trajectory: trajectory with:
    keep(it.points == [my_pose1, my_pose2, my_pose3])
    keep(it.time_stamps == [0s, 5s, 20s] )

例5:struct类型,map创建

my_odr: odr_point = map.create_odr_point(road_id: m_road_id,lane_id:'-4',s: 5.0m, t: 0.0m) 
my_xyz: xyz_point = map.create_xyz_point(x: 2.5m, y: 10.0m ,z: 0.0m)
my_point: road_point = map.create_road_point(road_id: '1', s: 5.0m, t: 0.0m)

逻辑场景(Logical scenario)

逻辑场景的参数声明通过:范围型[最小值..最大值] 和枚举型[值1, 值2] 的方式来实现泛化:

  • 范围型支持float和scalar类型。
  • 枚举型支持int, float, bool, str, enum和scalar类型,且需要保证枚举列表中的元素均为相同类型。

例1:范围型

m_value: float = [2.0..3.0]
v: speed = [5mps..10mps]
delay: time = [40s..60s]
m_a: acceleration = [0.00mpss..0.03mpss]

例2:枚举型

m_ id: int = [-1, 2]
m_value: float = [2.0, 3.0]
m_on_road: bool = [true, false]
Ego_name: string = ["Audi_A3_2009_black", "Audi_A3_2009_red"]
m_shape: dynamics_shape = [linear, sinusoidal]
m_side: side_left_right = [left, right]
v: speed = [5mps, 7mps, 10mps]
m_a: acceleration = [0.01mpss, 0.03mpss]
delay: time = [40s, 60s, 100s]
  • 通过泛化参数,可以实现实体entity 、动作act ,以及修饰器modifier的泛化。
  • Struct类型不能直接泛化,而是通过泛化参数来进行泛化。

例1:entity泛化

Ego_name: string = ["Audi_A3_2009_black", "Audi_A3_2009_red"]
Ego_controller: string = "DefaultDriver"
Ego: vehicle with:
    keep(it.name == Ego_name)
    keep(it.initial_bm == Ego_controller)

例2:act泛化

m_lateral: bool = [true, false]
m_speed: speed = [5mps..15mps]
m_rate_profile: dynamics_shape = linear
Ego.activate_controller(m_lateral, true)
Ego.change_speed(target: m_speed, rate_peak: 0.0mpss, rate_profile: m_rate_profile)

例3:modifier泛化

m_speed: speed = [5mps..15mps]
Ego.assign_init_speed() with:
    speed(speed: m_speed)

例4:Struct类型泛化

m_lane_id: int = [-1, 2]
m_odr: odr_point = map.create_odr_point(road_id: '0', lane_id:m_lane_id, s: 5.0m, t: 0.0m)

m_x: distance = [2m..7.5m]
m_position_3d: position_3d = map.create_xyz_point(x: m_x, y: 10.0m ,z: 0.0m)

m_pose_3d: pose_3d with:
    keep(it.odr_point == m_odr)

相关文档