-
Notifications
You must be signed in to change notification settings - Fork 568
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
Wait for nonzero joint states in PSM in Servo CPP integration test #3056
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -62,14 +62,42 @@ class ServoCppFixture : public testing::Test | |
|
||
planning_scene_monitor_ = moveit_servo::createPlanningSceneMonitor(servo_test_node_, servo_params_); | ||
|
||
// Wait until the joint configuration is nonzero before starting MoveIt Servo. | ||
int num_tries = 0; | ||
const int max_tries = 20; | ||
while (true) | ||
{ | ||
const auto q = getCurrentJointPositions("panda_arm"); | ||
if (q.norm() > 0.0) | ||
{ | ||
break; | ||
} | ||
if (num_tries > max_tries) | ||
{ | ||
FAIL() << "Robot joint configuration did not reach expected state after some time. Test is flaky."; | ||
} | ||
std::this_thread::sleep_for(std::chrono::milliseconds(100)); | ||
num_tries++; | ||
} | ||
|
||
servo_test_instance_ = | ||
std::make_shared<moveit_servo::Servo>(servo_test_node_, servo_param_listener_, planning_scene_monitor_); | ||
} | ||
|
||
/// Helper function to get the current pose of a specified frame. | ||
Eigen::Isometry3d getCurrentPose(const std::string& target_frame) const | ||
{ | ||
return planning_scene_monitor_->getStateMonitor()->getCurrentState()->getGlobalLinkTransform(target_frame); | ||
planning_scene_monitor::LockedPlanningSceneRO locked_scene(planning_scene_monitor_); | ||
return locked_scene->getCurrentState().getGlobalLinkTransform(target_frame); | ||
} | ||
|
||
/// Helper function to get the joint configuration of a group. | ||
Eigen::VectorXd getCurrentJointPositions(const std::string& group_name) const | ||
{ | ||
planning_scene_monitor::LockedPlanningSceneRO locked_scene(planning_scene_monitor_); | ||
std::vector<double> joint_positions; | ||
locked_scene->getCurrentState().copyJointGroupPositions(group_name, joint_positions); | ||
return Eigen::Map<Eigen::VectorXd>(joint_positions.data(), joint_positions.size()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This returns a pointer to the local vector |
||
} | ||
|
||
std::shared_ptr<rclcpp::Node> servo_test_node_; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a function for this:
planning_scene_monitor_->getStateMonitor()->waitForCompleteState(group_name, wait_time);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But we're not using the state monitor anymore, which was the original issue right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The issue was not with the StateMonitor itself, but asking for the current state before it was updated the first time.