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>pull/20737/head
parent
1786d04239
commit
4866a39244
2
cereal
2
cereal
|
@ -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;
|
||||
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 frame = msg.get(frame_pkt).as<capnp::DynamicStruct>();
|
||||
camera.buf.camera_bufs_metadata[buf_idx] = {
|
||||
.frame_id = frame.get("frameId").as<uint32_t>(),
|
||||
.timestamp_eof = frame.get("timestampEof").as<uint64_t>(),
|
||||
.frame_length = frame.get("frameLength").as<unsigned>(),
|
||||
.integ_lines = frame.get("integLines").as<unsigned>(),
|
||||
.global_gain = frame.get("globalGain").as<unsigned>(),
|
||||
};
|
||||
|
||||
auto msg = static_cast<capnp::DynamicStruct::Reader>(sm[frame_pkt]);
|
||||
auto frame = msg.get(frame_pkt).as<capnp::DynamicStruct>();
|
||||
camera.buf.camera_bufs_metadata[buf_idx] = {
|
||||
.frame_id = frame.get("frameId").as<uint32_t>(),
|
||||
.timestamp_eof = frame.get("timestampEof").as<uint64_t>(),
|
||||
.frame_length = frame.get("frameLength").as<unsigned>(),
|
||||
.integ_lines = frame.get("integLines").as<unsigned>(),
|
||||
.global_gain = frame.get("globalGain").as<unsigned>(),
|
||||
};
|
||||
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_command_queue q = camera.buf.camera_bufs[buf_idx].copy_q;
|
||||
cl_mem yuv_cl = camera.buf.camera_bufs[buf_idx].buf_cl;
|
||||
|
||||
auto image = frame.get("image").as<capnp::Data>();
|
||||
clEnqueueWriteBuffer(q, yuv_cl, CL_TRUE, 0, image.size(), image.begin(), 0, NULL, NULL);
|
||||
camera.buf.queue(buf_idx);
|
||||
buf_idx = (buf_idx + 1) % FRAME_BUF_COUNT;
|
||||
auto image = frame.get("image").as<capnp::Data>();
|
||||
clEnqueueWriteBuffer(q, yuv_cl, CL_TRUE, 0, image.size(), image.begin(), 0, NULL, NULL);
|
||||
camera.buf.queue(buf_idx);
|
||||
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) {
|
||||
if (sm->update(0) > 0) {
|
||||
sm->update(0);
|
||||
if(sm->updated("sensorEvents")){
|
||||
for (auto event : (*sm)["sensorEvents"].getSensorEvents()) {
|
||||
if (event.which() == cereal::SensorEventData::ACCELERATION) {
|
||||
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();
|
||||
|
||||
while (!do_exit) {
|
||||
if (sm.update(100) > 0){
|
||||
|
||||
sm.update(100);
|
||||
if(sm.updated("liveCalibration")){
|
||||
auto extrinsic_matrix = sm["liveCalibration"].getLiveCalibration().getExtrinsicMatrix();
|
||||
Eigen::Matrix<float, 3, 4> extrinsic_matrix_eigen;
|
||||
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;
|
||||
transform_lock.unlock();
|
||||
|
||||
if (sm.update(0) > 0) {
|
||||
// TODO: path planner timeout?
|
||||
desire = ((int)sm["lateralPlan"].getLateralPlan().getDesire());
|
||||
frame_id = sm["roadCameraState"].getRoadCameraState().getFrameId();
|
||||
}
|
||||
// TODO: path planner timeout?
|
||||
sm.update(0);
|
||||
desire = ((int)sm["lateralPlan"].getLateralPlan().getDesire());
|
||||
frame_id = sm["roadCameraState"].getRoadCameraState().getFrameId();
|
||||
|
||||
if (run_model_this_iter) {
|
||||
run_count++;
|
||||
|
|
|
@ -197,7 +197,8 @@ void sensor_loop() {
|
|||
}
|
||||
|
||||
// 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();
|
||||
if (low_power_mode != offroad) {
|
||||
for (auto &s : sensors) {
|
||||
|
|
Loading…
Reference in New Issue