Skip to content

Commit

Permalink
v1.5
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan Allen committed Aug 11, 2018
1 parent 8e815db commit aa3a74c
Show file tree
Hide file tree
Showing 15 changed files with 123 additions and 42 deletions.
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Cepton ROS Release Notes

## Version 1.5 2018-08-10
* Updated sdk.

## Version 1.4 (2018-08-02)
* Updated sdk.
* Changed point types.
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ set(OS_NAME "linux-${MACHINE_ARCH}")

# Variables
set(CEPTON_ROS_VERSION_MAJOR 1)
set(CEPTON_ROS_VERSION_MINOR 4)
set(CEPTON_ROS_VERSION_MINOR 5)
set(CEPTON_ROS_VERSION_STRING "${CEPTON_ROS_VERSION_MAJOR}.${CEPTON_ROS_VERSION_MINOR}")
add_definitions(-DCEPTON_ROS_VERSION_MAJOR=${CEPTON_ROS_VERSION_MAJOR})
add_definitions(-DCEPTON_ROS_VERSION_MINOR=${CEPTON_ROS_VERSION_MINOR})
Expand Down
30 changes: 30 additions & 0 deletions third_party/cepton_sdk/include/cepton_def.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/** Define macros.
*/

#ifdef COMPILING

#ifdef _MSC_VER
#define EXPORT __declspec(dllexport)
#elif __GNUC__
#define EXPORT __attribute__((visibility("default")))
#else
#define EXPORT
#endif

#else

#ifdef _MSC_VER
#define EXPORT __declspec(dllimport)
#else
#define EXPORT
#endif

#endif

#if defined(_MSC_VER)
#define DEPRECATED __declspec(deprecated)
#elif defined(__GNUC__)
#define DEPRECATED __attribute__((deprecated))
#else
#define DEPRECATED
#endif
7 changes: 0 additions & 7 deletions third_party/cepton_sdk/include/cepton_export.h

This file was deleted.

16 changes: 11 additions & 5 deletions third_party/cepton_sdk/include/cepton_sdk.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
extern "C" {
#endif

#include "cepton_export.h"
#define COMPILING CEPTON_SDK_COMPILING
#include "cepton_def.h"

#define CEPTON_SDK_VERSION 14

Expand Down Expand Up @@ -90,7 +91,7 @@ struct EXPORT CeptonSensorInformation {
float last_reported_humidity; ///< [%]
float last_reported_age; ///< [hours]

float measurement_period; ///< Time between measurements [microseconds]
float measurement_period; ///< Time between measurements [seconds]

int64_t ptp_ts; /// [microseconds]

Expand Down Expand Up @@ -140,6 +141,11 @@ struct EXPORT CeptonSensorImagePoint {
CeptonSensorReturnType return_type;

#ifdef SIMPLE
/**
* 1. `valid`: If `false`, then the distance and intensity are invalid.
* 2. `saturated`: If `true`, then the intensity is invalid. The distance is
* valid, but inaccurate.
*/
uint8_t flags;
#else
union {
Expand Down Expand Up @@ -314,7 +320,7 @@ EXPORT int64_t cepton_sdk_capture_replay_get_start_time();
EXPORT float cepton_sdk_capture_replay_get_position();
EXPORT float cepton_sdk_capture_replay_get_length();
EXPORT int cepton_sdk_capture_replay_is_end();
EXPORT CeptonSensorErrorCode cepton_sdk_capture_replay_rewind(); // DEPRECATED
DEPRECATED EXPORT CeptonSensorErrorCode cepton_sdk_capture_replay_rewind();
EXPORT CeptonSensorErrorCode cepton_sdk_capture_replay_seek(float position);

EXPORT CeptonSensorErrorCode
Expand All @@ -331,10 +337,10 @@ EXPORT int cepton_sdk_capture_replay_is_running();
EXPORT CeptonSensorErrorCode cepton_sdk_capture_replay_resume();
EXPORT CeptonSensorErrorCode cepton_sdk_capture_replay_pause();

#include "cepton_undef.h"

#ifdef __cplusplus
} // extern "C"
#endif

#undef EXPORT

#endif // CEPTON_SDK_H
36 changes: 33 additions & 3 deletions third_party/cepton_sdk/include/cepton_sdk.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,18 @@

#include "cepton_sdk.h"

#include <cassert>

#include <array>
#include <functional>
#include <mutex>
#include <string>
#include <vector>

namespace cepton_sdk {

#include "cepton_def.h"

//------------------------------------------------------------------------------
// Errors
//------------------------------------------------------------------------------
Expand Down Expand Up @@ -65,9 +70,8 @@ const T *get_error_data(SensorErrorCode error_code, const void *error_data,
class SensorError : public std::runtime_error {
public:
SensorError(SensorErrorCode code_, const char *const msg)
: std::runtime_error(msg), code(code_) {}
SensorError(SensorErrorCode code)
: SensorError(code, get_error_code_name(code)) {}
: std::runtime_error(create_message(code_, msg).c_str()), code(code_) {}
SensorError(SensorErrorCode code) : SensorError(code, "") {}
SensorError() : SensorError(CEPTON_SUCCESS) {}

/// Returns `false` if code is `CEPTON_SUCCESS`, true otherwise.
Expand All @@ -78,6 +82,20 @@ class SensorError : public std::runtime_error {
bool is_error() const { return is_error_code(code); }
bool is_fault() const { return is_fault_code(code); }

private:
static std::string create_message(SensorErrorCode code,
const char *const msg) {
std::array<char, 1024> result;
if (msg[0] == '\0') {
std::snprintf(result.data(), result.size(), "%s",
get_error_code_name(code));
} else {
std::snprintf(result.data(), result.size(), "%s: %s",
get_error_code_name(code), msg);
}
return result.data();
}

public:
SensorErrorCode code;
};
Expand Down Expand Up @@ -204,6 +222,16 @@ typedef void (*FpSensorImageDataCallback)(SensorHandle handle,

/// Sets image frames callback.
/**
* Returns points at frequency specified by `cepton_sdk::FrameOptions::mode`.
* Each frame contains all possible points (use
* `cepton_sdk::SensorImagePoint::valid` to filter points). Points are ordered
* by measurement, segment, and return:
*
* ```
* measurement_count = n_points / (segment_count * return_count)
* idx = ((i_measurement) * segment_count + i_segment) * return_count + i_return
* ```
*
* Returns error if callback already registered.
*/
static SensorError listen_image_frames(FpSensorImageDataCallback cb,
Expand Down Expand Up @@ -419,5 +447,7 @@ static SensorError pause() {
return get_error();
}

#include "cepton_undef.h"

} // namespace capture_replay
} // namespace cepton_sdk
47 changes: 28 additions & 19 deletions third_party/cepton_sdk/include/cepton_sdk_api.hpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
/*
Copyright Cepton Technologies Inc. 2017, All rights reserved.
Cepton Sensor SDK high level API for prototyping.
*/
#pragma once

#include <algorithm>
Expand All @@ -15,19 +10,30 @@
namespace cepton_sdk {
namespace api {

/// Returns false if capture replay is open, true otherwise.
#include "cepton_def.h"

/// Returns true if capture replay is not open.
static bool is_live() { return !capture_replay::is_open(); }

static bool is_end() { return (is_live()) ? false : capture_replay::is_end(); }
/// Returns true if live or capture replay is running.
static bool is_realtime() { return is_live() || capture_replay::is_running(); }

static bool is_end() {
if (capture_replay::is_open()) {
if (capture_replay::get_enable_loop()) return false;
return capture_replay::is_end();
}
return false;
}

/// Returns capture replay time or live time.
static uint64_t get_time() {
return (is_live()) ? util::get_timestamp_usec() : capture_replay::get_time();
}

/// Sleeps or resumes capture replay for duration.
static SensorErrorCode wait(float t_length = 0.1f) {
if (is_live() || capture_replay::is_running()) {
static SensorError wait(float t_length = 0.1f) {
if (is_realtime()) {
std::this_thread::sleep_for(
std::chrono::milliseconds((int)(1e3f * t_length)));
return CEPTON_SUCCESS;
Expand All @@ -46,20 +52,20 @@ static SensorError create_error(SensorErrorCode error_code,
if (!error_code) return SensorError();

std::string error_code_name = get_error_code_name(error_code);
char error_msg[100];
char error_msg[1024];
if (msg.empty()) {
std::snprintf(error_msg, 100, "SDK Error: %s!\n", error_code_name.c_str());
std::snprintf(error_msg, 1024, "SDK Error: %s!\n", error_code_name.c_str());
} else {
std::snprintf(error_msg, 100, "%s: %s!\n", msg.c_str(),
std::snprintf(error_msg, 1024, "%s: %s!\n", msg.c_str(),
error_code_name.c_str());
}
return SensorError(error_code, error_msg);
}
} // namespace internal

/// DEPRICATED: use `cepton_sdk::api::check_error`.
static SensorError check_error_code(SensorErrorCode error_code,
const std::string &msg = "") {
/// DEPRECATED: use `cepton_sdk::api::check_error`.
DEPRECATED static SensorError check_error_code(SensorErrorCode error_code,
const std::string &msg = "") {
const auto error = internal::create_error(error_code, msg);
if (!error) return error;

Expand All @@ -71,9 +77,9 @@ static SensorError check_error_code(SensorErrorCode error_code,
return error;
}

/// DEPRICATED: use `cepton_sdk::api::log_error`.
static SensorError log_error_code(SensorErrorCode error_code,
const std::string &msg = "") {
/// DEPRECATED: use `cepton_sdk::api::log_error`.
DEPRECATED static SensorError log_error_code(SensorErrorCode error_code,
const std::string &msg = "") {
const auto error = internal::create_error(error_code, msg);
if (!error) return error;

Expand Down Expand Up @@ -114,7 +120,7 @@ static void default_on_error(SensorHandle h, SensorErrorCode error_code,
const void *const error_data,
std::size_t error_data_size,
void *const instance) {
check_error(SensorError(error_code, error_msg));
log_error(SensorError(error_code, error_msg));
}

// -----------------------------------------------------------------------------
Expand Down Expand Up @@ -221,5 +227,8 @@ static std::vector<uint64_t> get_sensor_serial_numbers() {
std::sort(serial_numbers.begin(), serial_numbers.end());
return serial_numbers;
}

#include "cepton_undef.h"

} // namespace api
} // namespace cepton_sdk
19 changes: 12 additions & 7 deletions third_party/cepton_sdk/include/cepton_sdk_util.hpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
/*
Copyright Cepton Technologies Inc. 2017, All rights reserved.
Cepton Sensor SDK utilities.
*/
#pragma once

#include "cepton_sdk.hpp"
Expand All @@ -19,9 +14,14 @@
namespace cepton_sdk {
namespace util {

#include "cepton_def.h"

//------------------------------------------------------------------------------
// Common
//------------------------------------------------------------------------------
const int64_t second_usec(1e6);
const int64_t hour_usec(60.0 * 60.0 * 1e6);

template <typename T>
inline T square(T x) {
return x * x;
Expand All @@ -32,9 +32,9 @@ inline T square(T x) {
* This is the timestamp format used by all sdk functions.
*/
static int64_t get_timestamp_usec() {
const auto t_epoch = std::chrono::steady_clock::now().time_since_epoch();
// const auto t_epoch =
// std::chrono::high_resolution_clock::now().time_since_epoch();
const auto t_epoch = std::chrono::system_clock::now().time_since_epoch();
return std::chrono::duration_cast<std::chrono::microseconds>(t_epoch).count();
}

Expand Down Expand Up @@ -477,6 +477,7 @@ class FrameDetector {
}
break;
}
break;
case CEPTON_SDK_FRAME_CYCLE:
switch (m_sensor_info.model) {
case VISTA_860:
Expand All @@ -490,6 +491,7 @@ class FrameDetector {
}
break;
}
break;
}

switch (m_options.mode) {
Expand Down Expand Up @@ -581,7 +583,7 @@ class FrameAccumulator {
public:
FrameAccumulator(const SensorInformation &sensor_info)
: m_sensor_info(sensor_info), m_frame_detector(sensor_info) {
m_stride = (int)sensor_info.return_count * (int)sensor_info.segment_count;
m_stride = sensor_info.return_count * sensor_info.segment_count;
clear_impl();
}

Expand Down Expand Up @@ -650,5 +652,8 @@ class FrameAccumulator {
int m_i_frame;
FrameDetector m_frame_detector;
};

#include "cepton_undef.h"

} // namespace util
} // namespace cepton_sdk
5 changes: 5 additions & 0 deletions third_party/cepton_sdk/include/cepton_undef.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/** Undefine macros.
*/
#undef COMPILING
#undef EXPORT
#undef DEPRECATED
Binary file modified third_party/cepton_sdk/lib/linux-aarch64/libcepton_sdk.a
Binary file not shown.
Binary file modified third_party/cepton_sdk/lib/linux-aarch64/libcepton_sdk.so
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified third_party/cepton_sdk/lib/linux-x86_64/libcepton_sdk.a
Binary file not shown.
Binary file modified third_party/cepton_sdk/lib/linux-x86_64/libcepton_sdk.so
Binary file not shown.

0 comments on commit aa3a74c

Please sign in to comment.