osrf / rmf_core

Provides the centralized functions of RMF: scheduling, etc.
Apache License 2.0
102 stars 41 forks source link

unable to get participant created #284

Closed txlei closed 3 years ago

txlei commented 3 years ago

hi, is there another method to get the participant using the Participant API? using std::future<T>::get(), my program does not return anything and get stuck at that line.

auto p_future = node->_writer->make_participant(
        rmf_traffic::schedule::ParticipantDescription{
        "participant_" + nodeName,
        "su",
        rmf_traffic::schedule::ParticipantDescription::Rx::Unresponsive,
        profile
    });

rmf_traffic::schedule::Participant participant = p_future.get();

I have checked that participant was successfully created from terminal output

[rmf_traffic_schedule-1] [INFO] [1612410020.968641526] [rmf_traffic_schedule_node]: Registered participant [4] named [participant_detection_1] owned by [su]

I require the participant obj to add a negotiator.

rmf_traffic::schedule::StubbornNegotiator negotiator{ participant };
node->_negotiation->register_negotiator(participant.id(), 
std::make_unique<rmf_traffic::schedule::StubbornNegotiator>(negotiator));
mxgrey commented 3 years ago

I suspect the reason it's getting stuck is that you need to keep the ROS node spinning (in another thread) while you wait for the future value to arrive. If the node doesn't spin, then the future can never receive its value (which is coming from a ROS service).

For the easiest user experience, I recommend using async_make_participant, which you provide a callback to that will be triggered when the participant is ready.

On a tangential note, we're making a change to our GitHub Issue page policy. If you're seeking advice rather than reporting a bug, we would like you to use the GitHub Discussions page instead. Let's keep the issues page limited to detailed bug reports.