Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C++ thread interfere the LCM::subscribe #266

Open
AdamPengG opened this issue Dec 26, 2018 · 0 comments
Open

C++ thread interfere the LCM::subscribe #266

AdamPengG opened this issue Dec 26, 2018 · 0 comments

Comments

@AdamPengG
Copy link

I have use the C++ thread with the LCM::subscribe in main function.The thread run well.But subscribe doesn't call the call back method.Does the subscribe can't use when I use a C++ thread.
Here is my code:
int main(int argc,char **argv){
Camera zed;
InitParameters init_params;
init_params.camera_resolution = RESOLUTION_HD1080;
init_params.depth_mode = DEPTH_MODE_PERFORMANCE;
init_params.coordinate_units = UNIT_METER;
if (argc > 1) init_params.svo_input_filename.set(argv[1]);

    ERROR_CODE err = zed.open(init_params);
        if (err != SUCCESS) {
            printf("%s\n", toString(err).c_str());
            zed.close();
            return 1; // Quit if an error occurred
        }

    //LCM
    lcm::LCM lcm;
    if (!lcm.good())
          return 1;
    Handler handlerObject;
    lcm.subscribe("InsData",&Handler::Callback_RTK,&handlerObject);//The Callback_RTK can't cout anything.

    thread t1 (savepic,ref(zed));
    thread t2 (saveIMU,ref(zed));
    thread t3 (saveRTK);//file out the Rtk data. RTK vector is a global variable.
    //thread t4 (lcm.subscribe,ref("InsData"),ref(Handler::Callback_RTK),ref(handlerObject));

    //t4.join();
    t3.join();
    t2.join();
    t1.join();
 
    while(0==lcm.handle());
    return 0;

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant