From 9490bd02e4e6d701097cc86ceeb53d37b1a2974e Mon Sep 17 00:00:00 2001 From: nayan Date: Fri, 27 Nov 2026 17:39:04 -0500 Subject: [PATCH] feat(mici): parametric hearts, remove blush, and add gyro/yaw/pitch centrifugal turn squish --- .../ui/mici/tests/test_robotic_ui.py | 22 +++++ .../mici/onroad/robotic/expressions.py | 90 ++++++++++++----- .../mici/onroad/robotic/face_renderer.py | 97 ++++++++++++------- .../mici/onroad/robotic/speed_arc_renderer.py | 22 +++-- openpilot/selfdrive/ui/sunnypilot/ui_state.py | 3 +- 5 files changed, 162 insertions(+), 72 deletions(-) diff --git a/openpilot/selfdrive/ui/mici/tests/test_robotic_ui.py b/openpilot/selfdrive/ui/mici/tests/test_robotic_ui.py index ef2b00246c..11ec62ca76 100644 --- a/openpilot/selfdrive/ui/mici/tests/test_robotic_ui.py +++ b/openpilot/selfdrive/ui/mici/tests/test_robotic_ui.py @@ -246,3 +246,25 @@ class TestRoboticMoodEngine(OpenpilotTestCase): ) engine.update(snap_alert, now=15.5) assert engine.mood == RoboticMood.USER_PROMPT + + def test_centrifugal_turn_squish_and_pitch_response(self): + engine = self._engine() + # Gentle left turn (yaw_rate > 0 -> pushed right: squish_force > 0) + snap_mild = DrivingSnapshot(started=True, engaged=True, status=UIStatus.ENGAGED, v_ego=15.0, yaw_rate=0.10, pitch_rad=0.05) + engine.update(snap_mild, now=10.0) + t_mild = engine.update(snap_mild, now=15.0) + assert t_mild.squish_force > 0.15 + assert t_mild.pitch_offset_y > 0.0 + + # Fast left turn (high lateral G -> strongly squished right + surprised mouth) + snap_fast = DrivingSnapshot(started=True, engaged=True, status=UIStatus.ENGAGED, v_ego=24.0, yaw_rate=0.18, pitch_rate=-0.2) + t_fast = engine.update(snap_fast, now=16.0) + assert engine.mood == RoboticMood.SHARP_TURN + assert t_fast.squish_force > t_mild.squish_force + assert t_fast.squish_force > 0.65 + assert t_fast.mouth == MouthGlyph.SURPRISED + + # Fast right turn (yaw_rate < 0 -> pushed left: squish_force < 0) + snap_right = DrivingSnapshot(started=True, engaged=True, status=UIStatus.ENGAGED, v_ego=22.0, yaw_rate=-0.18) + t_right = engine.update(snap_right, now=17.0) + assert t_right.squish_force < -0.65 diff --git a/openpilot/selfdrive/ui/sunnypilot/mici/onroad/robotic/expressions.py b/openpilot/selfdrive/ui/sunnypilot/mici/onroad/robotic/expressions.py index ac0e920525..bc03e8721e 100644 --- a/openpilot/selfdrive/ui/sunnypilot/mici/onroad/robotic/expressions.py +++ b/openpilot/selfdrive/ui/sunnypilot/mici/onroad/robotic/expressions.py @@ -117,7 +117,8 @@ class EyeTarget: scale_x: float = 1.0 # squash-and-stretch horizontal multiplier scale_y: float = 1.0 # squash-and-stretch vertical multiplier wink_right: bool = False # cute asymmetric wink on bookmark or cheeky idle wink - cheek_blush: float = 0.0 # 0..1 rosy glowing cheeks below outer eye corners + squish_force: float = 0.0 # -1..+1 centrifugal push (-1 left wall, +1 right wall) + pitch_offset_y: float = 0.0 # px vertical bob from pitch / pitch-rate (bumps, hills, dive) glyph: EyeGlyph = EyeGlyph.ROUND_RECT mouth: MouthGlyph = MouthGlyph.NONE color: tuple[int, int, int] = PALETTE["engaged"] @@ -139,6 +140,10 @@ class DrivingSnapshot: a_ego: float = 0.0 # m/s^2 standstill: bool = False steering_angle_deg: float = 0.0 + yaw_rate: float = 0.0 # rad/s (+ = turning left -> centrifugal push right) + pitch_rad: float = 0.0 # rad (+ = nose up / hill climb) + pitch_rate: float = 0.0 # rad/s (bumps, crests, braking dive) + curvature: float = 0.0 # rad/m fallback for centrifugal accel set_speed_kph: float = SET_SPEED_NA is_metric: bool = False left_blinker: bool = False @@ -351,6 +356,22 @@ class RoboticMoodEngine: self.showing_speed = False + # Compute physical centrifugal force (-1 = pushed left, +1 = pushed right) & pitch bob + # Positive yaw_rate (turning left) pushes the bot toward the right wall (+1) + effective_yaw = snap.yaw_rate + if abs(effective_yaw) < 1e-4 and abs(snap.curvature) > 1e-5: + effective_yaw = snap.v_ego * snap.curvature + lat_accel = snap.v_ego * effective_yaw # m/s^2 + # Blend true lateral G with direct gyro yaw-rate so even tight low-speed turns feel lively + centrifugal_raw = (lat_accel / 4.2) + (effective_yaw / 1.4) * 0.35 + if abs(centrifugal_raw) < 0.05 and abs(snap.steering_angle_deg) > CURVE_STEER_THRESHOLD and not snap.standstill: + # Fallback for desktop previews/simulators without IMU data + centrifugal_raw = max(-1.0, min(1.0, (snap.steering_angle_deg / 90.0) * max(0.35, snap.v_ego / 20.0))) + squish_force = max(-1.0, min(1.0, centrifugal_raw)) if not snap.standstill else 0.0 + if abs(squish_force) < 0.08: + squish_force = 0.0 + pitch_offset_y = max(-22.0, min(22.0, snap.pitch_rad * 55.0 + snap.pitch_rate * 20.0)) + if alert is not None and alert_status == AlertStatus.critical: self.mood = RoboticMood.CRITICAL elif is_dm_alert: @@ -374,9 +395,9 @@ class RoboticMoodEngine: self.mood = RoboticMood.BOOST_ACCEL elif blinker_side != 0: self.mood = RoboticMood.TURN_SIGNAL - elif abs(snap.steering_angle_deg) >= SHARP_TURN_THRESHOLD and not snap.standstill: + elif (abs(squish_force) >= 0.42 or abs(snap.steering_angle_deg) >= SHARP_TURN_THRESHOLD) and not snap.standstill: self.mood = RoboticMood.SHARP_TURN - elif abs(snap.steering_angle_deg) > CURVE_STEER_THRESHOLD and not snap.standstill: + elif (abs(squish_force) >= 0.18 or abs(snap.steering_angle_deg) > CURVE_STEER_THRESHOLD) and not snap.standstill: self.mood = RoboticMood.CURVE_FOCUS elif snap.started and snap.music is not None and snap.music.is_music and alert is None: self.mood = RoboticMood.MUSIC_GROOVE @@ -406,6 +427,8 @@ class RoboticMoodEngine: bounce_y=breathe_y, scale_x=squash_x * breathe_scale, scale_y=stretch_y * (2.0 - breathe_scale), + squish_force=squish_force, + pitch_offset_y=pitch_offset_y, blind_spot_side=bsm_side, blinker_side=blinker_side, ) @@ -474,7 +497,6 @@ class RoboticMoodEngine: target.width = 114.0 target.height = 114.0 target.wink_right = self._love_wink - target.cheek_blush = 0.95 target.mouth = MouthGlyph.BIG_GRIN target.bounce_y = -abs(math.sin(t * 10.5)) * 15.0 target.show_hearts = True @@ -484,7 +506,6 @@ class RoboticMoodEngine: target.color = PALETTE["engaged"] target.width = 116.0 target.height = 100.0 - target.cheek_blush = 0.90 target.mouth = MouthGlyph.BIG_GRIN target.bounce_y = -abs(math.sin(t * 9.5)) * 16.0 @@ -494,7 +515,6 @@ class RoboticMoodEngine: target.width = 116.0 target.height = 120.0 target.gaze_y = -7.0 - target.cheek_blush = 0.70 target.mouth = MouthGlyph.BIG_GRIN target.bounce_y = math.sin(t * 18.0) * 5.0 target.show_speed_lines = True @@ -530,26 +550,28 @@ class RoboticMoodEngine: target.show_zzz = True elif self.mood == RoboticMood.SHARP_TURN: - direction = -1.0 if snap.steering_angle_deg > 0 else 1.0 + intensity = max(abs(squish_force), min(1.0, abs(snap.steering_angle_deg) / 85.0)) + push_dir = 1.0 if squish_force > 0 else (-1.0 if squish_force < 0 else (1.0 if snap.steering_angle_deg > 0 else -1.0)) + target.squish_force = push_dir * intensity target.width = 108.0 - target.height = 100.0 - target.top_lid = 0.16 - target.top_slant = 6.0 - target.gaze_x = steer_gaze + target.height = 104.0 + target.top_lid = 0.10 + 0.14 * intensity + target.top_slant = 5.0 + 7.0 * intensity + target.gaze_x = push_dir * 12.0 # squish renderer handles primary wall slide target.gaze_y = -3.0 - target.tilt_y = direction * 13.0 - target.cheek_blush = 0.55 - target.mouth = MouthGlyph.SMILE + target.tilt_y = push_dir * (8.0 + 8.0 * intensity) + target.mouth = MouthGlyph.SURPRISED if intensity >= 0.62 else MouthGlyph.SMILE elif self.mood == RoboticMood.CURVE_FOCUS: - direction = -1.0 if snap.steering_angle_deg > 0 else 1.0 + intensity = max(abs(squish_force), min(0.5, abs(snap.steering_angle_deg) / 70.0)) + push_dir = 1.0 if squish_force > 0 else (-1.0 if squish_force < 0 else (1.0 if snap.steering_angle_deg > 0 else -1.0)) + target.squish_force = push_dir * intensity target.width = 106.0 target.height = 106.0 - target.top_lid = 0.10 - target.gaze_x = steer_gaze + target.top_lid = 0.08 + target.gaze_x = push_dir * 8.0 target.gaze_y = -2.0 - target.tilt_y = direction * 7.0 - target.cheek_blush = 0.45 + target.tilt_y = push_dir * (5.0 + 6.0 * intensity) target.mouth = MouthGlyph.SMILE elif self.mood == RoboticMood.MUSIC_GROOVE: @@ -565,7 +587,6 @@ class RoboticMoodEngine: target.bounce_y = -14.0 * beat - abs(sway) * 6.0 - 8.0 target.scale_x = 1.0 + 0.11 * beat target.scale_y = 1.0 - 0.08 * beat - target.cheek_blush = 0.85 + 0.15 * beat target.mouth = MouthGlyph.BIG_GRIN if beat > 0.58: target.glyph = EyeGlyph.CRESCENT @@ -573,9 +594,8 @@ class RoboticMoodEngine: elif self.mood == RoboticMood.CRUISING_HAPPY: target.width = 106.0 target.height = 114.0 - target.cheek_blush = 0.65 target.mouth = MouthGlyph.SMILE - target.gaze_x = steer_gaze * 0.45 + self._idle_gaze_x * 0.65 + micro_drift_x + target.gaze_x = steer_gaze * 0.35 + self._idle_gaze_x * 0.65 + micro_drift_x target.gaze_y = self._idle_gaze_y * 0.65 target.tilt_y = self._idle_tilt_y * 0.75 + math.sin(t * 1.6) * 3.0 self._apply_idle_action(target, t) @@ -583,7 +603,6 @@ class RoboticMoodEngine: else: # IDLE_CURIOUS or SPEED_DISPLAY fallback target.width = 104.0 target.height = 110.0 - target.cheek_blush = 0.40 target.mouth = MouthGlyph.SMILE target.gaze_x = self._idle_gaze_x + micro_drift_x target.gaze_y = self._idle_gaze_y @@ -601,7 +620,6 @@ class RoboticMoodEngine: """Layer bubbly autonomous micro-behaviors onto normal cruising/idle states.""" if self.idle_action == IdleAction.HAPPY_SQUINT: target.glyph = EyeGlyph.CRESCENT - target.cheek_blush = 0.90 target.mouth = MouthGlyph.BIG_GRIN target.bounce_y = -abs(math.sin(t * 9.0)) * 12.0 elif self.idle_action == IdleAction.CURIOUS_LOOK: @@ -611,14 +629,12 @@ class RoboticMoodEngine: target.height = 118.0 elif self.idle_action == IdleAction.CHEEKY_WINK: target.wink_right = True - target.cheek_blush = 0.85 target.mouth = MouthGlyph.BIG_GRIN target.tilt_y = 6.0 target.bounce_y = -8.0 elif self.idle_action == IdleAction.GROOVE_BOB: target.bounce_y = math.sin(t * 7.2) * 11.0 target.tilt_y = math.sin(t * 3.6) * 8.0 - target.cheek_blush = 0.80 target.mouth = MouthGlyph.BIG_GRIN @@ -641,6 +657,24 @@ def snapshot_from_ui_state(ui_state, alert: Alert | None) -> DrivingSnapshot: v_ego_cluster = cs.vEgoCluster v_ego = v_ego_cluster if v_ego_cluster != 0.0 else cs.vEgo + # Extract pitch, pitch rate, and yaw rate from modelV2 orientation + gyroscope (104 Hz) + yaw_rate = 0.0 + pitch_rad = 0.0 + pitch_rate = 0.0 + if sm.valid.get("modelV2"): + mv2 = sm["modelV2"] + if len(mv2.orientation.y) > 0: + pitch_rad = float(mv2.orientation.y[0]) + if len(mv2.orientationRate.y) > 0 and len(mv2.orientationRate.z) > 0: + pitch_rate = float(mv2.orientationRate.y[0]) + yaw_rate = float(mv2.orientationRate.z[0]) + if sm.valid.get("gyroscope"): + gv = sm["gyroscope"].gyro.v + if len(gv) >= 3: + # Blend crisp high-rate gyro directly with model orientation rate + pitch_rate = 0.5 * pitch_rate + 0.5 * float(gv[1]) if pitch_rate != 0.0 else float(gv[1]) + yaw_rate = 0.5 * yaw_rate + 0.5 * float(gv[2]) if yaw_rate != 0.0 else float(gv[2]) + return DrivingSnapshot( started=ui_state.started, engaged=ui_state.engaged, @@ -649,6 +683,10 @@ def snapshot_from_ui_state(ui_state, alert: Alert | None) -> DrivingSnapshot: a_ego=float(cs.aEgo), standstill=bool(cs.standstill), steering_angle_deg=float(cs.steeringAngleDeg), + yaw_rate=yaw_rate, + pitch_rad=pitch_rad, + pitch_rate=pitch_rate, + curvature=float(controls.curvature) if sm.valid.get("controlsState") else 0.0, set_speed_kph=float(set_speed_kph), is_metric=bool(ui_state.is_metric), left_blinker=bool(cs.leftBlinker), diff --git a/openpilot/selfdrive/ui/sunnypilot/mici/onroad/robotic/face_renderer.py b/openpilot/selfdrive/ui/sunnypilot/mici/onroad/robotic/face_renderer.py index a4ea00700d..5bb88fc8aa 100644 --- a/openpilot/selfdrive/ui/sunnypilot/mici/onroad/robotic/face_renderer.py +++ b/openpilot/selfdrive/ui/sunnypilot/mici/onroad/robotic/face_renderer.py @@ -33,13 +33,14 @@ class ProceduralFaceRenderer: self._tilt_y = BounceFilter(0.0, 0.075, dt, bounce=3.2) self._scale_x = BounceFilter(1.0, 0.055, dt, bounce=4.5) self._scale_y = BounceFilter(1.0, 0.055, dt, bounce=4.5) + self._squish = BounceFilter(0.0, 0.075, dt, bounce=3.6) + self._pitch_y = BounceFilter(0.0, 0.075, dt, bounce=3.0) - # Crisp first-order filters for eyelids, roundness, blush, and smooth color blending + # Crisp first-order filters for eyelids, roundness, and smooth color blending self._roundness = FirstOrderFilter(0.62, 0.08, dt) self._top_lid = FirstOrderFilter(0.0, 0.032, dt) self._bottom_lid = FirstOrderFilter(0.0, 0.032, dt) self._top_slant = FirstOrderFilter(0.0, 0.065, dt) - self._cheek_blush = FirstOrderFilter(0.0, 0.12, dt) self._r = FirstOrderFilter(218.0, 0.14, dt) self._g = FirstOrderFilter(232.0, 0.14, dt) self._b = FirstOrderFilter(248.0, 0.14, dt) @@ -65,6 +66,9 @@ class ProceduralFaceRenderer: gaze_y = self._gaze_y.update(target.gaze_y) bounce_y = self._bounce_y.update(target.bounce_y) tilt_y = self._tilt_y.update(target.tilt_y) + squish = max(-1.0, min(1.0, self._squish.update(target.squish_force))) + pitch_y = self._pitch_y.update(target.pitch_offset_y) + squish_abs = abs(squish) r = max(0, min(255, int(self._r.update(target.color[0])))) g = max(0, min(255, int(self._g.update(target.color[1])))) @@ -78,6 +82,11 @@ class ProceduralFaceRenderer: eff_alpha = max(0.0, min(1.0, alpha * pulse)) core_color = rl.Color(r, g, b, int(255 * eff_alpha)) + # Subtle wall-cushion glow when centrifugal force squishes the bot strongly to one side + if squish_abs > 0.35: + wall_a = (squish_abs - 0.35) / 0.65 + self._draw_wall_squish_glow(rect, 1 if squish > 0 else -1, core_color, wall_a * eff_alpha) + # Ambient edge accents (blind spot glow, blinker chevrons, boost speed lines) bsm_a = self._bsm_alpha.update(1.0 if target.blind_spot_side != 0 else 0.0) if bsm_a > 0.02 and target.blind_spot_side != 0: @@ -90,21 +99,33 @@ class ProceduralFaceRenderer: if target.show_speed_lines: self._draw_speed_lines(rect, core_color, eff_alpha, t) - cx = rect.x + rect.width / 2.0 + gaze_x - cy = rect.y + rect.height / 2.0 - 8.0 + gaze_y + bounce_y + y_shift + # Slide the whole face toward the opposite side of the turn under centrifugal force + centrifugal_shift_x = squish * 76.0 + cx = rect.x + rect.width / 2.0 + gaze_x + centrifugal_shift_x + cy = rect.y + rect.height / 2.0 - 8.0 + gaze_y + bounce_y + pitch_y + y_shift - left_cx = cx - self.EYE_SPACING / 2.0 - right_cx = cx + self.EYE_SPACING / 2.0 + # Compress spacing between eyes as the bot gets smooshed against the side wall + spacing = self.EYE_SPACING * (1.0 - 0.24 * squish_abs) + left_cx = cx - spacing / 2.0 + right_cx = cx + spacing / 2.0 left_cy = cy - tilt_y right_cy = cy + tilt_y + # Asymmetric centrifugal wall-squish: outer pressed eye squishes narrower & taller! + left_w_mult = (1.0 - 0.36 * max(0.0, -squish)) * (1.0 - 0.14 * max(0.0, squish)) + left_h_mult = (1.0 + 0.16 * max(0.0, -squish)) * (1.0 - 0.05 * max(0.0, squish)) + right_w_mult = (1.0 - 0.36 * max(0.0, squish)) * (1.0 - 0.14 * max(0.0, -squish)) + right_h_mult = (1.0 + 0.16 * max(0.0, squish)) * (1.0 - 0.05 * max(0.0, -squish)) + # Subtle 3D perspective scaling when glancing left/right left_scale = 1.0 - max(0.0, gaze_x / 210.0) right_scale = 1.0 + min(0.0, gaze_x / 210.0) - for side_idx, (ecx, ecy, scale) in enumerate(((left_cx, left_cy, left_scale), (right_cx, right_cy, right_scale))): - ew = w * scale - eh = h * scale + eye_configs = ( + (left_cx, left_cy, w * left_scale * left_w_mult, h * left_scale * left_h_mult), + (right_cx, right_cy, w * right_scale * right_w_mult, h * right_scale * right_h_mult), + ) + for side_idx, (ecx, ecy, ew, eh) in enumerate(eye_configs): slant = top_slant if side_idx == 0 else -top_slant glyph = EyeGlyph.CRESCENT if (side_idx == 1 and target.wink_right) else target.glyph self._draw_eye(ecx, ecy, ew, eh, roundness, top_lid, bottom_lid, slant, glyph, core_color, eff_alpha, gaze_x, gaze_y, t) @@ -112,17 +133,21 @@ class ProceduralFaceRenderer: if target.mouth != MouthGlyph.NONE: self._draw_mouth(cx, cy + h * 0.72, target.mouth, core_color) - blush = self._cheek_blush.update(target.cheek_blush) - if blush > 0.03: - self._draw_cheek_blush(left_cx - w * 0.44, left_cy + h * 0.48, blush * eff_alpha) - self._draw_cheek_blush(right_cx + w * 0.44, right_cy + h * 0.48, blush * eff_alpha) - if target.show_zzz: self._draw_floating_zzz(right_cx + w * 0.58, right_cy - h * 0.35, core_color, eff_alpha, t) if target.show_hearts: self._draw_floating_mini_hearts(cx, cy - h * 0.58, core_color, eff_alpha, t) + def _draw_wall_squish_glow(self, rect: rl.Rectangle, side: int, color: rl.Color, alpha: float) -> None: + glow_w = 46 + edge = rl.Color(color.r, color.g, color.b, int(95 * alpha)) + clear = rl.Color(color.r, color.g, color.b, 0) + if side < 0: + rl.draw_rectangle_gradient_h(int(rect.x), int(rect.y), glow_w, int(rect.height), edge, clear) + else: + rl.draw_rectangle_gradient_h(int(rect.x + rect.width - glow_w), int(rect.y), glow_w, int(rect.height), clear, edge) + def _draw_bsm_edge_glow(self, rect: rl.Rectangle, side: int, alpha: float) -> None: glow_w = 56 amber = rl.Color(255, 160, 30, int(145 * alpha)) @@ -317,22 +342,33 @@ class ProceduralFaceRenderer: rl.draw_triangle(center, p2, p1, color) def _draw_heart_eye(self, cx: float, cy: float, radius: float, color: rl.Color, alpha: float, with_glow: bool = True) -> None: + """Seamless, perfectly symmetrical 48-point parametric smooth heart curve.""" if with_glow: rl.draw_circle_gradient( - rl.Vector2(cx, cy), radius * 1.35, - rl.Color(color.r, color.g, color.b, int(90 * alpha)), + rl.Vector2(cx, cy), radius * 1.4, + rl.Color(color.r, color.g, color.b, int(92 * alpha)), rl.Color(color.r, color.g, color.b, 0), ) - lobe_r = radius * 0.52 - lobe_y = cy - radius * 0.22 - rl.draw_circle(int(cx - lobe_r * 0.85), int(lobe_y), lobe_r, color) - rl.draw_circle(int(cx + lobe_r * 0.85), int(lobe_y), lobe_r, color) - rl.draw_triangle( - rl.Vector2(cx - radius * 0.96, lobe_y + lobe_r * 0.22), - rl.Vector2(cx, cy + radius * 0.92), - rl.Vector2(cx + radius * 0.96, lobe_y + lobe_r * 0.22), - color, - ) + + # Classic smooth parametric heart: + # x(t) = 16 sin^3(t), y(t) = -(13 cos(t) - 5 cos(2t) - 2 cos(3t) - cos(4t)) + # Normalized so half-width ~= radius; centered vertically around cy + scale = radius / 16.0 + n_pts = 48 + pts: list[rl.Vector2] = [] + for i in range(n_pts): + ang = (i / n_pts) * math.tau + s = math.sin(ang) + hx = 16.0 * (s * s * s) + hy = -(13.0 * math.cos(ang) - 5.0 * math.cos(2.0 * ang) - 2.0 * math.cos(3.0 * ang) - math.cos(4.0 * ang)) - 2.2 + pts.append(rl.Vector2(cx + hx * scale, cy + hy * scale)) + + center = rl.Vector2(cx, cy + radius * 0.05) + for i in range(n_pts): + p1 = pts[i] + p2 = pts[(i + 1) % n_pts] + # Parametric curve runs clockwise in screen coords (y-down), so (center, p2, p1) is CCW + rl.draw_triangle(center, p2, p1, color) def _draw_crescent_eye(self, cx: float, cy: float, w: float, h: float, color: rl.Color, alpha: float) -> None: radius = min(w, h) * 0.50 @@ -341,15 +377,6 @@ class ProceduralFaceRenderer: rl.draw_ring(rl.Vector2(cx, arc_cy), radius - 22.0, radius + 8.0, 200.0, 340.0, 28, glow_col) rl.draw_ring(rl.Vector2(cx, arc_cy), radius - 14.0, radius, 202.0, 338.0, 28, color) - def _draw_cheek_blush(self, cx: float, cy: float, alpha: float) -> None: - """Soft rosy OLED cheek blush beneath the outer corners of the eyes.""" - rl.draw_circle_gradient( - rl.Vector2(cx, cy), - 26.0, - rl.Color(255, 115, 165, int(110 * alpha)), - rl.Color(255, 115, 165, 0), - ) - def _draw_mouth(self, cx: float, cy: float, mouth: MouthGlyph, color: rl.Color) -> None: if mouth == MouthGlyph.SMILE: rl.draw_ring(rl.Vector2(cx, cy - 10.0), 17.0, 23.0, 25.0, 155.0, 20, color) diff --git a/openpilot/selfdrive/ui/sunnypilot/mici/onroad/robotic/speed_arc_renderer.py b/openpilot/selfdrive/ui/sunnypilot/mici/onroad/robotic/speed_arc_renderer.py index abed1e7f59..8a37bb8b44 100644 --- a/openpilot/selfdrive/ui/sunnypilot/mici/onroad/robotic/speed_arc_renderer.py +++ b/openpilot/selfdrive/ui/sunnypilot/mici/onroad/robotic/speed_arc_renderer.py @@ -204,13 +204,15 @@ class SpeedArcRenderer: rl.draw_circle(int(x + 10), int(y + 12), 5.5, rl.Color(sr, sg, sb, int(200 * dot_pulse * alpha))) def _draw_tiny_heart(self, cx: float, cy: float, radius: float, color: rl.Color) -> None: - lobe_r = radius * 0.55 - lobe_y = cy - radius * 0.2 - rl.draw_circle(int(cx - lobe_r * 0.8), int(lobe_y), lobe_r, color) - rl.draw_circle(int(cx + lobe_r * 0.8), int(lobe_y), lobe_r, color) - rl.draw_triangle( - rl.Vector2(cx - radius * 0.95, lobe_y + lobe_r * 0.2), - rl.Vector2(cx, cy + radius * 0.9), - rl.Vector2(cx + radius * 0.95, lobe_y + lobe_r * 0.2), - color, - ) + scale = radius / 16.0 + n_pts = 32 + pts: list[rl.Vector2] = [] + for i in range(n_pts): + ang = (i / n_pts) * math.tau + s = math.sin(ang) + hx = 16.0 * (s * s * s) + hy = -(13.0 * math.cos(ang) - 5.0 * math.cos(2.0 * ang) - 2.0 * math.cos(3.0 * ang) - math.cos(4.0 * ang)) - 2.2 + pts.append(rl.Vector2(cx + hx * scale, cy + hy * scale)) + center = rl.Vector2(cx, cy + radius * 0.05) + for i in range(n_pts): + rl.draw_triangle(center, pts[(i + 1) % n_pts], pts[i], color) diff --git a/openpilot/selfdrive/ui/sunnypilot/ui_state.py b/openpilot/selfdrive/ui/sunnypilot/ui_state.py index de081dfd10..453e5006ea 100644 --- a/openpilot/selfdrive/ui/sunnypilot/ui_state.py +++ b/openpilot/selfdrive/ui/sunnypilot/ui_state.py @@ -36,7 +36,8 @@ class UIStateSP: self.is_sp_release: bool = self.params.get_bool("IsReleaseSpBranch") self.sm_services_ext = [ "modelManagerSP", "selfdriveStateSP", "longitudinalPlanSP", "backupManagerSP", - "lateralTorqueParameters", "carStateSP", "liveMapDataSP", "carParamsSP", "lateralDelay", "modelDataV2SP" + "lateralTorqueParameters", "carStateSP", "liveMapDataSP", "carParamsSP", "lateralDelay", "modelDataV2SP", + "gyroscope", ] self.sunnylink_state = SunnylinkState()