From 0f133c61a161bac178d2aeb3bcb255c01c642f9c Mon Sep 17 00:00:00 2001 From: Kevin Roscom Date: Wed, 23 Feb 2022 00:22:40 -0600 Subject: [PATCH] cleanup and test actuators --- launch_x86.sh | 7 +++++++ opendbc | 2 +- panda | 2 +- selfdrive/camerad/cameras/camera_webcam.cc | 15 +++++++++------ selfdrive/car/ocelot/carcontroller.py | 11 +++-------- selfdrive/car/ocelot/ocelotcan.py | 16 ++++++++-------- 6 files changed, 29 insertions(+), 24 deletions(-) create mode 100755 launch_x86.sh diff --git a/launch_x86.sh b/launch_x86.sh new file mode 100755 index 00000000..8668a426 --- /dev/null +++ b/launch_x86.sh @@ -0,0 +1,7 @@ +#! /bin/bash + +export USE_WEBCAM=1 +export ROADCAM_ID=0 +export DRIVERCAM_ID=2 + +./launch_openpilot.sh diff --git a/opendbc b/opendbc index b1d3a963..7994ffa7 160000 --- a/opendbc +++ b/opendbc @@ -1 +1 @@ -Subproject commit b1d3a96355d830c21d7106ea8465ea2957badbbd +Subproject commit 7994ffa766f5367dc39e9474a59b2b9abe3d3f64 diff --git a/panda b/panda index b8ce1c96..4522320f 160000 --- a/panda +++ b/panda @@ -1 +1 @@ -Subproject commit b8ce1c9686da19cac3094e7d754dc6a642b87cef +Subproject commit 4522320fdc6ac5990aae191082f1e1f132778113 diff --git a/selfdrive/camerad/cameras/camera_webcam.cc b/selfdrive/camerad/cameras/camera_webcam.cc index f4204146..7e900774 100644 --- a/selfdrive/camerad/cameras/camera_webcam.cc +++ b/selfdrive/camerad/cameras/camera_webcam.cc @@ -18,8 +18,8 @@ #include "selfdrive/common/util.h" // id of the video capturing device -const int ROAD_CAMERA_ID = getenv("ROADCAM_ID") ? atoi(getenv("ROADCAM_ID")) : 1; -const int DRIVER_CAMERA_ID = getenv("DRIVERCAM_ID") ? atoi(getenv("DRIVERCAM_ID")) : 2; +const int ROAD_CAMERA_ID = 0; //getenv("ROADCAM_ID") ? atoi(getenv("ROADCAM_ID")) : 1; +const int DRIVER_CAMERA_ID = 2; //getenv("DRIVERCAM_ID") ? atoi(getenv("DRIVERCAM_ID")) : 2; #define FRAME_WIDTH 1164 #define FRAME_HEIGHT 874 @@ -97,16 +97,19 @@ static void road_camera_thread(CameraState *s) { set_thread_name("webcam_road_camera_thread"); cv::VideoCapture cap_road(ROAD_CAMERA_ID, cv::CAP_V4L2); // road - cap_road.set(cv::CAP_PROP_FRAME_WIDTH, 853); - cap_road.set(cv::CAP_PROP_FRAME_HEIGHT, 480); + cap_road.set(cv::CAP_PROP_FRAME_WIDTH, 1280); + cap_road.set(cv::CAP_PROP_FRAME_HEIGHT, 800); cap_road.set(cv::CAP_PROP_FPS, s->fps); cap_road.set(cv::CAP_PROP_AUTOFOCUS, 0); // off cap_road.set(cv::CAP_PROP_FOCUS, 0); // 0 - 255? // cv::Rect roi_rear(160, 0, 960, 720); // transforms calculation see tools/webcam/warp_vis.py - float ts[9] = {1.50330396, 0.0, -59.40969163, - 0.0, 1.50330396, 76.20704846, + // float ts[9] = {1.50330396, 0.0, -59.40969163, + // 0.0, 1.50330396, 76.20704846, + // 0.0, 0.0, 1.0}; + float ts[9] = {0.99560759, 0.0, -55.18885977, + 0.0, 0.99560759, 38.75696264, 0.0, 0.0, 1.0}; // if camera upside down: // float ts[9] = {-1.50330396, 0.0, 1223.4, diff --git a/selfdrive/car/ocelot/carcontroller.py b/selfdrive/car/ocelot/carcontroller.py index e297bc19..5aaf375c 100644 --- a/selfdrive/car/ocelot/carcontroller.py +++ b/selfdrive/car/ocelot/carcontroller.py @@ -1,8 +1,8 @@ from cereal import car from common.numpy_fast import clip -from selfdrive.car import apply_toyota_steer_torque_limits, make_can_msg +from selfdrive.car import apply_toyota_steer_torque_limits from selfdrive.car.ocelot.ocelotcan import create_steer_command, create_gas_command, create_brake_cmd -from selfdrive.car.ocelot.values import CAR, SteerLimitParams +from selfdrive.car.ocelot.values import SteerLimitParams from opendbc.can.packer import CANPacker VisualAlert = car.CarControl.HUDControl.VisualAlert @@ -103,7 +103,7 @@ class CarController(): # This prevents unexpected pedal range rescaling can_sends.append(create_gas_command(self.packer, apply_gas, frame//2)) - can_sends.append(create_brake_cmd(self.packer, enabled, actuators.brake, frame//2)) + can_sends.append(create_brake_cmd(self.packer, enabled, actuators.brake, frame)) # ui mesg is at 100Hz but we send asap if: # - there is something to display @@ -111,14 +111,9 @@ class CarController(): fcw_alert = hud_alert == VisualAlert.fcw steer_alert = hud_alert == VisualAlert.steerRequired - send_ui = False if ((fcw_alert or steer_alert) and not self.alert_active) or \ (not (fcw_alert or steer_alert) and self.alert_active): - send_ui = True self.alert_active = not self.alert_active - elif pcm_cancel_cmd: - # forcing the pcm to disengage causes a bad fault sound so play a good sound instead - send_ui = True # #*** static msgs *** diff --git a/selfdrive/car/ocelot/ocelotcan.py b/selfdrive/car/ocelot/ocelotcan.py index deed8547..7d9a89ed 100644 --- a/selfdrive/car/ocelot/ocelotcan.py +++ b/selfdrive/car/ocelot/ocelotcan.py @@ -6,7 +6,7 @@ def create_steer_command(packer, steer, mode, raw_cnt): "REQUESTED_STEER_TORQUE": steer, "COUNTER": raw_cnt, } - return packer.make_can_msg("OCELOT_STEERING_COMMAND", 0, values) + return packer.make_can_msg("OCELOT_STEERING_COMMAND", 2, values) def create_gas_command(packer, gas_amount, idx): # Common gas pedal msg generator @@ -18,16 +18,16 @@ def create_gas_command(packer, gas_amount, idx): } if enable: - values["GAS_COMMAND"] = gas_amount * 255. - values["GAS_COMMAND2"] = gas_amount * 255. + values["GAS_COMMAND"] = gas_amount * 2500 + values["GAS_COMMAND2"] = gas_amount * 1250 - return packer.make_can_msg("PEDAL_GAS_COMMAND", 0, values) + return packer.make_can_msg("PEDAL_GAS_COMMAND", 2, values) def create_brake_cmd(packer, enabled, brake, raw_cnt): values = { - "BRAKE_POSITION_COMMAND" : 0, - "BRAKE_RELATIVE_COMMAND": brake * 252, - "BRAKE_MODE": enabled, + "BRAKE_POSITION_COMMAND" : brake * 47, + "BRAKE_RELATIVE_COMMAND": 0, + "BRAKE_MODE": 2 if enabled else 0, "COUNTER" : raw_cnt, } - return packer.make_can_msg("OCELOT_BRAKE_COMMAND", 0, values) \ No newline at end of file + return packer.make_can_msg("OCELOT_BRAKE_COMMAND", 2, values) \ No newline at end of file