Skip to content

Commit 4b1fe2a

Browse files
committed
Modified when found candidates is set to true
The variable found_candidates_ is now set to true during inside feedbackCallback(). This gives time for the candidates and their costs to transfer to the local containers. When found_candidates_ was set to true is the doneCallback(), compute() would terminate before the candidate messages were received. This caused the planner to fail. However, now planning does not fail.
1 parent d74d26a commit 4b1fe2a

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

core/include/moveit/task_constructor/stages/gpd_generator.h

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545

4646
#include <memory>
4747
#include <functional>
48+
#include <iostream>
4849

4950

5051
namespace moveit {
@@ -160,9 +161,7 @@ bool DeepGraspPose<ActionSpec>::monitorGoal(){
160161

161162
// monitor timeout
162163
bool monitor_timeout = ActionBaseT::goal_timeout_ > std::numeric_limits<double>::epsilon() ? true : false;
163-
164-
double curr_time = ros::Time::now().toSec();
165-
double timeout_time = curr_time + ActionBaseT::goal_timeout_;
164+
double timeout_time = ros::Time::now().toSec() + ActionBaseT::goal_timeout_;
166165

167166
while(ActionBaseT::nh_.ok())
168167
{
@@ -172,8 +171,7 @@ bool DeepGraspPose<ActionSpec>::monitorGoal(){
172171
break;
173172
}
174173

175-
curr_time = ros::Time::now().toSec();
176-
if (curr_time > timeout_time && monitor_timeout){
174+
if (ros::Time::now().toSec() > timeout_time && monitor_timeout){
177175
ActionBaseT::clientPtr_->cancelGoal();
178176
ROS_ERROR_NAMED(LOGNAME, "Grasp pose generator time out reached");
179177
return false;
@@ -193,14 +191,14 @@ void DeepGraspPose<ActionSpec>::activeCallback(){
193191

194192
template<class ActionSpec>
195193
void DeepGraspPose<ActionSpec>::feedbackCallback(const FeedbackConstPtr &feedback){
196-
// TODO: Check if costs are positive ?
197-
198194
// each candidate should have a cost
199195
if (feedback->grasp_candidates.size() != feedback->costs.size()){
200196
ROS_ERROR_NAMED(LOGNAME, "Invalid input: each grasp candidate needs an associated cost");
201197
}
202198
else{
203-
ROS_INFO_NAMED(LOGNAME, "Grasp generated feedback received");
199+
ROS_INFO_NAMED(LOGNAME, "Grasp generated feedback received %lu candidates: ", feedback->grasp_candidates.size());
200+
201+
found_candidates_ = true;
204202

205203
grasp_candidates_.resize(feedback->grasp_candidates.size());
206204
costs_.resize(feedback->costs.size());
@@ -215,7 +213,6 @@ template<class ActionSpec>
215213
void DeepGraspPose<ActionSpec>::doneCallback(const actionlib::SimpleClientGoalState& state,
216214
const ResultConstPtr &result){
217215
if (state == actionlib::SimpleClientGoalState::SUCCEEDED){
218-
found_candidates_ = true;
219216
ROS_INFO_NAMED(LOGNAME, "Found grasp candidates (result): %s", result->grasp_state.c_str());
220217
}
221218
else{
@@ -268,7 +265,6 @@ void DeepGraspPose<ActionSpec>::compute(){
268265
if (upstream_solutions_.empty()){
269266
return;
270267
}
271-
272268
planning_scene::PlanningScenePtr scene = upstream_solutions_.pop()->end()->scene()->diff();
273269

274270
// set end effector pose
@@ -279,13 +275,13 @@ void DeepGraspPose<ActionSpec>::compute(){
279275
robot_state::RobotState& robot_state = scene->getCurrentStateNonConst();
280276
robot_state.setToDefaultValues(jmg, props.get<std::string>("pregrasp"));
281277

282-
283278
// compose/send goal
284279
composeGoal();
285280

286281
// monitor feedback/results
287282
// blocking function untill timeout reached or results received
288283
if (monitorGoal()){
284+
// ROS_WARN_NAMED(LOGNAME, "number %lu: ",grasp_candidates_.size());
289285
for(unsigned int i = 0; i < grasp_candidates_.size(); i++)
290286
{
291287
InterfaceState state(scene);

0 commit comments

Comments
 (0)