SimOnePNCAPI module

SimOnePNCAPI.SoRegisterVehicleState(mainVehicleId: str, data: list, size: int) bool[源代码]

注册主车状态信息(超出SimOne_Data_Gps范围)

Register additional vehicle state information beyond what is included in SimOne_Data_Gps.

参数:
  • mainVehicleId -- 车辆ID / Vehicle ID

  • data (list[ESimOne_Data_Vehicle_State]) -- 需要注册的车辆状态信息数组 / Array of states to register

  • size -- 状态数量 / Number of states

返回:

执行结果:成功或失败 / Success or failure

返回类型:

bool

示例

states = [ESimOne_Data_Vehicle_State.SPEED]
SoRegisterVehicleState("MainVehicle", states, len(states))
SimOnePNCAPI.SoGetVehicleState(mainVehicleId: str, data: SimOne_Data_Vehicle_Extra) bool[源代码]

获取通过SoRegisterVehicleState注册的主车状态信息

Retrieve vehicle states registered with SoRegisterVehicleState.

参数:
  • mainVehicleId -- 车辆ID / Vehicle ID

  • data (SimOne_Data_Vehicle_Extra) -- 主车动态状态信息 / Vehicle state information

返回:

执行结果:成功或失败 / Success or failure

返回类型:

bool

示例

extra_state = SimOne_Data_Vehicle_Extra()
SoGetVehicleState("MainVehicle", extra_state)
SimOnePNCAPI.SoSetPose(mainVehicleId: str, poseControl: SimOne_Data_Pose_Control) bool[源代码]

设置主车位置

Set the next position of the main vehicle.

参数:
  • mainVehicleId -- 车辆ID / Vehicle ID

  • poseControl (SimOne_Data_Pose_Control) -- 下一个车辆位置 / Next vehicle position

返回:

执行结果:成功或失败 / Success or failure

返回类型:

bool

示例

pose = SimOne_Data_Pose_Control()
pose.position.x = 10.0
pose.position.y = 20.0
SoSetPose("MainVehicle", pose)
SimOnePNCAPI.SoSetDrive(mainVehicleId: str, driveControl: SimOne_Data_Control) bool[源代码]

主车控制

Control the main vehicle using throttle, steering, and brake.

参数:
  • mainVehicleId -- 车辆ID / Vehicle ID

  • driveControl (SimOne_Data_Control) -- 车辆驾驶参数 / Driving parameters

返回:

执行结果:成功或失败 / Success or failure

返回类型:

bool

示例

control = SimOne_Data_Control()
control.throttle = 0.5
control.steering = 0.1
SoSetDrive("MainVehicle", control)
SimOnePNCAPI.SoSetDriveTrajectory(mainVehicleId: str, controlTrajectory: SimOne_Data_Control_Trajectory) bool[源代码]

主车控制 - 按轨迹驾驶

Drive the vehicle along a planned trajectory.

参数:
返回:

执行结果:成功或失败 / Success or failure

返回类型:

bool

SimOnePNCAPI.SoSetDriverName(mainVehicleId: str, driverName: str) bool[源代码]

设置主车控制器的名字

Set the name of the vehicle controller (max length 8 chars).

参数:
  • mainVehicleId -- 车辆ID / Vehicle ID

  • driverName -- 驾驶员名字(最多8个字符)/ Driver name (max 8 chars)

返回:

执行结果:成功或失败 / Success or failure

返回类型:

bool

SimOnePNCAPI.SoSetDriveMode(mainVehicleId: str, driverMode: ESimOne_Drive_Mode) bool[源代码]

设置主车控制模式

Set the driving mode of the vehicle dynamics.

模式包括 / Modes include:

  • ESimOne_Drive_Mode_API: 通过API控制模块驾驶 / Driving by API

  • ESimOne_Drive_Mode_Driver: 通过SimOneDriver控制驾驶 / Driving by SimOneDriver

  • ESimOne_Drive_Mode_API_Lateral: 横向API,纵向Driver / Lateral by API, longitudinal by Driver

  • ESimOne_Drive_Mode_API_Longitudinal: 横向Driver,纵向API / Lateral by Driver, longitudinal by API

参数:
  • mainVehicleId -- 车辆ID / Vehicle ID

  • driverMode (ESimOne_Drive_Mode) -- 驾驶模式 / Driving mode

返回:

执行结果:成功或失败 / Success or failure

返回类型:

bool

SimOnePNCAPI.SoSetVehicleEvent(mainVehicleId: str, vehicleEventInfo: SimOne_Data_Vehicle_EventInfo) bool[源代码]

设置主车预警消息

Set warning messages for the main vehicle.

参数:
  • mainVehicleId -- 车辆ID / Vehicle ID

  • vehicleEventInfo (SimOne_Data_Vehicle_EventInfo) -- 驾驶过程中生成的事件信号 / Event signal during driving

返回:

执行结果:成功或失败 / Success or failure

返回类型:

bool

SimOnePNCAPI.SoSetSignalLights(mainVehicleId: str, pSignalLight: SimOne_Data_Signal_Lights) bool[源代码]

设置车辆信号灯状态

Set the state of the vehicle's signal lights.

参数:
返回:

执行结果:成功或失败 / Success or failure

返回类型:

bool

SimOnePNCAPI.SoGetDriverControl(mainVehicleId: str, driverControlData: SimOne_Data_Control) bool[源代码]

获取SimOneDriver控制信号

Get control signals from SimOneDriver.

参数:
  • mainVehicleId -- 车辆ID / Vehicle ID

  • driverControlData (SimOne_Data_Control) -- 驾驶控制信息 / Driver control data

返回:

执行结果:成功或失败 / Success or failure

返回类型:

bool

SimOnePNCAPI.SoGetControlMode(mainVehicleId: str, controlModeData: SimOne_Data_Control_Mode) bool[源代码]

获取车辆控制模式

Retrieve the current vehicle control mode.

参数:
  • mainVehicleId -- 车辆ID / Vehicle ID

  • controlModeData (SimOne_Data_Control_Mode) -- 当前控制模式 / Current control mode

返回:

执行结果:成功或失败 / Success or failure

返回类型:

bool

SimOnePNCAPI.SoGetWayPoints(mainVehicleId: str, wayPointsData: SimOne_Data_WayPoints) bool[源代码]

获取案例主车路径点

Retrieve the waypoints of the main vehicle from scenario editing.

参数:
  • mainVehicleId -- 车辆ID / Vehicle ID

  • wayPointsData (SimOne_Data_WayPoints) -- 路径点数据 / Waypoints data

返回:

执行结果:成功或失败 / Success or failure

返回类型:

bool

SimOnePNCAPI.SoAPISetScenarioEventCB(cb: callable) bool[源代码]

场景事件回调

Register a callback function for scenario events.

参数:

cb (callable) -- 场景事件的回调函数 / Callback for scenario events

Callback signature:
def callback(source: str, target: str, type: str, content: str) -> None

Callback parameters:

  • source (str): 发送消息的车辆ID / Vehicle ID sending the message

  • target (str): 接收方ID / Target ID

  • type (str): 消息类型("Command"或"Event")/ Message type

  • content (str): 消息内容 / Message content

返回:

执行结果:成功或失败 / Success or failure

返回类型:

bool

SimOnePNCAPI.SoSetVehicleToInitState(mainVehicleId: str) bool[源代码]

重置主车状态

Reset the main vehicle to its initial state.

参数:

mainVehicleId -- 主车ID / Vehicle ID

返回:

执行结果:成功或失败 / Success or failure

返回类型:

bool