-
Notifications
You must be signed in to change notification settings - Fork 171
New grasp pose generator stage #196
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
Open
bostoncleek
wants to merge
5
commits into
moveit:master
Choose a base branch
from
bostoncleek:pr-deep_grasp_stage
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
2e30535
New grasp pose generator stage
bostoncleek 8220806
Rename stage to Grasp Provider
bostoncleek e671e06
Remove template paramete to action base class
bostoncleek 5145e0c
Handle asynchronous feedback
bostoncleek 7c47532
Fix Jafar's change requests
bostoncleek 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 hidden or 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
100 changes: 100 additions & 0 deletions
100
core/include/moveit/task_constructor/stages/action_base.h
This file contains hidden or 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 |
---|---|---|
@@ -0,0 +1,100 @@ | ||
/********************************************************************* | ||
* BSD 3-Clause License | ||
* | ||
* Copyright (c) 2020 PickNik Inc. | ||
* All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions are met: | ||
* | ||
* * Redistributions of source code must retain the above copyright notice, this | ||
* list of conditions and the following disclaimer. | ||
* | ||
* * Redistributions in binary form must reproduce the above copyright notice, | ||
* this list of conditions and the following disclaimer in the documentation | ||
* and/or other materials provided with the distribution. | ||
* | ||
* * Neither the name of the copyright holder nor the names of its | ||
* contributors may be used to endorse or promote products derived from | ||
* this software without specific prior written permission. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | ||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | ||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
*********************************************************************/ | ||
|
||
/* Author: Boston Cleek | ||
Desc: Abstact class for stages using a simple action client. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <memory> | ||
#include <string> | ||
#include <limits> | ||
|
||
#include <actionlib/client/simple_action_client.h> | ||
#include <grasping_msgs/GraspPlanningAction.h> | ||
|
||
namespace moveit { | ||
namespace task_constructor { | ||
namespace stages { | ||
|
||
/** @brief Interface allowing stages to use a simple action client */ | ||
class ActionBase | ||
{ | ||
public: | ||
/** | ||
* @brief Constructor | ||
* @param action_name - action namespace | ||
* @param spin_thread - spins a thread to service this action's subscriptions | ||
* @param goal_timeout - goal to completed time out (0 is considered infinite timeout) | ||
* @param server_timeout - connection to server time out (0 is considered infinite timeout) | ||
* @details Initialize the action client and time out parameters | ||
*/ | ||
ActionBase(const std::string& action_name, bool spin_thread, double goal_timeout, double server_timeout); | ||
|
||
/** | ||
* @brief Constructor | ||
* @param action_name - action namespace | ||
* @param spin_thread - spins a thread to service this action's subscriptions | ||
* @details Initialize the action client and time out parameters to infinity | ||
*/ | ||
ActionBase(const std::string& action_name, bool spin_thread); | ||
|
||
/* @brief Destructor */ | ||
virtual ~ActionBase() = default; | ||
|
||
/* @brief Called when goal becomes active */ | ||
virtual void activeCallback() = 0; | ||
|
||
/** | ||
* @brief Called every time feedback is received for the goal | ||
* @param feedback - pointer to the feedback message | ||
*/ | ||
virtual void feedbackCallback(const grasping_msgs::GraspPlanningFeedbackConstPtr& feedback) = 0; | ||
|
||
/** | ||
* @brief Called once when the goal completes | ||
* @param state - state info for goal | ||
* @param result - pointer to result message | ||
*/ | ||
virtual void doneCallback(const actionlib::SimpleClientGoalState& state, | ||
const grasping_msgs::GraspPlanningResultConstPtr& result) = 0; | ||
|
||
protected: | ||
ros::NodeHandle nh_; | ||
std::string action_name_; // action name space | ||
std::unique_ptr<actionlib::SimpleActionClient<grasping_msgs::GraspPlanningAction>> clientPtr_; // action client | ||
double server_timeout_, goal_timeout_; // connection and goal completed time out | ||
}; | ||
} // namespace stages | ||
} // namespace task_constructor | ||
} // namespace moveit |
107 changes: 107 additions & 0 deletions
107
core/include/moveit/task_constructor/stages/grasp_provider.h
This file contains hidden or 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 |
---|---|---|
@@ -0,0 +1,107 @@ | ||
/********************************************************************* | ||
* BSD 3-Clause License | ||
* | ||
* Copyright (c) 2020 PickNik Inc. | ||
* All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions are met: | ||
* | ||
* * Redistributions of source code must retain the above copyright notice, this | ||
* list of conditions and the following disclaimer. | ||
* | ||
* * Redistributions in binary form must reproduce the above copyright notice, | ||
* this list of conditions and the following disclaimer in the documentation | ||
* and/or other materials provided with the distribution. | ||
* | ||
* * Neither the name of the copyright holder nor the names of its | ||
* contributors may be used to endorse or promote products derived from | ||
* this software without specific prior written permission. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | ||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | ||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
*********************************************************************/ | ||
|
||
/* Author: Boston Cleek | ||
Desc: Grasp generator stage | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <functional> | ||
#include <mutex> | ||
|
||
#include <moveit/task_constructor/stages/generate_pose.h> | ||
#include <moveit/task_constructor/stages/action_base.h> | ||
#include <moveit/task_constructor/storage.h> | ||
#include <moveit/task_constructor/marker_tools.h> | ||
#include <rviz_marker_tools/marker_creation.h> | ||
#include <moveit/planning_scene/planning_scene.h> | ||
|
||
namespace moveit { | ||
namespace task_constructor { | ||
namespace stages { | ||
|
||
/** @brief Generate grasp candidates using deep learning approaches */ | ||
class GraspProvider : public GeneratePose, ActionBase | ||
{ | ||
public: | ||
/** | ||
* @brief Constructor | ||
* @param action_name - action namespace | ||
* @param stage_name - name of stage | ||
* @param goal_timeout - goal to completed time out (0 is considered infinite timeout) | ||
* @param server_timeout - connection to server time out (0 is considered infinite timeout) | ||
* @details Initialize the client and connect to server | ||
*/ | ||
GraspProvider(const std::string& action_name, const std::string& stage_name = "grasp provider", | ||
double goal_timeout = 0.0, double server_timeout = 0.0); | ||
|
||
/** | ||
* @brief Composes the action goal and sends to server | ||
*/ | ||
void composeGoal(); | ||
|
||
/** | ||
* @brief Monitors status of action goal | ||
* @return true if grasp candidates are received within (optional) timeout | ||
* @details This is a blocking call. It will wait until either grasp candidates | ||
* are received or the timeout has been reached. | ||
*/ | ||
bool monitorGoal(); | ||
|
||
void activeCallback() override; | ||
void feedbackCallback(const grasping_msgs::GraspPlanningFeedbackConstPtr& feedback) override; | ||
void doneCallback(const actionlib::SimpleClientGoalState& state, | ||
const grasping_msgs::GraspPlanningResultConstPtr& result) override; | ||
|
||
void init(const core::RobotModelConstPtr& robot_model) override; | ||
void compute() override; | ||
|
||
void setEndEffector(const std::string& eef) { setProperty("eef", eef); } | ||
void setObject(const std::string& object) { setProperty("object", object); } | ||
|
||
void setPreGraspPose(const std::string& pregrasp) { properties().set("pregrasp", pregrasp); } | ||
void setPreGraspPose(const moveit_msgs::RobotState& pregrasp) { properties().set("pregrasp", pregrasp); } | ||
void setGraspPose(const std::string& grasp) { properties().set("grasp", grasp); } | ||
void setGraspPose(const moveit_msgs::RobotState& grasp) { properties().set("grasp", grasp); } | ||
|
||
protected: | ||
void onNewSolution(const SolutionBase& s) override; | ||
|
||
private: | ||
std::mutex grasp_mutex_; // Protects grasp candidates | ||
std::atomic_bool found_candidates_; // Flag indicates the discovery of grasps | ||
std::vector<moveit_msgs::Grasp> grasp_candidates_; // Grasp Candidates | ||
}; | ||
} // namespace stages | ||
} // namespace task_constructor | ||
} // namespace moveit |
This file contains hidden or 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 hidden or 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 hidden or 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 |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/********************************************************************* | ||
* BSD 3-Clause License | ||
* | ||
* Copyright (c) 2021 PickNik Inc. | ||
* All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions are met: | ||
* | ||
* * Redistributions of source code must retain the above copyright notice, this | ||
* list of conditions and the following disclaimer. | ||
* | ||
* * Redistributions in binary form must reproduce the above copyright notice, | ||
* this list of conditions and the following disclaimer in the documentation | ||
* and/or other materials provided with the distribution. | ||
* | ||
* * Neither the name of the copyright holder nor the names of its | ||
* contributors may be used to endorse or promote products derived from | ||
* this software without specific prior written permission. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | ||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | ||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
*********************************************************************/ | ||
|
||
/* Author: Boston Cleek | ||
Desc: Abstact class for stages using a simple action client. | ||
*/ | ||
|
||
#include <moveit/task_constructor/stages/action_base.h> | ||
|
||
namespace moveit { | ||
namespace task_constructor { | ||
namespace stages { | ||
|
||
constexpr char LOGNAME[] = "action_base"; | ||
|
||
ActionBase::ActionBase(const std::string& action_name, bool spin_thread, double goal_timeout, double server_timeout) | ||
: action_name_(action_name), server_timeout_(server_timeout), goal_timeout_(goal_timeout) { | ||
clientPtr_ = std::make_unique<actionlib::SimpleActionClient<grasping_msgs::GraspPlanningAction>>(nh_, action_name_, | ||
spin_thread); | ||
|
||
// Negative timeouts are set to zero | ||
server_timeout_ = server_timeout_ < std::numeric_limits<double>::epsilon() ? 0.0 : server_timeout_; | ||
goal_timeout_ = goal_timeout_ < std::numeric_limits<double>::epsilon() ? 0.0 : goal_timeout_; | ||
|
||
ROS_DEBUG_STREAM_NAMED(LOGNAME, "Waiting for connection to grasp generation action server..."); | ||
clientPtr_->waitForServer(ros::Duration(server_timeout_)); | ||
ROS_DEBUG_STREAM_NAMED(LOGNAME, "Connected to server"); | ||
} | ||
|
||
ActionBase::ActionBase(const std::string& action_name, bool spin_thread) | ||
: ActionBase::ActionBase(action_name, spin_thread, 0.0, 0.0) {} | ||
} // namespace stages | ||
} // namespace task_constructor | ||
} // namespace moveit |
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.
Uh oh!
There was an error while loading. Please reload this page.