Skip to content

More elegant return type and tuples #9

@rikba

Description

@rikba

Somehow, for the radar return type you can have a very elegant way of selecting the Radar object among the result tuple. See https://github.com/ethz-asl/mav_sensors/blob/master/src/impl/radar/xwr18xx_mmw_demo.cpp#L96-L99

  std::get<Radar>(measurement).cfar_detections.resize(num_detected_obj);
  std::get<Radar>(measurement).unix_stamp_ns =
      std::chrono::duration_cast<std::chrono::nanoseconds>(now.time_since_epoch()).count();
  std::get<Radar>(measurement).hardware_stamp = time_cpu_cycles;

However, the same does not seem to work for Temperature and Pressure. Would be nice to do for example

    auto measurements = bmp390.read();
    LOG(I, std::get<FluidPressure>(measurements).has_value(),
        "Pressure: " << std::get<FluidPressure>(measurements).value() << " Pa");

instead of selecting by index, as this can lead to wrong indexing, see https://github.com/ethz-asl/mav_sensors/blob/master/src/main.cpp#L24C1-L35

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions