[BUG] getPrimitiveStates error no response from server
Closed this issue · 7 comments
Version information
- RDK: v0.10
- Robot software: v2.10.9
- OS: Ubuntu 20.04
Describe the bug
Unlike in the previously reported issue here, I am only calling getPrimitiveStates at 10Hz.
After starting a primitive from the RDK, the function getPrimitiveStates is used to monitor the primitive's executing status. However, it sometimes gives the error No response from server and crashes the program.
Steps to reproduce
- Issue the MoveComp primitive
- Call getPrimitiveStates at 10Hz
- The error only happens sometime, not every time, you might need to repeat this multiple times at different network conditions.
Expected behavior
It at least should not close the connection and terminate the program.
Screenshots
Additional context
Will catch the thrown out error help in this case?
@acf986 Have you caught the exception thrown by getPrimitiveStates() when the error "No response from server" happens? Exception will be propagated to the top of stack and trigger the program to exit if not handled.
Server response timeout can happen under busy networks. To address this, you can write a try catch statement to handle such exception: put the first getPrimitiveStates() in the try{} statement, then put another getPrimitiveStates() call in the catch {} statement. This way, a retry of getting primitive states is executed if the first attempt failed.
@pzhu-flexiv , hi we have tried to catch the error with the following code:
bool CompPrimState::is_finished()
{
std::vector<std::string> states;
try
{
states = m_se->get_robot()->getPrimitiveStates();
}
catch(const flexiv::CommException& e )
{
std::cout<<"Catched the error: "<<e.what()<<std::endl;
std::cout<<"Retrying"<<e.what()<<std::endl;
states = m_se->get_robot()->getPrimitiveStates();
std::cout<<"Retry finished"<<e.what()<<std::endl;
}
return execution_started_ && flexiv::utility::parsePtStates(states, "reachedTarget") == "1";
}
This checking function is triggered by a timer at 10Hz.
We've caught the error as shown in the attached image, but the process still failed.
It appears the RDK terminated the process and the program never reach the retry part. Can you suggest a more reliable method to check if a primitive has finished? As this issue will halt the usage of all primitives from RDK.
@acf986 (1/2) What are the primitives you are using?
@acf986 (1/2) What are the primitives you are using?
I am using the moveCompliance primitive.
@acf986 (2/2) Could you update the get primitive states part of your code to the following and try again?
std::vector<std::string> states;
do {
try {
states = m_se->get_robot()->getPrimitiveStates();
} catch (const flexiv::CommException& e) {
std::cout << "Get primitive states failed, trying again ..." << std::endl
}
std::this_thread::sleep_for(std::chrono::milliseconds(100));
} while (flexiv::utility::parsePtStates(states, "reachedTarget") != "1");
@acf986 (1/2) What are the primitives you are using?
I am using the moveCompliance primitive.
Then you have two options, one is to try the revised code I provided above, the other is to use Robot::isStopped() with some initial wait until the robot starts to move.
@acf986 Closed issue due to inactivity. You can reopen it if the issue is not solved.