ros2 subscriber callback blocking one another
Hello,
I am using ROS2 galactic on Ubuntu 20.04. I have 2 callbacks, one which subscribes to the movement message and another which subscribes to a custom path message. In the first call I can see that both these callbacks get data and are updated but however my second call back has a function which moves the robot on that particular path. When this line executes, I stop getting data in my first callback because it is blocking it I guess?? I tried callback groups but it didn't work. Here is my code:
1st callback
void Robot::moveStatusCb(const fleet_msgs::msg::MoveStatus &msg) {
moveable = msg.movestatus[robotId - 1];
std::cout << "MOVABLE CALLBACK: " << moveable << std::endl;
}
2nd callback
void Robot::robotPathCb(const fleet_msgs::msg::RobotPath &msg) {
std::cout << "Entered path callback" << std::endl;
for (int i = 0; i < msg.paths.size(); ++i)
{
if (robotId == msg.paths[i].robotid)
{
robotPath = msg.paths[i];
task = 1;
robotInstructions();
assigned = true;
break;
}
else {
task = 0;
robotInstructions();
robotStatus.robotid = robotId;
robotStatus.orderid = -1;
robotStatus.toteid = -1;
robotStatus.state = state;
robotStatPub->publish(robotStatus);
}
}
robotMovement();
}
The robotMovement function is the one which makes the robot move. However when the code enters this function, I stop getting data on movementStatusCb. Can anyone please tell me how to solve this??
Thanks.