Skip to content

Commit

Permalink
fixup! add rs-all-client test in GHA
Browse files Browse the repository at this point in the history
  • Loading branch information
maloel committed Oct 28, 2023
1 parent 64cd29a commit 3742237
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 31 deletions.
22 changes: 15 additions & 7 deletions .github/workflows/buildsCI.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -154,15 +154,14 @@ 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
- name: Client for realsense2-all
shell: bash
run: |
run: |
mkdir ${{env.WIN_BUILD_DIR}}/rs-all-client
cd ${{env.WIN_BUILD_DIR}}/rs-all-client
cmake $GITHUB_WORKSPACE/.github/workflows/rs-all-client -G "Visual Studio 16 2019"
cmake --build . --config Release -- -m
./Release/rs-all-client
#--------------------------------------------------------------------------------
Expand Down Expand Up @@ -392,24 +391,33 @@ jobs:
run: |
cd build
cmake .. -DCMAKE_BUILD_TYPE=${{env.LRS_RUN_CONFIG}} -DBUILD_SHARED_LIBS=false -DBUILD_EXAMPLES=false -DBUILD_TOOLS=false -DBUILD_UNIT_TESTS=false -DCHECK_FOR_UPDATES=false -DBUILD_WITH_DDS=true -DBUILD_PYTHON_BINDINGS=true -DPYTHON_EXECUTABLE=$(which python3) -DFORCE_RSUSB_BACKEND=true
cmake --build . -- -j4
cmake --build . -- -j4
- name: LibCI
# Note: we specifically disable BUILD_UNIT_TESTS so the executable C++ unit-tests won't run
# This is to save time as DDS already lengthens the build...
shell: bash
run: |
python3 unit-tests/run-unit-tests.py --no-color --debug --stdout --not-live --context "dds linux" --tag dds
- name: Client for realsense2-all
shell: bash
run: |
mkdir ${{env.WIN_BUILD_DIR}}/rs-all-client
cd ${{env.WIN_BUILD_DIR}}/rs-all-client
cmake $GITHUB_WORKSPACE/.github/workflows/rs-all-client -DBUILD_WITH_DDS=ON
cmake --build . -- -j4
./rs-all-client

#--------------------------------------------------------------------------------
U22_SH_RSUSB_LiveTest: # Ubuntu 2022, Shared, Legacy live-tests
runs-on: ubuntu-22.04
runs-on: ubuntu-22.04
timeout-minutes: 60
env:
LRS_BUILD_NODEJS: true
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v3

- name: Check_API
shell: bash
Expand Down
14 changes: 12 additions & 2 deletions .github/workflows/rs-all-client/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,22 @@ 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
MSVC_RUNTIME_LIBRARY MultiThreaded$<$<CONFIG:Debug>:Debug> # New in version 3.15; ignored in Linux
)

target_include_directories( ${PROJECT_NAME} PRIVATE ../../../include )
target_include_directories( ${PROJECT_NAME} PRIVATE
../../../include
../../../third-party/rsutils/include
)
target_link_directories( ${PROJECT_NAME} PRIVATE ${CMAKE_BINARY_DIR}/../Release )

if( NOT WIN32 )
find_library( LIBUSB NAMES usb-1.0 )
target_link_libraries( ${PROJECT_NAME} PRIVATE realsense2-all udev pthread ${LIBUSB} )
if( BUILD_WITH_DDS )
target_link_libraries( ${PROJECT_NAME} PRIVATE ssl crypto rt )
endif()
endif()

#
target_link_libraries( ${PROJECT_NAME} PRIVATE realsense2-all )
Expand Down
50 changes: 28 additions & 22 deletions .github/workflows/rs-all-client/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,38 @@
#include <librealsense2/rs.hpp> // Include RealSense Cross Platform API
#include <iostream> // for cout

// This is the Hello RealSense example
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;
rs2::log_to_console( RS2_LOG_SEVERITY_DEBUG );

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

while (true)
rs2::context context;
auto devices = context.query_devices();
if( devices.size() )
{
// 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";
// This can run under GHA, too -- so we don't always have devices
// Run for just a little bit, count the frames
size_t n_frames = 0;
{
rs2::pipeline p( context );
auto profile = p.start();
auto device = profile.get_device();
std::cout << "Streaming on " << device.get_info( RS2_CAMERA_INFO_NAME ) << std::endl;

rsutils::time::timer timer( std::chrono::seconds( 3 ) );
while( ! timer.has_expired() )
{
// Block program until frames arrive
rs2::frameset frames = p.wait_for_frames();
++n_frames;
}
}

std::cout << "Got " << n_frames << " frames" << std::endl;
}
else
{
// Allow enough time for DDS enumeration
std::this_thread::sleep_for( std::chrono::seconds( 3 ) );
}

return EXIT_SUCCESS;
Expand Down

0 comments on commit 3742237

Please sign in to comment.