Will calling a service whilst processing a message from a topic in a callback lead to a deadlock

asked 2020-10-05 09:09:46 -0500

bgraysea gravatar image

updated 2020-10-05 09:31:13 -0500

If I'm using AsyncSpinner spinner(1); will calling a service whilst processing a message from a topic in a callback lead to a deadlock?

I think yes; but would like to double check I've diagnosed things correctly.

Screen shot below; the most relevant lines are 82, 85 &52

Upading to AsyncSpinner spinner(2) the code is able to progress past line 52

void planningSceneAction(const moveit_msgs::PlanningScene::ConstPtr& msg)
{
    ......
    moveit::planning_interface::MoveGroupInterface::Plan my_plan;
    //DEADLOCKK ISSUES???? Even though its "this thread" invoking the service
    // the response can't be recieved if there is only a single thread?
    bool success = (move_group.plan(my_plan) == moveit::planning_interface::MoveItErrorCode::SUCCESS);
    ......
}

int main(int argc, char** argv)
{
    ......
    ros::Subscriber subPlanningScene = node_handle.subscribe("/planning_scene", 3, planningSceneAction);
    ......
    ros::AsyncSpinner spinner(2); // using 1 hits deadlock

}

I think this is similar to the python version discussed here: https://discourse.ros.org/t/synchrono...C:\fakepath\deadlock-able.png

edit retag flag offensive close merge delete

Comments

1

Please paste the text as code. Screenshots of terminal and code are discouraged because they are not searchable.

fvd gravatar image fvd  ( 2020-10-05 09:13:33 -0500 )edit