前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >commaai代码!

commaai代码!

作者头像
用户1908973
发布2018-07-24 15:48:08
4390
发布2018-07-24 15:48:08
举报
文章被收录于专栏:CreateAMindCreateAMind

1.Directory structure

  • cereal – The messaging spec used for all logs on the phone
  • common – Library like functionality we’ve developed here
  • opendbc – Files showing how to interpret data from cars
  • panda – Code used to communicate on CAN and LIN
  • phonelibs – Libraries used on the phone
  • selfdrive – Code needed to drive the car
    • assets – Fonts for ui
    • boardd – Daemon to talk to the board
    • car – Code that talks to the car and implements CarInterface
    • common – Shared C/C++ code for the daemons
    • controls – Python controls (PID loops etc) for the car
    • debug – Tools to help you debug and do car ports
    • logcatd – Android logcat as a service
    • loggerd – Logger and uploader of car data
    • proclogd – Logs information from proc
    • radar – Code that talks to the radar and implements RadarInterface
    • sensord – IMU / GPS interface code
    • test/plant – Car simulator running code through virtual maneuvers
    • ui – The UI
    • visiond – embedded vision pipeline

2.start entry

代码语言:javascript
复制
#selfdrive/manager.py     
     managed_processes = {
      "uploader": "selfdrive.loggerd.uploader",
      "controlsd": "selfdrive.controls.controlsd",
      "plannerd": "selfdrive.controls.plannerd",
      "radard": "selfdrive.controls.radard",
      "loggerd": ("loggerd", ["./loggerd"]),
      "logmessaged": "selfdrive.logmessaged",
      "tombstoned": "selfdrive.tombstoned",
      "logcatd": ("logcatd", ["./logcatd"]),
      "proclogd": ("proclogd", ["./proclogd"]),
      "boardd": ("boardd", ["./boardd"]),   # switch to c++ boardd
      "ui": ("ui", ["./ui"]),
      "visiond": ("visiond", ["./visiond"]),
      "sensord": ("sensord", ["./sensord"]), }
       car_started_processes = [
      'controlsd',
      'plannerd',
      'loggerd',
      'sensord',
      'radard',
      'visiond',
      'proclogd',
    ]

3.service_list.yaml

代码语言:javascript
复制
    # service_name:[port,shuld_log]


    # frame syncing packet
    frame: [8002, true]
    # accel, gyro, and compass
    sensorEvents: [8003, true]
    # GPS data, also global timestamp
    gpsNMEA: [8004, true]
    # CPU+MEM+GPU+BAT temps
    thermal: [8005, true]
    # List(CanData), list of can messages
    can: [8006, true]
    live100: [8007, true]
    # random events we want to log
    #liveEvent: [8008, true]
    model: [8009, true]
    features: [8010, true]
    health: [8011, true]
    live20: [8012, true]
    #liveUI: [8014, true]
    encodeIdx: [8015, true]
    liveTracks: [8016, true]
    sendcan: [8017, true]
    logMessage: [8018, true]
    liveCalibration: [8019, true]
    androidLog: [8020, true]
    carState: [8021, true]
    # 8022 is reserved for sshd
    carControl: [8023, true]
    plan: [8024, true]
    liveLocation: [8025, true]
    gpsLocation: [8026, true]
    ethernetData: [8027, true]
    navUpdate: [8028, true]
    qcomGnss: [8029, true]
    lidarPts: [8030, true]
    procLog: [8031, true]
    testModel: [8040, false]

4.plan

lateral plan : selfdrive.controls.lib.pathplanner longitudal plan: selfdrive.controls.lib.adaptivecruise

sub_sock:car_state,model,live20 pub_sock:plan

5.control

LongControl : selfdrive.controls.lib.longcontrol LatControl : selfdrive.controls.lib.latcontrol

sub_sock:can,plan,thermal,health pub_sock:car_state,live100:carcontrol

代码语言:javascript
复制
    # *** gas/brake PID loop ***
    final_gas, final_brake = LoC.update(enabled, CS.vEgo, v_cruise_kph,
                                        plan.vTarget,
                                        [plan.aTargetMin, plan.aTargetMax],
                                        plan.jerkFactor, CP)
    # *** steering PID loop ***
    final_steer, sat_flag = LaC.update(enabled, CS.vEgo, CS.steeringAngle, CS.steeringPressed, plan.dPoly, angle_offset, CP)
    # ***** control the car *****
    CC = car.CarControl.new_message()
    CC.enabled = enabled
    CC.gas = float(final_gas)
    CC.brake = float(final_brake)
    CC.steeringTorque = float(final_steer)
    CC.cruiseControl.override = True
    CC.cruiseControl.cancel = bool((not CP.enableCruise) or (not enabled and CS.cruiseState.enabled))    # always cancel if we have an interceptor
    # brake discount removes a sharp nonlinearity
    brake_discount = (1.0 - clip(final_brake*3., 0.0, 1.0))
    CC.cruiseControl.speedOverride = float(max(0.0, ((LoC.v_pid - .5) * brake_discount)) if CP.enableCruise else 0.0)
    #CC.cruiseControl.accelOverride = float(AC.a_pcm)
    # TODO: fix this
    CC.cruiseControl.accelOverride = float(1.0)
    CC.hudControl.setSpeed = float(v_cruise_kph * CV.KPH_TO_MS)
    CC.hudControl.speedVisible = enabled
    CC.hudControl.lanesVisible = enabled
    CC.hudControl.leadVisible = plan.hasLead
    CC.hudControl.visualAlert = visual_alert
    CC.hudControl.audibleAlert = audible_alert

6 minutes self_driving

代码语言:javascript
复制
    if enabled:
      # gives the user 6 minutes
      awareness_status -= 1.0/(100*60*6)
      if awareness_status <= 0.:
        AM.add("driverDistracted", enabled)
    # reset awareness status on steering
    if CS.steeringPressed:
      awareness_status = 1.0

6.visiond

computer vision and machine learning embeded in visiond.

visiond uses an internal framework to run the neural net. Tensorflow is way too slow on phones.

Currently comma.ai have no plans to open source visiond.

7.radard

代码语言:javascript
复制
    # *** subscribe to features and model from visiond
    model = messaging.sub_sock(context, service_list['model'].port)
    PP = PathPlanner(model)
    # *** get path prediction from the model ***
    PP.update(sec_since_boot(), v_ego)
本文参与 腾讯云自媒体分享计划,分享自微信公众号。
原始发表:2017-07-09,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 CreateAMind 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 1.Directory structure
  • 2.start entry
  • 3.service_list.yaml
  • 4.plan
  • 5.control
  • 6.visiond
  • 7.radard
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档