cereal: SubMaster refactor, update is now void (#20730)

* cereal: SubMaster refactor, update is now void

* bump cereal

* mistake

* update void

* checks

* semicolon

* Update selfdrive/camerad/cameras/camera_frame_stream.cc

Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com>

* check sensorEvent

* update cereal

Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com>
old-commit-hash: 4866a39244
commatwo_master
iejMac 4 years ago committed by GitHub
parent 3e4eb2e343
commit 4abd8988e4
  1. 2
      cereal
  2. 39
      selfdrive/camerad/cameras/camera_frame_stream.cc
  3. 3
      selfdrive/camerad/cameras/camera_qcom.cc
  4. 13
      selfdrive/modeld/modeld.cc
  5. 3
      selfdrive/sensord/sensors_qcom.cc

@ -1 +1 @@
Subproject commit 9c56c531c6b1c6dbf6d22377fbb2eb75309d1e91 Subproject commit 8e5eb3ba4db9975e3370f3e4f5e60c0e7b73d078

@ -49,25 +49,26 @@ void run_frame_stream(CameraState &camera, const char* frame_pkt) {
size_t buf_idx = 0; size_t buf_idx = 0;
while (!do_exit) { while (!do_exit) {
if (sm.update(1000) == 0) continue; sm.update(1000);
if(sm.updated(frame_pkt)){
auto msg = static_cast<capnp::DynamicStruct::Reader>(sm[frame_pkt]); auto msg = static_cast<capnp::DynamicStruct::Reader>(sm[frame_pkt]);
auto frame = msg.get(frame_pkt).as<capnp::DynamicStruct>(); auto frame = msg.get(frame_pkt).as<capnp::DynamicStruct>();
camera.buf.camera_bufs_metadata[buf_idx] = { camera.buf.camera_bufs_metadata[buf_idx] = {
.frame_id = frame.get("frameId").as<uint32_t>(), .frame_id = frame.get("frameId").as<uint32_t>(),
.timestamp_eof = frame.get("timestampEof").as<uint64_t>(), .timestamp_eof = frame.get("timestampEof").as<uint64_t>(),
.frame_length = frame.get("frameLength").as<unsigned>(), .frame_length = frame.get("frameLength").as<unsigned>(),
.integ_lines = frame.get("integLines").as<unsigned>(), .integ_lines = frame.get("integLines").as<unsigned>(),
.global_gain = frame.get("globalGain").as<unsigned>(), .global_gain = frame.get("globalGain").as<unsigned>(),
}; };
cl_command_queue q = camera.buf.camera_bufs[buf_idx].copy_q; cl_command_queue q = camera.buf.camera_bufs[buf_idx].copy_q;
cl_mem yuv_cl = camera.buf.camera_bufs[buf_idx].buf_cl; cl_mem yuv_cl = camera.buf.camera_bufs[buf_idx].buf_cl;
auto image = frame.get("image").as<capnp::Data>(); auto image = frame.get("image").as<capnp::Data>();
clEnqueueWriteBuffer(q, yuv_cl, CL_TRUE, 0, image.size(), image.begin(), 0, NULL, NULL); clEnqueueWriteBuffer(q, yuv_cl, CL_TRUE, 0, image.size(), image.begin(), 0, NULL, NULL);
camera.buf.queue(buf_idx); camera.buf.queue(buf_idx);
buf_idx = (buf_idx + 1) % FRAME_BUF_COUNT; buf_idx = (buf_idx + 1) % FRAME_BUF_COUNT;
}
} }
} }

@ -850,7 +850,8 @@ static void parse_autofocus(CameraState *s, uint8_t *d) {
} }
static std::optional<float> get_accel_z(SubMaster *sm) { static std::optional<float> get_accel_z(SubMaster *sm) {
if (sm->update(0) > 0) { sm->update(0);
if(sm->updated("sensorEvents")){
for (auto event : (*sm)["sensorEvents"].getSensorEvents()) { for (auto event : (*sm)["sensorEvents"].getSensorEvents()) {
if (event.which() == cereal::SensorEventData::ACCELERATION) { if (event.which() == cereal::SensorEventData::ACCELERATION) {
if (auto v = event.getAcceleration().getV(); v.size() >= 3) if (auto v = event.getAcceleration().getV(); v.size() >= 3)

@ -40,8 +40,8 @@ void calibration_thread(bool wide_camera) {
const mat3 yuv_transform = get_model_yuv_transform(); const mat3 yuv_transform = get_model_yuv_transform();
while (!do_exit) { while (!do_exit) {
if (sm.update(100) > 0){ sm.update(100);
if(sm.updated("liveCalibration")){
auto extrinsic_matrix = sm["liveCalibration"].getLiveCalibration().getExtrinsicMatrix(); auto extrinsic_matrix = sm["liveCalibration"].getLiveCalibration().getExtrinsicMatrix();
Eigen::Matrix<float, 3, 4> extrinsic_matrix_eigen; Eigen::Matrix<float, 3, 4> extrinsic_matrix_eigen;
for (int i = 0; i < 4*3; i++){ for (int i = 0; i < 4*3; i++){
@ -90,11 +90,10 @@ void run_model(ModelState &model, VisionIpcClient &vipc_client) {
const bool run_model_this_iter = live_calib_seen; const bool run_model_this_iter = live_calib_seen;
transform_lock.unlock(); transform_lock.unlock();
if (sm.update(0) > 0) { // TODO: path planner timeout?
// TODO: path planner timeout? sm.update(0);
desire = ((int)sm["lateralPlan"].getLateralPlan().getDesire()); desire = ((int)sm["lateralPlan"].getLateralPlan().getDesire());
frame_id = sm["roadCameraState"].getRoadCameraState().getFrameId(); frame_id = sm["roadCameraState"].getRoadCameraState().getFrameId();
}
if (run_model_this_iter) { if (run_model_this_iter) {
run_count++; run_count++;

@ -197,7 +197,8 @@ void sensor_loop() {
} }
// Check whether to go into low power mode at 5Hz // Check whether to go into low power mode at 5Hz
if (frame % 20 == 0 && sm.update(0) > 0) { if (frame % 20 == 0) {
sm.update(0);
bool offroad = !sm["deviceState"].getDeviceState().getStarted(); bool offroad = !sm["deviceState"].getDeviceState().getStarted();
if (low_power_mode != offroad) { if (low_power_mode != offroad) {
for (auto &s : sensors) { for (auto &s : sensors) {

Loading…
Cancel
Save