Apollo 3.5 Cyber - 如何為Dreamview新增hmi mode

有人寫過ros遷移cyber的方法,當中寫到了怎寫launch conf跟dag文件,那我就懶得寫了
https://blog.csdn.net/davidhopper/article/details/85989091

Apollo以Dreamview為啟動一切模塊的中心,功能模塊的開關都由Dreamview的web介面控制。而Dreamview的介面內容跟選項是由Dreamview下的conf決定。而Dreamview中提供了不同hmi模式,不同模式可用功能模塊都不一。

所以modules/dreamview/conf/hmi_modes下的hmi node是直接決定了你可以控制那些功能模塊。
那對於有自已新增硬件或模塊的用戶來言,要寫自己的hmi mode是必然的。

先說明一下,你要加的文件除了Dreamviewhmi mode外,還有cyber 中的scheduler conf


hmi mode 文件

hmi mode 文件就是一個protobuf文件
其內部結構就是modules/dreamview/proto/hmi_mode.proto
當中有三大要素

  • cyber_modules

要用cyber啟動的功能模塊,Dreamview就會用nohup mainboard把它啟動。
一個cyber_modules對應一個process。
value就是相關componet的dag文件,我假設你己經會寫了
process_group就是cyber中scheduler conf的名字,
process_group: "compute_sched"就指向cyber/conf/compute_sched.conf 這文件

cyber_modules {
  key: "Computer"
  value: {
    dag_files: "/apollo/modules/drivers/camera/dag/camera_no_compress.dag"
    dag_files: "/apollo/modules/drivers/gnss/dag/gnss.dag"
    dag_files: "/apollo/modules/drivers/radar/conti_radar/dag/conti_radar.dag"
    dag_files: "/apollo/modules/drivers/velodyne/dag/velodyne.dag"
    dag_files: "/apollo/modules/localization/dag/dag_streaming_msf_localization.dag"
    dag_files: "/apollo/modules/perception/production/dag/dag_streaming_perception.dag"
    dag_files: "/apollo/modules/perception/production/dag/dag_streaming_perception_trafficlights.dag"
    dag_files: "/apollo/modules/routing/dag/routing.dag"
    dag_files: "/apollo/modules/transform/dag/static_transform.dag"
    process_group: "compute_sched"
  }
}
cyber_modules {
  key: "Controller"
  value: {
    dag_files: "/apollo/modules/canbus/dag/canbus.dag"
    dag_files: "/apollo/modules/guardian/dag/guardian.dag"
    process_group: "control_sched"
  }
}
  • modules

就一般非cyber模塊,內容為一句shell script command。要定義如何啟動,如何關閉
還有如何知道它是否存活

modules {
  key: "Recorder"
  value: {
    start_command: "/apollo/scripts/record_bag.py --start"
    stop_command: "/apollo/scripts/record_bag.py --stop"
    process_monitor_config {
      command_keywords: "cyber_recorder record"
    }
  }
}
  • monitored_components

專注監察進程,不會啟動模塊。從system status topic看status


scheduler conf文件

上面說到如果你加了新的cyber模塊,那你最好需要自定一個 scheduler conf (為了控制你新加的模塊在那一個cpu thread上跑)

scheduler的conf也分choreography跟classic兩種,一般用classic就可以,如果要做到完全控制才用前者。

兩種scheduler的不同
https://blog.csdn.net/weixin_44450715/article/details/86538575

仔細怎寫,可看上文跟參考其他現有的conf
而你要注意的是,scheduler conf中task和processor/group的配對要小心,一不小心是可以出現starvation的。
因為scheduler中並沒有按task的等待時間改動priority,它是完全跟從你自己的設定的。


hmi mode 文件的命名規則可看以下

# Vehicle Modes

This folder contains modes configuration for Apollo vehicle. Each pb.txt should
be an instance of HMIMode. Check the proto for detailed information.

## Name Convention

We'll convert the file name to a readable title-case name automatically to
display on Dreamview. So please make it simple, clean and meaningful.

Some examples:

* mkz_standard_debug.pb.txt -> "Mkz Standard Debug"
* mkz_close_loop.pb.txt     -> "Mkz Close Loop"
* mkz_map_collection.pb.txt -> "Mkz Map Collection"

終於把要寫的文檔寫完,可以調代碼去了~

你可能感兴趣的:(apollo)