diff --git a/README.md b/README.md index ec0efc67621992..d03e294394a27a 100644 --- a/README.md +++ b/README.md @@ -35,8 +35,7 @@ while 1: # in publisher pm = messaging.PubMaster(['sensorEvents']) -dat = messaging.new_message() -dat.init('sensorEvents', 1) +dat = messaging.new_message('sensorEvents', size=1) dat.sensorEvents[0] = {"gyro": {"v": [0.1, -0.1, 0.1]}} pm.send('sensorEvents', dat) ``` diff --git a/car.capnp b/car.capnp index 58ff3fb42e95cb..695f4a91bc47fd 100644 --- a/car.capnp +++ b/car.capnp @@ -127,6 +127,7 @@ struct CarState { steeringRateLimited @29 :Bool; # if the torque is limited by the rate limiter stockAeb @30 :Bool; stockFcw @31 :Bool; + espDisabled @32 :Bool; # cruise state cruiseState @10 :CruiseState; @@ -150,6 +151,10 @@ struct CarState { # which packets this state came from canMonoTimes @12: List(UInt64); + + # blindspot sensors + leftBlindspot @33 :Bool; # Is there something blocking the left lane change + rightBlindspot @34 :Bool; # Is there something blocking the right lane change struct WheelSpeeds { # optional wheel speeds @@ -441,6 +446,7 @@ struct CarParams { noOutput @19; # like silent but without silent CAN TXs hondaBoschHarness @20; volkswagenPq @21; + subaruLegacy @22; # pre-Global platform } enum SteerControlType { @@ -468,10 +474,21 @@ struct CarParams { fwdCamera @3; engine @4; unknown @5; + transmission @8; # Transmission Control Module + srs @9; # airbag + gateway @10; # can gateway + hud @11; # heads up display + combinationMeter @12; # instrument cluster # Toyota only dsu @6; apgs @7; + + # Honda only + vsa @13; # Vehicle Stability Assist + programmedFuelInjection @14; + electricBrakeBooster @15; + shiftByWire @16; } enum FingerprintSource { diff --git a/log.capnp b/log.capnp index 46971d81a309e9..90e2ec4026268e 100644 --- a/log.capnp +++ b/log.capnp @@ -626,9 +626,11 @@ struct ModelData { brakeDisengageProb @2 :Float32; gasDisengageProb @3 :Float32; steerOverrideProb @4 :Float32; + desireState @5 :List(Float32); } struct LongitudinalData { + distances @2 :List(Float32); speeds @0 :List(Float32); accelerations @1 :List(Float32); } @@ -790,6 +792,52 @@ struct PathPlan { } } +struct LiveLocationKalman { + + # More info on reference frames: + # https://github.com/commaai/openpilot/tree/master/common/transformations + + positionECEF @0 : Measurement; + positionGeodetic @1 : Measurement; + velocityECEF @2 : Measurement; + velocityNED @3 : Measurement; + velocityDevice @4 : Measurement; + accelerationDevice @5: Measurement; + + + # These angles are all eulers and roll, pitch, yaw + # orientationECEF transforms to rot matrix: ecef_from_device + orientationECEF @6 : Measurement; + orientationNED @7 : Measurement; + angularVelocityDevice @8 : Measurement; + + # orientationNEDCalibrated transforms to rot matrix: NED_from_calibrated + orientationNEDCalibrated @9 : Measurement; + + # Calibrated frame is simply device frame + # aligned with the vehicle + velocityCalibrated @10 : Measurement; + accelerationCalibrated @11 : Measurement; + angularVelocityCalibrated @12 : Measurement; + + gpsWeek @13 :Int32; + gpsTimeOfWeek @14 :Float64; + status @15 :Status; + unixTimestampMillis @16 :Int64; + + enum Status { + uninitialized @0; + uncalibrated @1; + valid @2; + } + + struct Measurement { + value @0 : List(Float64); + std @1 : List(Float64); + valid @2 : Bool; + } +} + struct LiveLocationData { status @0 :UInt8; @@ -1877,6 +1925,16 @@ struct KalmanOdometry { rotStd @3 :List(Float32); # std rad/s in device frame } +struct Sentinel { + enum SentinelType { + endOfSegment @0; + endOfRoute @1; + startOfSegment @2; + startOfRoute @3; + } + type @0 :SentinelType; +} + struct Event { # in nanoseconds? logMonoTime @0 :UInt64; @@ -1933,7 +1991,7 @@ struct Event { gpsLocationExternal @48 :GpsLocationData; location @49 :LiveLocationData; uiNavigationEvent @50 :UiNavigationEvent; - liveLocationKalman @51 :LiveLocationData; + liveLocationKalmanDEPRECATED @51 :LiveLocationData; testJoystick @52 :Joystick; orbOdometry @53 :OrbOdometry; orbFeatures @54 :OrbFeatures; @@ -1953,5 +2011,7 @@ struct Event { carParams @69: Car.CarParams; frontFrame @70: FrameData; dMonitoringState @71: DMonitoringState; + liveLocationKalman @72 :LiveLocationKalman; + sentinel @73 :Sentinel; } } diff --git a/messaging/__init__.py b/messaging/__init__.py index e5a004740dfaaa..b53d6fb7ab6247 100644 --- a/messaging/__init__.py +++ b/messaging/__init__.py @@ -19,10 +19,15 @@ context = Context() -def new_message(): +def new_message(service=None, size=None): dat = log.Event.new_message() dat.logMonoTime = int(sec_since_boot() * 1e9) dat.valid = True + if service is not None: + if size is None: + dat.init(service) + else: + dat.init(service, size) return dat def pub_sock(endpoint): @@ -148,12 +153,11 @@ def __init__(self, services, ignore_alive=None, addr="127.0.0.1"): self.sock[s] = sub_sock(s, poller=self.poller, addr=addr, conflate=True) self.freq[s] = service_list[s].frequency - data = new_message() try: - data.init(s) + data = new_message(s) except capnp.lib.capnp.KjException: # lists - data.init(s, 0) + data = new_message(s, 0) self.data[s] = getattr(data, s) self.logMonoTime[s] = 0