From 8f3e77397724cdd53b9314ba66ad321b4d0b8f35 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Thu, 27 Feb 2025 18:12:55 -0600 Subject: [PATCH] actuators: rename steer to torque (#34724) * bump * temp fix * fix * forgot these --- opendbc_repo | 2 +- selfdrive/controls/controlsd.py | 13 +++++++------ selfdrive/debug/max_lat_accel.py | 2 +- selfdrive/locationd/torqued.py | 2 +- selfdrive/selfdrived/events.py | 2 +- tools/joystick/joystickd.py | 4 ++-- tools/replay/ui.py | 2 +- tools/tuning/measure_steering_accuracy.py | 4 ++-- 8 files changed, 16 insertions(+), 15 deletions(-) diff --git a/opendbc_repo b/opendbc_repo index 706567945a..bdcb515ffc 160000 --- a/opendbc_repo +++ b/opendbc_repo @@ -1 +1 @@ -Subproject commit 706567945a80e0baff18592585d4c1a29e1feea1 +Subproject commit bdcb515ffced5137569bd8f5536829c91356f02c diff --git a/selfdrive/controls/controlsd.py b/selfdrive/controls/controlsd.py index c45a3e92bd..fb7dd3944c 100755 --- a/selfdrive/controls/controlsd.py +++ b/selfdrive/controls/controlsd.py @@ -19,13 +19,13 @@ from openpilot.selfdrive.controls.lib.latcontrol_torque import LatControlTorque from openpilot.selfdrive.controls.lib.longcontrol import LongControl from openpilot.selfdrive.locationd.helpers import PoseCalibrator, Pose - State = log.SelfdriveState.OpenpilotState LaneChangeState = log.LaneChangeState LaneChangeDirection = log.LaneChangeDirection ACTUATOR_FIELDS = tuple(car.CarControl.Actuators.schema.fields.keys()) + class Controls: def __init__(self) -> None: self.params = Params() @@ -44,7 +44,7 @@ class Controls: self.desired_curvature = 0.0 self.pose_calibrator = PoseCalibrator() - self.calibrated_pose: Pose|None = None + self.calibrated_pose: Pose | None = None self.LoC = LongControl(self.CP) self.VM = VehicleModel(self.CP) @@ -112,9 +112,9 @@ class Controls: self.desired_curvature = clip_curvature(CS.vEgo, self.desired_curvature, model_v2.action.desiredCurvature) actuators.curvature = float(self.desired_curvature) steer, steeringAngleDeg, lac_log = self.LaC.update(CC.latActive, CS, self.VM, lp, - self.steer_limited, self.desired_curvature, - self.calibrated_pose) # TODO what if not available - actuators.steer = float(steer) + self.steer_limited, self.desired_curvature, + self.calibrated_pose) # TODO what if not available + actuators.torque = float(steer) actuators.steeringAngleDeg = float(steeringAngleDeg) # Ensure no NaNs/Infs for p in ACTUATOR_FIELDS: @@ -164,7 +164,7 @@ class Controls: self.steer_limited = abs(CC.actuators.steeringAngleDeg - CO.actuatorsOutput.steeringAngleDeg) > \ STEER_ANGLE_SATURATION_THRESHOLD else: - self.steer_limited = abs(CC.actuators.steer - CO.actuatorsOutput.steer) > 1e-2 + self.steer_limited = abs(CC.actuators.torque - CO.actuatorsOutput.torque) > 1e-2 # TODO: both controlsState and carControl valids should be set by # sm.all_checks(), but this creates a circular dependency @@ -212,6 +212,7 @@ class Controls: self.publish(CC, lac_log) rk.monitor_time() + def main(): config_realtime_process(4, Priority.CTRL_HIGH) controls = Controls() diff --git a/selfdrive/debug/max_lat_accel.py b/selfdrive/debug/max_lat_accel.py index 4a4d10d816..2369d99d86 100755 --- a/selfdrive/debug/max_lat_accel.py +++ b/selfdrive/debug/max_lat_accel.py @@ -48,7 +48,7 @@ def find_events(lr: LogReader, qlog: bool = False) -> list[Event]: elif msg.which() == 'carOutput': # if we test with driver torque safety, max torque can be slightly noisy - requesting_max = requesting_max + 1 if abs(msg.carOutput.actuatorsOutput.steer) > 0.95 else 0 + requesting_max = requesting_max + 1 if abs(msg.carOutput.actuatorsOutput.torque) > 0.95 else 0 elif msg.which() == 'carState': steering_unpressed = steering_unpressed + 1 if not msg.carState.steeringPressed else 0 diff --git a/selfdrive/locationd/torqued.py b/selfdrive/locationd/torqued.py index bdbb2e62b4..590b6cc6f7 100755 --- a/selfdrive/locationd/torqued.py +++ b/selfdrive/locationd/torqued.py @@ -167,7 +167,7 @@ class TorqueEstimator(ParameterEstimator): self.raw_points["lat_active"].append(msg.latActive) elif which == "carOutput": self.raw_points["carOutput_t"].append(t + self.lag) - self.raw_points["steer_torque"].append(-msg.actuatorsOutput.steer) + self.raw_points["steer_torque"].append(-msg.actuatorsOutput.torque) elif which == "carState": self.raw_points["carState_t"].append(t + self.lag) # TODO: check if high aEgo affects resulting lateral accel diff --git a/selfdrive/selfdrived/events.py b/selfdrive/selfdrived/events.py index 9da844bce4..06c87f849c 100755 --- a/selfdrive/selfdrived/events.py +++ b/selfdrive/selfdrived/events.py @@ -321,7 +321,7 @@ def wrong_car_mode_alert(CP: car.CarParams, CS: car.CarState, sm: messaging.SubM def joystick_alert(CP: car.CarParams, CS: car.CarState, sm: messaging.SubMaster, metric: bool, soft_disable_time: int, personality) -> Alert: gb = sm['carControl'].actuators.accel / 4. - steer = sm['carControl'].actuators.steer + steer = sm['carControl'].actuators.torque vals = f"Gas: {round(gb * 100.)}%, Steer: {round(steer * 100.)}%" return NormalPermanentAlert("Joystick Mode", vals) diff --git a/tools/joystick/joystickd.py b/tools/joystick/joystickd.py index 2f44618538..b775f18f70 100755 --- a/tools/joystick/joystickd.py +++ b/tools/joystick/joystickd.py @@ -53,8 +53,8 @@ def joystickd_thread(): max_curvature = MAX_LAT_ACCEL / max(sm['carState'].vEgo ** 2, 5) max_angle = math.degrees(VM.get_steer_from_curvature(max_curvature, sm['carState'].vEgo, sm['liveParameters'].roll)) - actuators.steer = float(np.clip(joystick_axes[1], -1, 1)) - actuators.steeringAngleDeg, actuators.curvature = actuators.steer * max_angle, actuators.steer * -max_curvature + actuators.torque = float(np.clip(joystick_axes[1], -1, 1)) + actuators.steeringAngleDeg, actuators.curvature = actuators.torque * max_angle, actuators.torque * -max_curvature pm.send('carControl', cc_msg) diff --git a/tools/replay/ui.py b/tools/replay/ui.py index 03f3a0c37c..34e22ec595 100755 --- a/tools/replay/ui.py +++ b/tools/replay/ui.py @@ -154,7 +154,7 @@ def ui_thread(addr): # TODO gas is deprecated plot_arr[-1, name_to_arr_idx['computer_gas']] = clip(sm['carControl'].actuators.accel/4.0, 0.0, 1.0) plot_arr[-1, name_to_arr_idx['user_brake']] = sm['carState'].brake - plot_arr[-1, name_to_arr_idx['steer_torque']] = sm['carControl'].actuators.steer * ANGLE_SCALE + plot_arr[-1, name_to_arr_idx['steer_torque']] = sm['carControl'].actuators.torque * ANGLE_SCALE # TODO brake is deprecated plot_arr[-1, name_to_arr_idx['computer_brake']] = clip(-sm['carControl'].actuators.accel/4.0, 0.0, 1.0) plot_arr[-1, name_to_arr_idx['v_ego']] = sm['carState'].vEgo diff --git a/tools/tuning/measure_steering_accuracy.py b/tools/tuning/measure_steering_accuracy.py index 0b8916343e..5294ffcc49 100755 --- a/tools/tuning/measure_steering_accuracy.py +++ b/tools/tuning/measure_steering_accuracy.py @@ -47,9 +47,9 @@ class SteeringAccuracyTool: v_ego = sm['carState'].vEgo active = sm['controlsState'].active - steer = sm['carOutput'].actuatorsOutput.steer + steer = sm['carOutput'].actuatorsOutput.torque standstill = sm['carState'].standstill - steer_limited = abs(sm['carControl'].actuators.steer - sm['carControl'].actuatorsOutput.steer) > 1e-2 + steer_limited = abs(sm['carControl'].actuators.torque - sm['carControl'].actuatorsOutput.torque) > 1e-2 overriding = sm['carState'].steeringPressed changing_lanes = sm['modelV2'].meta.laneChangeState != 0 model_points = sm['modelV2'].position.y