Cepton
Cepton

Future-proof Cepton lidar applications with SDK v2

by - created

tl;dr Please use Cepton SDK v2 to write your lidar applications even if you are working with Vista-P series products.

Since the very beginning of the company's history, Cepton has been releasing lidar sensors every few months. Over the last 4-5 years, we have released HR80 series (5T, W, 4T), Sora series, Vista-P series (860, P60, P90, P61, P91), and now Vista-X series (X90) and Nova. It has been our goal from day one that the software should work across all lidar sensors without API changes. With this goal in mind, we released Cepton SDK v1 in 2017. The SDKv1 supports all Cepton sensors up to Vista-P series.

In 2020, to support Vista-X series sensors, we have released an all new SDKv2 (SDKv2 will be available for download at developer.cepton.com). SDKv2 is a new SDK with a modular design to facilitate easier integration with all the 3rd party frameworks. Another goal is to be free of legacy proprietary code so that we can open source the SDK in the near future. Although different in API interfaces, SDKv2 has full support for all our old sensor products through a LegacyTranslation mode. We still fully support SDKv1 for our earlier generations of sensors, but we ask all new developers to use SDKv2 to be future proofed and better supported by us.

Comparison between SDKv2 and SDKv1 features:

SDKv2 SDKv1
Support Vista-X and Nova Yes No
Support Vista-P and Sora Yes Yes
Modular Design Yes No
Advanced Capture Replay Yes No
Open Source Yes* No

(*Source code of SDKv2 will be provided in the near future)

Comparison between these two styles of SDKs (both extracted from cepton_exporter sample app):

SDKv2:

int InitializeSDK() {
  int err;
  err = CeptonInitialize(CEPTON_API_VERSION, CbCeptonSensorError);
  if (err != CEPTON_SUCCESS) ReportError(err, "CeptonInitialize", true);
  sdk_initialized = true;

  // Enable legacy
  CeptonEnableLegacyTranslation();

  // Listen to point data
  if (streaming) {
    err = CeptonListenPoints(CbCeptonSensorImageData, nullptr);
    if (err != CEPTON_SUCCESS) ReportError(err, "CeptonListenPoints", true);
  } else {
    err = CeptonListenFrames(aggregation_mode, CbCeptonSensorImageData, nullptr);
    if (err != CEPTON_SUCCESS) ReportError(err, "CeptonListenFrames", true);
  }

  // Listen to sensor detection
  CeptonListenSensorInfo(CbCeptonSensorInfo, nullptr);

  if (!capture_file.empty()) {
    err = CeptonReplayLoadPcap(capture_file.c_str(), 0, &capture_handle);
    if (err != CEPTON_SUCCESS) ReportError(err, "CeptonReplayLoadPcap", true);
    err = CeptonReplaySetSpeed(capture_handle, 0);  // No delay replay
    if (err != CEPTON_SUCCESS) ReportError(err, "CeptonReplaySetSpeed", true);
    err = CeptonReplayPlay(capture_handle);
    if (err != CEPTON_SUCCESS) ReportError(err, "CeptonStartReplay", true);
  } else {
    err = CeptonStartNetworking();
    if (err != CEPTON_SUCCESS) ReportError(err, "CeptonStartNetworking", true);
  }
  return 0;
}

SDKv1:

int InitializeSDK() {
  CeptonSensorErrorCode err;
  CeptonSDKOptions opts = cepton_sdk_create_options();
  if (streaming) {
    opts.frame.mode = CEPTON_SDK_FRAME_STREAMING;
  } else {
    // Use cover mode as the default mode
    opts.frame.mode = CEPTON_SDK_FRAME_COVER;
  }

  if (!capture_file.empty())
    opts.control_flags |= CEPTON_SDK_CONTROL_DISABLE_NETWORK;
  err = cepton_sdk_initialize(CEPTON_SDK_VERSION, &opts, CbCeptonSensorError,
                              nullptr);
  if (err != CEPTON_SUCCESS) {
    ReportError(err, "initialize");
    return -1;
  }

  if (!capture_file.empty()) {
    // attempt to discover the sensors in the pcap
    err = cepton_sdk_capture_replay_open(capture_file.c_str());
    if (err != CEPTON_SUCCESS) {
      ReportError(err, "load capture");
      return -1;
    }
    err = cepton_sdk_capture_replay_set_speed(0);
    if (err != CEPTON_SUCCESS) {
      ReportError(err, "set replay speed");
      return -1;
    }
    err = cepton_sdk_capture_replay_resume_blocking(2.0f);
    if (err != CEPTON_SUCCESS) {
      ReportError(err, "pre-replay");
      return -1;
    }
    err = cepton_sdk_capture_replay_seek(0);
    if (err != CEPTON_SUCCESS) {
      ReportError(err, "rewind");
      return -1;
    }
  }

  err = cepton_sdk_listen_image_frames(CbCeptonSensorImageData, nullptr);
  if (err != CEPTON_SUCCESS) {
    ReportError(err, "listen frames");
    return -1;
  }

  if (!capture_file.empty()) {
    err = cepton_sdk_capture_replay_resume();
    if (err != CEPTON_SUCCESS) {
      ReportError(err, "load capture");
      return -1;
    }
  }

  return 0;
}

For more information, please visit SDKv2 page