Skip to content

Commit

Permalink
add rs-all-client test in GHA
Browse files Browse the repository at this point in the history
  • Loading branch information
maloel committed Oct 21, 2023
1 parent 1cbd1f0 commit 7c549aa
Show file tree
Hide file tree
Showing 3 changed files with 99 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .github/workflows/buildsCI.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,17 @@ jobs:
run: |
python3 unit-tests/run-unit-tests.py --no-color --debug --stdout --not-live --context "windows" ${{env.WIN_BUILD_DIR}}/Release
- name: Libraries
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
shell: bash
run: |
LRS_SRC_DIR=$(pwd)/.github/workflows/rs-all-client
mkdir ${{env.WIN_BUILD_DIR}}/rs-all-client
cd ${{env.WIN_BUILD_DIR}}/rs-all-client
cmake $(pwd)/.github/workflows/rs-all-client -G "Visual Studio 16 2019"
cmake --build . -- -m
#--------------------------------------------------------------------------------
Win_SH_Py_DDS_CI: # Windows, Shared, Python, Tools, DDS, libCI without executables
Expand Down
41 changes: 41 additions & 0 deletions .github/workflows/rs-all-client/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# License: Apache 2.0. See LICENSE file in root directory.
# Copyright(c) 2023 Intel Corporation. All Rights Reserved.
cmake_minimum_required( VERSION 3.15 )

#
# This tests whether we can link with realsense2-all and not have any missing external symbols.
# Without realsense2-all, we'd need to link with:
# realsense2 realsense-file rsutils
# Or, if DDS was enabled:
# realsense2 realsense-file rsutils fastcdr fastrtps foonathan_memory realdds
# And the list gets longer if we add libraries.
#
# On Windows, no additional special libraries are needed.
# On Linux, we have other dependencies:
# libusb udev
# These are not part of realsense2-all, even though we depend on them!
#

project( rs-all-client )

option( BUILD_SHARED_LIBS "Build using shared libraries" OFF )

if( WIN32 )
# Take away the other configurations because they'd require we picked another link
# directory and target... keep it simple...
set( CMAKE_CONFIGURATION_TYPES "Release" )
endif()

add_executable( ${PROJECT_NAME} main.cpp )
set_target_properties( ${PROJECT_NAME} PROPERTIES
CXX_STANDARD 14
MSVC_RUNTIME_LIBRARY MultiThreaded$<$<CONFIG:Debug>:Debug> # New in version 3.15
)

target_include_directories( ${PROJECT_NAME} PRIVATE ../../../include )
target_link_directories( ${PROJECT_NAME} PRIVATE ${CMAKE_BUILD_DIR}/../Release )


#
target_link_libraries( ${PROJECT_NAME} PRIVATE realsense2-all )

47 changes: 47 additions & 0 deletions .github/workflows/rs-all-client/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// License: Apache 2.0. See LICENSE file in root directory.
// Copyright(c) 2019 Intel Corporation. All Rights Reserved.

#include <librealsense2/rs.hpp> // Include RealSense Cross Platform API
#include <iostream> // for cout

// Hello RealSense example demonstrates the basics of connecting to a RealSense device
// and taking advantage of depth data
int main(int argc, char * argv[]) try
{
// Create a Pipeline - this serves as a top-level API for streaming and processing frames
rs2::pipeline p;

// Configure and start the pipeline
p.start();

while (true)
{
// Block program until frames arrive
rs2::frameset frames = p.wait_for_frames();

// Try to get a frame of a depth image
rs2::depth_frame depth = frames.get_depth_frame();

// Get the depth frame's dimensions
auto width = depth.get_width();
auto height = depth.get_height();

// Query the distance from the camera to the object in the center of the image
float dist_to_center = depth.get_distance(width / 2, height / 2);

// Print the distance
std::cout << "The camera is facing an object " << dist_to_center << " meters away \r";
}

return EXIT_SUCCESS;
}
catch (const rs2::error & e)
{
std::cerr << "RealSense error calling " << e.get_failed_function() << "(" << e.get_failed_args() << "):\n " << e.what() << std::endl;
return EXIT_FAILURE;
}
catch (const std::exception& e)
{
std::cerr << e.what() << std::endl;
return EXIT_FAILURE;
}

0 comments on commit 7c549aa

Please sign in to comment.