[fea]
[循环线路支持]
This commit is contained in:
yangyakun
2024-09-25 15:51:07 +08:00
parent 41f1b7312c
commit 2d5e2cdc48
6 changed files with 107 additions and 37 deletions

View File

@@ -59,5 +59,7 @@ class OchCommonConst {
// 自动驾驶自动规划的最大距离
const val AUTOMATIC_PLANNING_MAX_DISTANCE = 15
const val ARRIVE_AT_END_STATION_DISTANCE = 10
}
}

View File

@@ -95,7 +95,6 @@ object OchAutoPilotManager : IMoGoReceiveReceivedAckListener, IMoGoFsm2024Listen
@JvmStatic
fun startAutoPilot(controlParameters: AutopilotControlParameters?): Long {
val sessionId = CallerAutoPilotControlManager.startAutoPilot(controlParameters)
LineManager.isReStartAutopilot = false
globalSessionId.set(sessionId)
fsmBackSessionId.set(-1L)
OchAutopilotAnalytics.triggerStartAutopilotParameters(controlParameters, sessionId)

View File

@@ -6,11 +6,13 @@ import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotControlManager
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager
import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils
import com.mogo.eagle.core.utilcode.util.StringUtils
import com.mogo.eagle.core.utilcode.util.ToastUtils
import com.mogo.och.common.module.R
import com.mogo.och.common.module.manager.autopilot.autopilot.bean.ArrivedStation
import com.mogo.och.common.module.manager.autopilot.line.LineManager
import com.mogo.och.common.module.manager.autopilot.trajectory.TrajectoryManager
import com.mogo.och.common.module.manager.logchainanalytic.OchChainLogManager
import com.mogo.och.common.module.utils.CallerBase
import com.zhjt.mogo.adas.data.AdasConstants
import com.zhjt.mogo.adas.data.bean.MogoReport
@@ -51,10 +53,12 @@ object OchAutoPilotStatusListenerManager : CallerBase<IOchAutopilotStatusListene
LineManager.triggerStartServiceEvent(true, 0)
}
M_LISTENERS.forEach {
val listener = it.value
listener.onAutopilotStatusResponse(newValue)
}
LineManager.searchAutopilotState()
}
}
val autopilotState:Int
@@ -93,15 +97,6 @@ object OchAutoPilotStatusListenerManager : CallerBase<IOchAutopilotStatusListene
}
}
override fun onAutopilotArriveAtStation(arrivalNotification: MessagePad.ArrivalNotification?) {
super.onAutopilotArriveAtStation(arrivalNotification)
val trasform = ArrivedStation.trasform(arrivalNotification)
M_LISTENERS.forEach {
val listener = it.value
listener.onAutopilotArriveAtStation(trasform)
}
}
override fun onAutopilotSNRequest(basicInfoReq: MessagePad.BasicInfoReq) {
super.onAutopilotSNRequest(basicInfoReq)
M_LISTENERS.forEach {
@@ -196,6 +191,7 @@ object OchAutoPilotStatusListenerManager : CallerBase<IOchAutopilotStatusListene
override fun onAutopilotStatusResponseFromCan(state: Int) {
super.onAutopilotStatusResponseFromCan(state)
LineManager.searchAutopilotState()
M_LISTENERS.forEach {
val listener = it.value
listener.onAutopilotStatusResponseFromCan(state)
@@ -206,4 +202,36 @@ object OchAutoPilotStatusListenerManager : CallerBase<IOchAutopilotStatusListene
}
}
}
override fun onAutopilotArriveAtStation(arrivalNotification: MessagePad.ArrivalNotification?) {
super.onAutopilotArriveAtStation(arrivalNotification)
val trasform = ArrivedStation.trasform(arrivalNotification)
M_LISTENERS.forEach {
val listener = it.value
listener.onAutopilotArriveAtStation(trasform)
}
}
override fun onAutoPilotStation(
token: Long,
timestamp: Long,
autoPilotStation: SsmInfo.AutoPilotStation?
) {
OchChainLogManager.writeChainLogAutopilot("到站逻辑",
"token:$token 通过主动查询到站底盘传递:${autoPilotStation?.orderId}_${autoPilotStation?.arrivedStationFlag}")
autoPilotStation?.let {
if (it.hasOrderId() && !StringUtils.isEmpty(it.orderId)&&it.hasArrivedStationFlag()) {
LineManager.invokeArrivedStation(it.orderId,it.arrivedStationFlag)
}
}
}
override fun onAutoPilotInfo(token: Long, timestamp: Long, autoPilotInfo: SsmInfo.AutoPilotInfo?) {
OchChainLogManager.writeChainLogAutopilot("自驾状态",
"token:$token 通过主动查询到站底盘传递:${autoPilotInfo?.orderId}_第一次启动自驾${autoPilotInfo?.firstAutopilotFlag}_次数${autoPilotInfo?.count}")
autoPilotInfo?.let {
if (it.hasOrderId() && !StringUtils.isEmpty(it.orderId)) {
LineManager.invokeSetIsFirstAutopilot(it.orderId,it.firstAutopilotFlag,it.count)
}
}
}
}

View File

@@ -12,4 +12,6 @@ public interface ILineCallback {
default void startAutopilotTimeOut(){}
default void startAutopilotFailure(String startFailedCode,String startFailedMessage){}
default void arrivedStationSuccessBySearch(){}
}

View File

@@ -8,6 +8,7 @@ import com.mogo.eagle.core.data.autopilot.AutopilotControlParameters.AutoPilotLi
import com.mogo.eagle.core.data.autopilot.AutopilotControlParameters.AutoPilotLonLat
import com.mogo.eagle.core.data.config.FunctionBuildConfig
import com.mogo.eagle.core.data.map.MogoLocation
import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisLocationGCJ02Listener
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotControlManager
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager
import com.mogo.eagle.core.function.call.map.CallerMapGlobalTrajectoryDrawManager
@@ -15,12 +16,15 @@ import com.mogo.eagle.core.function.call.order.CallerOrderListenerManager
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.d
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.e
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_BUS
import com.mogo.eagle.core.utilcode.util.CoordinateUtils
import com.mogo.eagle.core.utilcode.util.StringUtils
import com.mogo.eagle.core.utilcode.util.ToastUtils
import com.mogo.och.common.module.constant.OchCommonConst
import com.mogo.och.common.module.manager.autopilot.OCHAdasAbilityManager
import com.mogo.och.common.module.manager.autopilot.autopilot.OchAutoPilotManager
import com.mogo.och.common.module.manager.autopilot.autopilot.OchAutoPilotManager.startAutoPilot
import com.mogo.och.common.module.manager.autopilot.autopilot.OchAutopilotAnalytics
import com.mogo.och.common.module.manager.autopilot.location.OchLocationManager
import com.mogo.och.common.module.manager.distance.TrajectoryAndDistanceManager
import com.mogo.och.common.module.manager.logchainanalytic.OchChainLogManager
import com.mogo.och.common.module.utils.CallerBase
@@ -64,14 +68,54 @@ object LineManager : CallerBase<ILineCallback>() {
*/
private var endStation: BusStationBean? = null
var isReStartAutopilot = true
var isFirstStartAutopilot = true
private var orderId = ""
// 自车定位
private val mMapLocationListener = object : IMoGoChassisLocationGCJ02Listener {
override fun onChassisLocationGCJ02(mogoLocation: MogoLocation?) {
if (null == mogoLocation) return
getStations { start, end ->
val startLon = end.gcjLon
val startLat = end.gcjLat
val distance = CoordinateUtils.calculateLineDistance(
startLon, startLat,
mogoLocation.longitude, mogoLocation.latitude
)
if (distance <= OchCommonConst.ARRIVE_AT_END_STATION_DISTANCE) {
val token = CallerAutoPilotControlManager.sendSsmFuncQueryAutoPilotStation(orderId)
OchChainLogManager.writeChainLogAutopilot("到站逻辑","距离站点:$distance 请求token$token")
}
}
}
}
fun invokeArrivedStation(orderId: String, arrivedStationFlag: Boolean) {
if (this.orderId==orderId&&arrivedStationFlag){
M_LISTENERS.forEach {
it.value.arrivedStationSuccessBySearch()
}
}
}
fun invokeSetIsFirstAutopilot(orderId: String?, firstAutopilotFlag: Boolean, count: Int) {
if (this.orderId==orderId){
if(count>=1){
isFirstStartAutopilot = false
}else{
isFirstStartAutopilot = true
}
}
}
/**
* 设置站点信息
*/
fun setStartAndEndStation(startStation: BusStationBean?, endStation: BusStationBean?) {
if(this.startStation!=startStation||this.endStation!=endStation){
isReStartAutopilot = true
isFirstStartAutopilot = true
}
this.startStation = startStation
this.endStation = endStation
@@ -197,11 +241,19 @@ object LineManager : CallerBase<ILineCallback>() {
endStationLocation.latitude = end.gcjLat
endStationLocation.longitude = end.gcjLon
TrajectoryAndDistanceManager.setStationPoint(startStationLocation, endStationLocation, lineInfo.lineId)
OchLocationManager.addGCJ02Listener(TAG,1,mMapLocationListener)
// 恢复启动自驾信息
searchAutopilotState()
}
}
fun searchAutopilotState(){
CallerAutoPilotControlManager.sendSsmFuncQueryAutoPilotInfo()
}
private fun clearAutopilotControlParameters(){
CallerAutoPilotStatusListenerManager.updateAutopilotControlParameters(null)
TrajectoryAndDistanceManager.setStationPoint(null, null, null)
this.orderId = ""
OchLocationManager.removeGCJ02Listener(TAG)
}
fun hasDrawnGlobalTrajectory(): Boolean {
@@ -245,6 +297,9 @@ object LineManager : CallerBase<ILineCallback>() {
parameters?.startLatLon = AutoPilotLonLat(start.lat, start.lon)
parameters?.endLatLon = AutoPilotLonLat(end.lat, end.lon)
parameters?.vehicleType = 10
this.orderId = "${lineInfo.lineId}_${start.siteId}_${end.siteId}"
parameters?.orderId = this.orderId
parameters?.firstAutopilotFlag = isFirstStartAutopilot
if (parameters?.autoPilotLine == null) {
parameters?.autoPilotLine = AutoPilotLine(
@@ -334,7 +389,7 @@ object LineManager : CallerBase<ILineCallback>() {
M_BUS + TAG,
"行程日志-开启自动驾驶====" + GsonUtil.jsonFromObject(parameters)
+ " startLatLon=" + parameters.startName + "endLatLon=" + parameters.endName +
"isRestart = " + LineManager.isReStartAutopilot
"isRestart = " + LineManager.isFirstStartAutopilot
)
M_LISTENERS.forEach {
@@ -354,7 +409,7 @@ object LineManager : CallerBase<ILineCallback>() {
fun triggerStartServiceEvent(send: Boolean,source:Int) {
getStationsWithLine { start, end, lineInfo ->
OchAutopilotAnalytics.triggerStartAutopilotEvent(
isReStartAutopilot,
isFirstStartAutopilot,
send,
start.name,
end.name,

View File

@@ -18,6 +18,7 @@ import com.mogo.eagle.core.utilcode.util.ToastUtils
import com.mogo.eagle.core.utilcode.util.UiThreadHandler
import com.mogo.och.common.module.biz.login.LoginStatusManager
import com.mogo.och.common.module.manager.autopilot.autopilot.bean.ArrivedStation
import com.mogo.och.common.module.manager.autopilot.line.ILineCallback
import com.mogo.och.common.module.manager.autopilot.line.LineManager
import com.mogo.och.common.module.manager.autopilot.location.OchLocationManager
import com.mogo.och.common.module.manager.logchainanalytic.OchChainLogManager
@@ -71,8 +72,8 @@ object OrderModel {
// 加载核销模块
TicketModel.load()
// 定位监听
OchLocationManager.addGCJ02Listener(TAG, 5, mMapLocationListener)
LineManager.addListener(TAG,arriveStationBySearch)
OchTransform.addListener(TAG,ochTransform)
@@ -87,7 +88,7 @@ object OrderModel {
TicketModel.release()
OchLocationManager.removeGCJ02Listener(TAG)
LineManager.removeListener(TAG)
OchTransform.removeListener(TAG)
}
@@ -105,34 +106,17 @@ object OrderModel {
// 自车定位
private val mMapLocationListener = object : IMoGoChassisLocationGCJ02Listener {
override fun onChassisLocationGCJ02(mogoLocation: MogoLocation?) {
if (null == mogoLocation) return
private val arriveStationBySearch = object : ILineCallback {
override fun arrivedStationSuccessBySearch() {
//是否到站的围栏判断 离站状态并且自动驾驶还未触发到站
if (isGoingToNextStation && !isArrivedStation) {
OCHThreadPoolManager.getsInstance().locationExecute {
judgeArrivedStation(mogoLocation)
onArriveAt(null, "兜底:根据定位计算到站")
}
}
}
}
//根据围栏判断,是否到达站点
private fun judgeArrivedStation(location: MogoLocation) {
LineManager.getStations { start, end ->
val startLon = end.gcjLon
val startLat = end.gcjLat
val distance = CoordinateUtils.calculateLineDistance(
startLon, startLat,
location.longitude, location.latitude
)
if (distance <= BusConst.ARRIVE_AT_END_STATION_DISTANCE) {
d(M_BUS + TAG, "行程日志-judgeArrivedStation() distance = $distance to ${end.name}")
onArriveAt(null, "兜底:根据定位计算到站")
}
}
}
/**
* 查询小巴路线