更新时间:2025-02-20 GMT+08:00
分享

Struct

struct类型,又称结构类型,是一种由简单类型(例如int、float、string类型,scalar类型,简单的struct类型等)构建的复杂类型,一般用于表示抽象的道路结构,与地图文件中的具体的道路结构建立关联。osc2.0支持的struct类型有:odr_point、position_3d、road_point、orientation_3d和pose_3d。

position_3d

  • 定义:笛卡尔(XYZ)坐标系中的三维位置(position)。
  • 用途:设置坐标系中的三维位置,用于构成xyz_point。
  • 参数:参数如下表
    表1 position_3d参数

    Parameter

    Type

    Mandatory

    Description

    x

    length

    yes

    position on the x-axis

    y

    length

    yes

    position on the y-axis

    z

    length

    yes

    position on the z-axis

代码样例

my_position: position_3d with:
    keep(it.x == 150.0m)
    keep(it.y == 200.0m)
    keep(it.z == 0.0m)

xyz_point

  • 定义:笛卡尔(XYZ)坐标系中的特定位置点(point)。
  • 用途:设置实体位置,用于构成pose_3d。
  • 参数:参数如下表
    表2 xyz_point参数

    Parameter

    Type

    Mandatory

    Description

    position

    position_3d

    yes

    Position in Cartesian (XYZ) coordinates

keep创建

my_pos: position_3d with:
    keep(it.x == 150.0m)
    keep(it.y == 200.0m)
    keep(it.z == 0.0m)
my_xyz: xyz_point with:
    keep(it.position == my_pos)

create创建

my_xyz: xyz_point = map.create_xyz_point(x: 150.0m, y: 200.0m ,z: 0.0m)

road_point

  • 定义:路网s-t坐标系中的特定位置点(point)。
  • 用途:设置实体位置,用于构成pose_3d。
  • 参数:参数如下表
    表3 road_point参数

    Parameter

    Type

    Mandatory

    Description

    road_id

    string

    yes

    identifier for the road in which this point is located

    s

    length

    yes

    Coordinate along the s-axis of the corresponding road

    t

    length

    yes

    Coordinate along the t-axis of the corresponding road

keep创建

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

create创建

my_point: road_point = map.create_road_point(road_id: '1', s: 5.0m, t: 0.0m)

odr_point

  • 定义:ASAM OpenDRIVE坐标系中的位置点(point)。
  • 用途:设置实体位置,用于构成pose_3d。
  • 参数:参数如下表
    表4 odr_point参数

    Parameter

    Type

    Mandatory

    Description

    road_id

    string

    yes

    ASAM OpenDRIVE identifier for the road

    lane_id

    string

    yes

    ASAM OpenDRIVE identifier for the lane

    s

    length

    yes

    Coordinate along the ASAM OpenDRIVE s-axis

    t

    length

    yes

    Coordinate along the ASAM OpenDRIVE t-axis, the t-coordinate is measured from the lane centerline

keep创建

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

create创建

my_odr: odr_point = map.create_odr_point(road_id: '1',lane_id:'-2',s: 3.0m, t: 0.0m)

orientation_3d

  • 定义:由Tait–Bryan角度的三个参数roll(横滚角,围绕x轴的角度)、pitch(俯仰角,围绕y轴的角度)和yaw(偏航角,围绕z轴的角度)定义的三维角度
  • 用途:设置实体的朝向角度、用于构成pose_3d。
  • 参数:参数如下表
表5 orientation_3d参数

Parameter

Type

Mandatory

Description

roll

angle

yes

rotation angle around the x-axis

pitch

angle

yes

rotation angle around the y-axis

yaw

angle

yes

rotation angle around the z-axis

  • 根据ISO 8855的定义,角度旋转的顺序是:首先进行yaw(围绕z轴)、接着pitch(围绕新y轴),最后roll(围绕新x轴)。
  • 当实体的朝向与road0的方向相同时,无需设置orientation_3d。
  • angle的单位一般为rad(弧度)而非degree(角度),rad = degree*pi/180,1rad约等于57.3度(详见scalar units中的angle units一节)。

与road 0的方向相反(相差180°

m_orientation: orientation_3d with:
    keep(it.roll == 0.0rad)
    keep(it.pitch == 0.0rad)
    keep(it.yaw == 3.14rad)

pose_3d

  • 定义:三维空间的复合位置,包含位置点(odr_point或position_3d或road_point)和方向(orientation_3d)两个参数
  • 用途:设置实体的初始位置(assign_init_speed动作)、目标位置(acquire_position动作)
  • 参数:参数如下表
表6 pose_3d参数

Parameter

Type

Mandatory

Description

xyz_point

xyz_point

no

a pose in space specified in Cartesian (XYZ) coordinates

odr_point

odr_point

no

a point expressed in ASAM OpenDRIVE coordinates

road_point

road_point

no

a point on route network specified in S-T coordinates

orientation

orientation_3d

no

three-dimensional orientation

  • xyz_point、odr_point和road_point必须设置且仅设置一个,用以提供位置信息。
  • orientation非必选项,当不设置orientation时,对应roll、pitch、yaw均为0时的方向。

使用xyz_point、设置orientation

my_xyz: xyz_point = map.create_xyz_point(x: 150.0m, y: 200.0m ,z: 0.0m)
m_orientation: orientation_3d with:
    keep(it.roll == 0.0rad)
    keep(it.pitch == 0.0rad)        
    keep(it.yaw == 1.57rad)
my_pose: pose_3d with:
    keep(it.xyz_point == my_xyz)
    keep(it.orientation == m_orientation)

使用odr_point、不设置orientation

my_odr: odr_point = map.create_odr_point(road_id: '1',lane_id:'-2',s: 3.0m, t: 0.0m)
my_pose: pose_3d with:
    keep(it.odr_point == my_odr)

使用road_point不设置orientation

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

相关文档