mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-06-28 01:52:06 +08:00
automatically detect available camera streams (#27640)
* remove WideCameraOnly * check in set_initial_state * no block * remove try block * apply reviews old-commit-hash: 4ae0378f639826df5cc1518574842b61b118f371
This commit is contained in:
@@ -186,7 +186,6 @@ std::unordered_map<std::string, uint32_t> keys = {
|
||||
{"UpdaterNewReleaseNotes", CLEAR_ON_MANAGER_START},
|
||||
{"Version", PERSISTENT},
|
||||
{"VisionRadarToggle", PERSISTENT},
|
||||
{"WideCameraOnly", PERSISTENT},
|
||||
{"ApiCache_Device", PERSISTENT},
|
||||
{"ApiCache_DriveStats", PERSISTENT},
|
||||
{"ApiCache_NavDestinations", PERSISTENT},
|
||||
|
||||
@@ -9,6 +9,7 @@ from common.realtime import sec_since_boot, config_realtime_process, Priority, R
|
||||
from common.profiler import Profiler
|
||||
from common.params import Params, put_nonblocking
|
||||
import cereal.messaging as messaging
|
||||
from cereal.visionipc import VisionIpcClient, VisionStreamType
|
||||
from common.conversions import Conversions as CV
|
||||
from panda import ALTERNATIVE_EXPERIENCE
|
||||
from system.swaglog import cloudlog
|
||||
@@ -82,8 +83,6 @@ class Controls:
|
||||
ignore = ['testJoystick']
|
||||
if SIMULATION:
|
||||
ignore += ['driverCameraState', 'managerState']
|
||||
if self.params.get_bool('WideCameraOnly'):
|
||||
ignore += ['roadCameraState']
|
||||
self.sm = messaging.SubMaster(['deviceState', 'pandaStates', 'peripheralState', 'modelV2', 'liveCalibration',
|
||||
'driverMonitoringState', 'longitudinalPlan', 'lateralPlan', 'liveLocationKalman',
|
||||
'managerState', 'liveParameters', 'radarState', 'liveTorqueParameters', 'testJoystick'] + self.camera_packets,
|
||||
@@ -438,6 +437,10 @@ class Controls:
|
||||
all_valid = CS.canValid and self.sm.all_checks()
|
||||
timed_out = self.sm.frame * DT_CTRL > (6. if REPLAY else 3.5)
|
||||
if all_valid or timed_out or SIMULATION:
|
||||
available_streams = VisionIpcClient.available_streams("camerad", block=False)
|
||||
if VisionStreamType.VISION_STREAM_ROAD not in available_streams:
|
||||
self.sm.ignore_alive.append('roadCameraState')
|
||||
|
||||
if not self.read_only:
|
||||
self.CI.init(self.CP, self.can_sock, self.pm.sock['sendcan'])
|
||||
|
||||
|
||||
@@ -179,9 +179,6 @@ int main(int argc, char **argv) {
|
||||
assert(ret == 0);
|
||||
}
|
||||
|
||||
bool main_wide_camera = Params().getBool("WideCameraOnly");
|
||||
bool use_extra_client = !main_wide_camera; // set for single camera mode
|
||||
|
||||
// cl init
|
||||
cl_device_id device_id = cl_get_device_id(CL_DEVICE_TYPE_DEFAULT);
|
||||
cl_context context = CL_CHECK_ERR(clCreateContext(NULL, 1, &device_id, NULL, NULL, &err));
|
||||
@@ -191,6 +188,18 @@ int main(int argc, char **argv) {
|
||||
model_init(&model, device_id, context);
|
||||
LOGW("models loaded, modeld starting");
|
||||
|
||||
bool main_wide_camera = false;
|
||||
while (!do_exit) {
|
||||
auto streams = VisionIpcClient::getAvailableStreams("camerad", false);
|
||||
if (!streams.empty()) {
|
||||
main_wide_camera = streams.count(VISION_STREAM_ROAD) == 0;
|
||||
break;
|
||||
}
|
||||
|
||||
util::sleep_for(100);
|
||||
}
|
||||
|
||||
bool use_extra_client = !main_wide_camera; // set for single camera mode
|
||||
VisionIpcClient vipc_client_main = VisionIpcClient("camerad", main_wide_camera ? VISION_STREAM_WIDE_ROAD : VISION_STREAM_ROAD, true, device_id, context);
|
||||
VisionIpcClient vipc_client_extra = VisionIpcClient("camerad", VISION_STREAM_WIDE_ROAD, false, device_id, context);
|
||||
|
||||
|
||||
@@ -459,7 +459,6 @@ def setup_env(CP=None, cfg=None, controlsState=None, lr=None, fingerprint=None,
|
||||
params.put_bool("OpenpilotEnabledToggle", True)
|
||||
params.put_bool("Passive", False)
|
||||
params.put_bool("DisengageOnAccelerator", True)
|
||||
params.put_bool("WideCameraOnly", False)
|
||||
params.put_bool("DisableLogging", False)
|
||||
|
||||
os.environ["NO_RADAR_SLEEP"] = "1"
|
||||
|
||||
+11
-18
@@ -254,7 +254,6 @@ class CarlaBridge:
|
||||
msg.liveCalibration.validBlocks = 20
|
||||
msg.liveCalibration.rpyCalib = [0.0, 0.0, 0.0]
|
||||
self.params.put("CalibrationParams", msg.to_bytes())
|
||||
self.params.put_bool("WideCameraOnly", not arguments.dual_camera)
|
||||
|
||||
self._args = arguments
|
||||
self._carla_objects = []
|
||||
@@ -545,23 +544,17 @@ if __name__ == "__main__":
|
||||
q: Any = Queue()
|
||||
args = parse_args()
|
||||
|
||||
try:
|
||||
carla_bridge = CarlaBridge(args)
|
||||
p = carla_bridge.run(q)
|
||||
carla_bridge = CarlaBridge(args)
|
||||
p = carla_bridge.run(q)
|
||||
|
||||
if args.joystick:
|
||||
# start input poll for joystick
|
||||
from tools.sim.lib.manual_ctrl import wheel_poll_thread
|
||||
if args.joystick:
|
||||
# start input poll for joystick
|
||||
from tools.sim.lib.manual_ctrl import wheel_poll_thread
|
||||
|
||||
wheel_poll_thread(q)
|
||||
else:
|
||||
# start input poll for keyboard
|
||||
from tools.sim.lib.keyboard_ctrl import keyboard_poll_thread
|
||||
wheel_poll_thread(q)
|
||||
else:
|
||||
# start input poll for keyboard
|
||||
from tools.sim.lib.keyboard_ctrl import keyboard_poll_thread
|
||||
|
||||
keyboard_poll_thread(q)
|
||||
p.join()
|
||||
|
||||
finally:
|
||||
# Try cleaning up the wide camera param
|
||||
# in case users want to use replay after
|
||||
Params().remove("WideCameraOnly")
|
||||
keyboard_poll_thread(q)
|
||||
p.join()
|
||||
|
||||
Reference in New Issue
Block a user