Issues getting development branch of the Astra SDK running with Astra / Astra Pro cameras

Hello!

I’ve managed to make a simple depth / color stream reader with the release version of the Astra SDK on Github and it runs almost without issues. I’m using the Orbbec development board (arm-linux-gnueabihf) with the Astra / Astra Pro cameras. I’m now having segfaults when trying to use a minimalistic program with the development branch. Since the C samples on the Github repo probably don’t reflect the development branch, could you help me in figuring out what I need to change to get the development branch working?

#include <astra/astra.hpp>
#include <astra/capi/astra.h>
#include <iostream>

std::string getAstraError(astra_status_t& error_code)
{
    switch (error_code) {
    case ASTRA_STATUS_INVALID_PARAMETER:
            return "Invalid parameter";
    case ASTRA_STATUS_DEVICE_ERROR:
            return "Device error";
    case ASTRA_STATUS_TIMEOUT:
            return "Timeout";
    case ASTRA_STATUS_INVALID_PARAMETER_TOKEN:
            return "Invalid parameter token";
    case ASTRA_STATUS_INVALID_OPERATION:
            return "Invalid operation";
    case ASTRA_STATUS_INTERNAL_ERROR:
            return "Internal error";
    case ASTRA_STATUS_UNINITIALIZED:
            return "Uninitialized";
    default:
            return "Unknown error";
    }
    return "Unknown error";
}

#define CHECK_STATUS(func, desc) if((rc = func) != ASTRA_STATUS_SUCCESS) { std::cout << "Error with " << desc << ": " << getAstraError(rc) << std::endl; }

int main(int argc, char** argv)
{
    astra_reader_t reader;
    astra_streamsetconnection_t sensor;
    astra_reader_frame_t frame;
    astra_status_t rc;

    CHECK_STATUS(astra_initialize(), "Initializing sensor");
    CHECK_STATUS(astra_streamset_open("device/default", &sensor), "Streamset open");

    CHECK_STATUS(astra_reader_create(sensor, &reader), "reader_create");

    while (true)
    {
         // segfault here
        CHECK_STATUS(astra_reader_open_frame(reader, ASTRA_TIMEOUT_FOREVER, &frame), "reader_open_frame");
        CHECK_STATUS(astra_reader_close_frame(&frame), "reader_close_frame");
    }

    astra_reader_destroy(&reader);
    astra_streamset_close(&sensor);
    astra_terminate();

    return 0;
}

I’m building the program like so: g++ -std=c++11 -g main.cpp -I/home/orbbec/astra/include -L/home/orbbec/astra/build/lib/ -lastra -lastra_core -lastra_core_api

And here’s what gdb tells me. I’m running the program via sudo as I can’t seem to get the sensors running as a normal user. The included examples and my program made with the master branch work via sudo.

sudo gdb

(gdb) set env LD_LIBRARY_PATH=/home/orbbec/astra/build/lib
(gdb) file a.out
A program is being debugged already.
Are you sure you want to change the file? (y or n) y
Load new symbol table from "a.out"? (y or n) y
Reading symbols from a.out...done.
(gdb) break main.cpp:38
Breakpoint 1 at 0x8dd2: file main.cpp, line 38.
(gdb) r
The program being debugged has been started already.
Start it from the beginning? (y or n) y
Starting program: /home/orbbec/bintest/debug/a.out 
yTraceback (most recent call last):
  File "/usr/share/gdb/auto-load/usr/lib/arm-linux-gnueabihf/libstdc++.so.6.0.19-gdb.py", line 63, in <module>
    from libstdcxx.v6.printers import register_libstdcxx_printers
ImportError: No module named 'libstdcxx'
Warning: couldn't activate thread debugging using libthread_db: Cannot find new threads: debugger service failed
warning: File "/lib/arm-linux-gnueabihf/libthread_db-1.0.so" auto-loading has been declined by your `auto-load safe-path' set to "$debugdir:$datadir/auto-load".
warning: Unable to find libthread_db matching inferior's thread library, thread debugging will not be available.
 
Breakpoint 1, main (argc=1, argv=0xbefff704) at main.cpp:38
38      CHECK_STATUS(astra_streamset_open("device/default", &sensor), "Streamset open");
(gdb) s
40      CHECK_STATUS(astra_reader_create(sensor, &reader), "reader_create");
(gdb) s
44          CHECK_STATUS(astra_reader_open_frame(reader, ASTRA_TIMEOUT_FOREVER, &frame), "reader_open_frame");
(gdb) s

Program received signal SIGSEGV, Segmentation fault.
0xb6fa783a in astra::CallbackList<void, astra::stream_connection*, int>::remove(unsigned int) () from /home/orbbec/astra/build/lib/libastra_core.so

(gdb) bt
#0  0xb6fa783a in astra::CallbackList<void, astra::stream_connection*, int>::remove(unsigned int) () from /home/orbbec/astra/build/lib/libastra_core.so
#1  0xb6fa7500 in astra::signal<astra::stream_connection*, int>::operator-=(unsigned int) () from /home/orbbec/astra/build/lib/libastra_core.so
#2  0xb6fa6b20 in astra::stream_connection::unregister_frame_ready_callback(unsigned int&) () from /home/orbbec/astra/build/lib/libastra_core.so
#3  0xb6fa9386 in astra::stream_reader::~stream_reader() () from /home/orbbec/astra/build/lib/libastra_core.so
#4  0xb128c9c0 in astra::stream_reader::reader_ref::notify_listeners(_astra_reader_frame*) () from /home/orbbec/astra/build/lib/Plugins/liborbbec_xs.so
#5  0xb128c740 in astra::stream_reader::reader_ref::frame_ready_thunk(void*, _astra_reader*, _astra_reader_frame*) () from /home/orbbec/astra/build/lib/Plugins/liborbbec_xs.so
#6  0xb6fa9684 in astra::stream_reader::register_frame_ready_callback(void (*)(void*, _astra_reader*, _astra_reader_frame*), void*)::{lambda(_astra_reader*, _astra_reader_frame*)#1}::operator()(_astra_reader*, _astra_reader_frame*) const () from /home/orbbec/astra/build/lib/libastra_core.so
#7  0xb6faaa9c in std::_Function_handler<void (_astra_reader*, _astra_reader_frame*), astra::stream_reader::register_frame_ready_callback(void (*)(void*, _astra_reader*, _astra_reader_frame*), void*)::{lambda(_astra_reader*, _astra_reader_frame*)#1}>::_M_invoke(std::_Any_data const&, _astra_reader*, _astra_reader_frame*) ()
   from /home/orbbec/astra/build/lib/libastra_core.so
#8  0xb6faca36 in std::function<void (_astra_reader*, _astra_reader_frame*)>::operator()(_astra_reader*, _astra_reader_frame*) const ()
   from /home/orbbec/astra/build/lib/libastra_core.so
#9  0xb6fac30e in astra::CallbackList<void, _astra_reader*, _astra_reader_frame*>::invoke(_astra_reader*, _astra_reader_frame*) ()
   from /home/orbbec/astra/build/lib/libastra_core.so
#10 0xb6fabab8 in astra::signal<_astra_reader*, _astra_reader_frame*>::raise(_astra_reader*, _astra_reader_frame*) () from /home/orbbec/astra/build/lib/libastra_core.so
#11 0xb6faa616 in astra::stream_reader::raise_frame_ready() () from /home/orbbec/astra/build/lib/libastra_core.so
#12 0xb6faa56a in astra::stream_reader::check_for_all_frames_ready() () from /home/orbbec/astra/build/lib/libastra_core.so
#13 0xb6faa482 in astra::stream_reader::on_connection_frame_ready(astra::stream_connection*, int) () from /home/orbbec/astra/build/lib/libastra_core.so
#14 0xb6fa94c2 in astra::stream_reader::get_sc_frame_ready_callback()::{lambda(astra::stream_connection*, int)#1}::operator()(astra::stream_connection*, int) const ()
   from /home/orbbec/astra/build/lib/libastra_core.so
#15 0xb6faab8c in std::_Function_handler<void (astra::stream_connection*, int), astra::stream_reader::get_sc_frame_ready_callback()::{lambda(astra::stream_connection*, int)#1}>::_M_invoke(std::_Any_data const&, astra::stream_connection*, int) () from /home/orbbec/astra/build/lib/libastra_core.so
#16 0xb6fa7a52 in std::function<void (astra::stream_connection*, int)>::operator()(astra::stream_connection*, int) const () from /home/orbbec/astra/build/lib/libastra_core.so
#17 0xb6fa7732 in astra::CallbackList<void, astra::stream_connection*, int>::invoke(astra::stream_connection*, int) () from /home/orbbec/astra/build/lib/libastra_core.so
#18 0xb6fa74c4 in astra::signal<astra::stream_connection*, int>::raise(astra::stream_connection*, int) () from /home/orbbec/astra/build/lib/libastra_core.so
#19 0xb6fa6ac4 in astra::stream_connection::on_bin_front_buffer_ready(astra::stream_bin*, int) () from /home/orbbec/astra/build/lib/libastra_core.so
#20 0xb6fa657e in astra::stream_connection::stream_connection(astra::stream*)::{lambda(astra::stream_bin*, int)#1}::operator()(astra::stream_bin*, int) const ()
   from /home/orbbec/astra/build/lib/libastra_core.so
#21 0xb6fa7060 in std::_Function_handler<void (astra::stream_bin*, int), astra::stream_connection::stream_connection(astra::stream*)::{lambda(astra::stream_bin*, int)#1}>::_M_invoke(std::_Any_data const&, astra::stream_bin*, int) () from /home/orbbec/astra/build/lib/libastra_core.so
#22 0xb6fa8d2a in std::function<void (astra::stream_bin*, int)>::operator()(astra::stream_bin*, int) const () from /home/orbbec/astra/build/lib/libastra_core.so
#23 0xb6fa8c2e in astra::CallbackList<void, astra::stream_bin*, int>::invoke(astra::stream_bin*, int) () from /home/orbbec/astra/build/lib/libastra_core.so
#24 0xb6fa8a08 in astra::signal<astra::stream_bin*, int>::raise(astra::stream_bin*, int) () from /home/orbbec/astra/build/lib/libastra_core.so
#25 0xb6fa86c2 in astra::stream_bin::raiseFrameReadySignal() () from /home/orbbec/astra/build/lib/libastra_core.so
#26 0xb6fa8646 in astra::stream_bin::cycle_buffers() () from /home/orbbec/astra/build/lib/libastra_core.so
#27 0xb6f97e60 in astra::plugin_service_impl::cycle_bin_buffers(_astra_bin*, _astra_frame*&) () from /home/orbbec/astra/build/lib/libastra_core.so
#28 0xb6f964a8 in astra::plugin_service::cycle_bin_buffers(_astra_bin*, _astra_frame*&) () from /home/orbbec/astra/build/lib/libastra_core.so
#29 0xb6f96a16 in astra::plugin_service_delegate::cycle_bin_buffers(void*, _astra_bin*, _astra_frame**) () from /home/orbbec/astra/build/lib/libastra_core.so
#30 0xb6c196d0 in astra::pluginservice_proxy::cycle_bin_buffers(_astra_bin*, _astra_frame**) () from /home/orbbec/astra/build/lib/Plugins/libopenni_sensor.so
#31 0xb6c1c8ae in astra::plugins::stream_bin<_astra_imageframe_wrapper>::cycle() () from /home/orbbec/astra/build/lib/Plugins/libopenni_sensor.so
#32 0xb6c1c23a in astra::plugins::stream_bin<_astra_imageframe_wrapper>::end_write() () from /home/orbbec/astra/build/lib/Plugins/libopenni_sensor.so
#33 0xb6c1b652 in orbbec::ni::devicestream<_astra_imageframe_wrapper>::on_read(int) () from /home/orbbec/astra/build/lib/Plugins/libopenni_sensor.so
#34 0xb6c1eb72 in orbbec::ni::stream::read(int) () from /home/orbbec/astra/build/lib/Plugins/libopenni_sensor.so
#35 0xb6c1dd64 in orbbec::ni::device_streamset::read() () from /home/orbbec/astra/build/lib/Plugins/libopenni_sensor.so
#36 0xb6c16a2e in orbbec::ni::oni_adapter_plugin::read_streams() () from /home/orbbec/astra/build/lib/Plugins/libopenni_sensor.so
#37 0xb6c16998 in orbbec::ni::oni_adapter_plugin::temp_update() () from /home/orbbec/astra/build/lib/Plugins/libopenni_sensor.so
#38 0xb6c162a2 in astra_plugin_update () from /home/orbbec/astra/build/lib/Plugins/libopenni_sensor.so
#39 0xb6f9b0de in astra::plugin_manager::update() () from /home/orbbec/astra/build/lib/libastra_core.so
#40 0xb6f75d72 in astra::context_impl::temp_update() () from /home/orbbec/astra/build/lib/libastra_core.so
#41 0xb6f60ab8 in astra::context::temp_update() () from /home/orbbec/astra/build/lib/libastra_core.so
#42 0xb6f9128a in astra_temp_update () from /home/orbbec/astra/build/lib/libastra_core.so
#43 0xb6fa97be in astra::stream_reader::block_until_frame_ready_or_timeout(int) () from /home/orbbec/astra/build/lib/libastra_core.so
#44 0xb6fa98aa in astra::stream_reader::lock(int, _astra_reader_frame*&) () from /home/orbbec/astra/build/lib/libastra_core.so
#45 0xb6f7599a in astra::context_impl::reader_open_frame(_astra_reader*, int, _astra_reader_frame*&) () from /home/orbbec/astra/build/lib/libastra_core.so
#46 0xb6f60904 in astra::context::reader_open_frame(_astra_reader*, int, _astra_reader_frame*&) () from /home/orbbec/astra/build/lib/libastra_core.so
#47 0xb6f90fdc in astra_reader_open_frame () from /home/orbbec/astra/build/lib/libastra_core.so
#48 0x00008f04 in main (argc=1, argv=0xbefff704) at main.cpp:44

And here’s some extra information about the compiler, git version, etc. I’ve built the Astra SDK myself for the development board.


orbbec@orbbec:~/bintest/debug$ g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/arm-linux-gnueabihf/4.8/lto-wrapper
Target: arm-linux-gnueabihf
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 4.8.4-2ubuntu1~14.04' --with-bugurl=file:///usr/share/doc/gcc-4.8/README.Bugs --enable-languages=c,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.8 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.8 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --disable-libmudflap --disable-libitm --disable-libquadmath --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-4.8-armhf/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-4.8-armhf --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-4.8-armhf --with-arch-directory=arm --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-multiarch --enable-multilib --disable-sjlj-exceptions --with-arch=armv7-a --with-fpu=vfpv3-d16 --with-float=hard --with-mode=thumb --disable-werror --enable-checking=release --build=arm-linux-gnueabihf --host=arm-linux-gnueabihf --target=arm-linux-gnueabihf
Thread model: posix
gcc version 4.8.4 (Ubuntu/Linaro 4.8.4-2ubuntu1~14.04) 

orbbec@orbbec:~/astra$ git branch
* develop
  master

orbbec@orbbec:~/astra$ git rev-parse HEAD
8236851c47e4d56e8bebf6a26396afc17827fd2a

orbbec@orbbec:~/astra/build/lib$ ls
astra.toml  libastra_core_api.so  libastra_core.so  libastra-device-sdk.a  libastra.so  Plugins

orbbec@orbbec:~/bintest/debug$ uname -a
Linux orbbec 3.10.0 #131 SMP PREEMPT Wed Nov 18 20:31:46 CST 2015 armv7l armv7l armv7l GNU/Linux

orbbec@orbbec:~/bintest/debug$ readelf -h a.out 
ELF Header:
  Magic:   7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00 
  Class:                             ELF32
  Data:                              2's complement, little endian
  Version:                           1 (current)
  OS/ABI:                            UNIX - System V
  ABI Version:                       0
  Type:                              EXEC (Executable file)
  Machine:                           ARM
  Version:                           0x1
  Entry point address:               0x8a69
  Start of program headers:          52 (bytes into file)
  Start of section headers:          151804 (bytes into file)
  Flags:                             0x5000402, has entry point, Version5 EABI, hard-float ABI
  Size of this header:               52 (bytes)
  Size of program headers:           32 (bytes)
  Number of program headers:         9
  Size of section headers:           40 (bytes)
  Number of section headers:         37
  Section header string table index: 34

orbbec@orbbec:~/bintest/debug$ sudo LD_LIBRARY_PATH=/home/orbbec/astra/build/lib/ ldd ./a.out 
    libastra_core.so => /home/orbbec/astra/build/lib/libastra_core.so (0xb6e3f000)
    libstdc++.so.6 => /usr/lib/arm-linux-gnueabihf/libstdc++.so.6 (0xb6d83000)
    libc.so.6 => /lib/arm-linux-gnueabihf/libc.so.6 (0xb6c9c000)
    libastra_core_api.so => /home/orbbec/astra/build/lib/libastra_core_api.so (0xb6c91000)
    libdl.so.2 => /lib/arm-linux-gnueabihf/libdl.so.2 (0xb6c86000)
    libgcc_s.so.1 => /lib/arm-linux-gnueabihf/libgcc_s.so.1 (0xb6c65000)
    /lib/ld-linux-armhf.so.3 (0xb6fa8000)
    libm.so.6 => /lib/arm-linux-gnueabihf/libm.so.6 (0xb6bf8000)

orbbec@orbbec:~/astra/build/lib/Plugins$ ls
libopenni_sensor.so  liborbbec_hand.so  liborbbec_xs.so  openni2  orbbec_hand.toml

orbbec@orbbec:~/astra/build/lib/Plugins$ ldd liborbbec_xs.so
    libastra.so => /home/orbbec/astra/build/lib/Plugins/./../libastra.so (0xb6f82000)
    libastra_core_api.so => /home/orbbec/astra/build/lib/Plugins/./../libastra_core_api.so (0xb6f76000)
    libstdc++.so.6 => /usr/lib/arm-linux-gnueabihf/libstdc++.so.6 (0xb6ebb000)
    libgcc_s.so.1 => /lib/arm-linux-gnueabihf/libgcc_s.so.1 (0xb6e9a000)
    libc.so.6 => /lib/arm-linux-gnueabihf/libc.so.6 (0xb6db3000)
    libm.so.6 => /lib/arm-linux-gnueabihf/libm.so.6 (0xb6d47000)
    /lib/ld-linux-armhf.so.3 (0xb6fd7000)
orbbec@orbbec:~/astra/build/lib/Plugins$ ldd libopenni_sensor.so
    libOpenNI2.so => /home/orbbec/openni2-arm-bin/libOpenNI2.so (0xb6ea4000)
    libstdc++.so.6 => /usr/lib/arm-linux-gnueabihf/libstdc++.so.6 (0xb6de9000)
    libm.so.6 => /lib/arm-linux-gnueabihf/libm.so.6 (0xb6d7d000)
    libgcc_s.so.1 => /lib/arm-linux-gnueabihf/libgcc_s.so.1 (0xb6d5c000)
    libc.so.6 => /lib/arm-linux-gnueabihf/libc.so.6 (0xb6c75000)
    libdl.so.2 => /lib/arm-linux-gnueabihf/libdl.so.2 (0xb6c69000)
    libpthread.so.0 => /lib/arm-linux-gnueabihf/libpthread.so.0 (0xb6c4e000)
    librt.so.1 => /lib/arm-linux-gnueabihf/librt.so.1 (0xb6c40000)
    /lib/ld-linux-armhf.so.3 (0xb6f4e000)