Skip to content

Commit

Permalink
Public-Auto-release: v2.20.5
Browse files Browse the repository at this point in the history
# Changed
* [closes #42694] Properly terminate C++ examples on SIGINT
  • Loading branch information
blickfeld-lidar committed Sep 21, 2022
1 parent 9948e6f commit bb54e1c
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 12 deletions.
5 changes: 5 additions & 0 deletions doc/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ influence the resulting point cloud.

### Removed

## [2.20.5] - 2022.09.21

### Changed
* [closes #42694] Properly terminate C++ examples on SIGINT

## [2.20.4] - 2022.09.21

### Changed
Expand Down
15 changes: 9 additions & 6 deletions examples/cpp/fetch_clouds/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,14 @@
#include <blickfeld/scanner.h>
#include <blickfeld/utils.h>

std::shared_ptr<blickfeld::scanner::point_cloud_stream<blickfeld::protocol::data::Frame> > stream;

bool keep_alive = true;
void sigint_handler(int signal) {
stream = nullptr;
exit(signal);
if (keep_alive) {
std::cout << "Received SIGINT. Stopping stream." << std::endl;
keep_alive = false;
} else {
exit(signal);
}
}

int example(int argc, char* argv[]) {
Expand All @@ -38,7 +41,7 @@ int example(int argc, char* argv[]) {
std::cout << "Connected." << std::endl;

// Create a pointcloud stream object to receive pointclouds
stream = scanner->get_point_cloud_stream();
auto stream = scanner->get_point_cloud_stream();

std::ofstream dump_stream;
#ifdef BSL_RECORDING
Expand All @@ -49,7 +52,7 @@ int example(int argc, char* argv[]) {
}
#endif

while (true) {
while (keep_alive) {
// Format of frame is described in protocol/blickfeld/data/frame.proto or doc/protocol.md
// Protobuf API is described in https://developers.google.com/protocol-buffers/docs/cpptutorial
const blickfeld::protocol::data::Frame frame = stream->recv_frame();
Expand Down
15 changes: 9 additions & 6 deletions examples/cpp/fetch_imu/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,14 @@
#include <blickfeld/scanner.h>
#include <blickfeld/utils.h>

std::shared_ptr<blickfeld::imu_stream> stream;

bool keep_alive = true;
void sigint_handler(int signal) {
stream = nullptr;
exit(signal);
if (keep_alive) {
std::cout << "Received SIGINT. Stopping stream." << std::endl;
keep_alive = false;
} else {
exit(signal);
}
}

int example(int argc, char* argv[]) {
Expand All @@ -35,9 +38,9 @@ int example(int argc, char* argv[]) {
std::cout << "Connected." << std::endl;

// Create a pointcloud stream object to receive pointclouds
stream = scanner->get_imu_stream();
auto stream = scanner->get_imu_stream();

while (true) {
while (keep_alive) {
// Format of IMU data is described in protocol documentation:
// https://docs.blickfeld.com/cube/latest/external/blickfeld-scanner-lib/protobuf_protocol.html
//
Expand Down

0 comments on commit bb54e1c

Please sign in to comment.