-
Notifications
You must be signed in to change notification settings - Fork 935
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
motion_planning_rviz_plugin : add CartesianPath planning check box #1238
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
2f4206a
motion_planning_rviz_plugin : add CartesianPath planning check box
k-okada 1af111f
remove cartesianPathToggled()
rhaschke a4922fc
cleanup
rhaschke 77faad5
gracefully handle non-unique end-effector
rhaschke 2e76c28
save/load status of CartesianPath checkbox
rhaschke 989af56
report planning time
rhaschke d4c761c
disable checkbox if CartesianPath planning is not feasible
rhaschke d61f8ec
clang format
rhaschke File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
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
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 |
---|---|---|
|
@@ -43,6 +43,8 @@ | |
|
||
#include <std_srvs/Empty.h> | ||
#include <moveit_msgs/RobotState.h> | ||
#include <tf2_eigen/tf2_eigen.h> | ||
#include <moveit/trajectory_processing/iterative_time_parameterization.h> | ||
|
||
#include "ui_motion_planning_rviz_plugin_frame.h" | ||
|
||
|
@@ -108,6 +110,59 @@ void MotionPlanningFrame::onClearOctomapClicked() | |
clear_octomap_service_client_.call(srv); | ||
} | ||
|
||
bool MotionPlanningFrame::computeCartesianPlan() | ||
{ | ||
ros::WallTime start = ros::WallTime::now(); | ||
// get goal pose | ||
robot_state::RobotState goal = *planning_display_->getQueryGoalState(); | ||
std::vector<geometry_msgs::Pose> waypoints; | ||
const std::string& link_name = move_group_->getEndEffectorLink(); | ||
const robot_model::LinkModel* link = move_group_->getRobotModel()->getLinkModel(link_name); | ||
if (!link) | ||
{ | ||
ROS_ERROR_STREAM("Failed to determine unique end-effector link: " << link_name); | ||
return false; | ||
} | ||
waypoints.push_back(tf2::toMsg(goal.getGlobalLinkTransform(link))); | ||
|
||
// setup default params | ||
double cart_step_size = 0.01; | ||
double cart_jump_thresh = 0.0; | ||
bool avoid_collisions = true; | ||
|
||
// compute trajectory | ||
moveit_msgs::RobotTrajectory trajectory; | ||
double fraction = | ||
move_group_->computeCartesianPath(waypoints, cart_step_size, cart_jump_thresh, trajectory, avoid_collisions); | ||
|
||
if (fraction >= 1.0) | ||
{ | ||
ROS_INFO("Achieved %f %% of Cartesian path", fraction * 100.); | ||
|
||
// Compute time parameterization to also provide velocities | ||
// https://groups.google.com/forum/#!topic/moveit-users/MOoFxy2exT4 | ||
robot_trajectory::RobotTrajectory rt(move_group_->getRobotModel(), move_group_->getName()); | ||
rt.setRobotTrajectoryMsg(*move_group_->getCurrentState(), trajectory); | ||
trajectory_processing::IterativeParabolicTimeParameterization iptp; | ||
bool success = | ||
iptp.computeTimeStamps(rt, ui_->velocity_scaling_factor->value(), ui_->acceleration_scaling_factor->value()); | ||
ROS_INFO("Computing time stamps %s", success ? "SUCCEDED" : "FAILED"); | ||
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. SUCCEEDED 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. As this is already merged, could you please file a PR? |
||
|
||
// Store trajectory in current_plan_ | ||
current_plan_.reset(new moveit::planning_interface::MoveGroupInterface::Plan()); | ||
rt.getRobotTrajectoryMsg(current_plan_->trajectory_); | ||
current_plan_->planning_time_ = (ros::WallTime::now() - start).toSec(); | ||
return success; | ||
} | ||
return false; | ||
} | ||
|
||
bool MotionPlanningFrame::computeJointSpacePlan() | ||
{ | ||
current_plan_.reset(new moveit::planning_interface::MoveGroupInterface::Plan()); | ||
return move_group_->plan(*current_plan_) == moveit::planning_interface::MoveItErrorCode::SUCCESS; | ||
} | ||
|
||
void MotionPlanningFrame::computePlanButtonClicked() | ||
{ | ||
if (!move_group_) | ||
|
@@ -117,19 +172,18 @@ void MotionPlanningFrame::computePlanButtonClicked() | |
ui_->result_label->setText("Planning..."); | ||
|
||
configureForPlanning(); | ||
current_plan_.reset(new moveit::planning_interface::MoveGroupInterface::Plan()); | ||
if (move_group_->plan(*current_plan_)) | ||
bool success = (ui_->use_cartesian_path->isEnabled() && ui_->use_cartesian_path->checkState()) ? | ||
computeCartesianPlan() : | ||
computeJointSpacePlan(); | ||
|
||
if (success) | ||
{ | ||
ui_->execute_button->setEnabled(true); | ||
|
||
// Success | ||
ui_->result_label->setText(QString("Time: ").append(QString::number(current_plan_->planning_time_, 'f', 3))); | ||
} | ||
else | ||
{ | ||
current_plan_.reset(); | ||
|
||
// Failure | ||
ui_->result_label->setText("Failed"); | ||
} | ||
Q_EMIT planningFinished(); | ||
|
@@ -156,8 +210,16 @@ void MotionPlanningFrame::computePlanAndExecuteButtonClicked() | |
// to suppress a warning, we pass an empty state (which encodes "start from current state") | ||
move_group_->setStartStateToCurrentState(); | ||
ui_->stop_button->setEnabled(true); | ||
bool success = move_group_->move() == moveit::planning_interface::MoveItErrorCode::SUCCESS; | ||
onFinishedExecution(success); | ||
if (ui_->use_cartesian_path->isEnabled() && ui_->use_cartesian_path->checkState()) | ||
{ | ||
if (computeCartesianPlan()) | ||
computeExecuteButtonClicked(); | ||
} | ||
else | ||
{ | ||
bool success = move_group_->move() == moveit::planning_interface::MoveItErrorCode::SUCCESS; | ||
onFinishedExecution(success); | ||
} | ||
ui_->plan_and_execute_button->setEnabled(true); | ||
} | ||
|
||
|
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
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.
This used to be
> 0
. With this version, the button fails silently. Is that on purpose?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.
Yes, this was on purpose: If you cannot reach your target, the planning request should fail.
What do you mean by "fails silently"? It should be written "FAILED" and the partial trajectory should be shown.
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.
My bad, it will display "Failed" in the UI. I don't see how the partial trajectory would be displayed, but I'll go test first.