Skip to content
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

Add feedback sending capability to RealtimeServerGoalHandle. #18

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions include/realtime_tools/realtime_server_goal_handle.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,25 +50,31 @@ class RealtimeServerGoalHandle

typedef actionlib::ServerGoalHandle<Action> GoalHandle;
typedef boost::shared_ptr<Result> ResultPtr;
typedef boost::shared_ptr<Feedback> FeedbackPtr;

uint8_t state_;

bool req_abort_;
bool req_succeed_;
ResultConstPtr req_result_;
FeedbackConstPtr req_feedback_;

public:
GoalHandle gh_;
ResultPtr preallocated_result_; // Preallocated so it can be used in realtime
FeedbackPtr preallocated_feedback_; // Preallocated so it can be used in realtime

RealtimeServerGoalHandle(GoalHandle &gh, const ResultPtr &preallocated_result = ResultPtr((Result*)NULL))
RealtimeServerGoalHandle(GoalHandle &gh, const ResultPtr &preallocated_result = ResultPtr((Result*)NULL), const FeedbackPtr &preallocated_feedback = FeedbackPtr((Feedback*)NULL))
: req_abort_(false),
req_succeed_(false),
gh_(gh),
preallocated_result_(preallocated_result)
preallocated_result_(preallocated_result),
preallocated_feedback_(preallocated_feedback)
{
if (!preallocated_result_)
preallocated_result_.reset(new Result);
if (!preallocated_feedback_)
preallocated_feedback_.reset(new Feedback);
}

void setAborted(ResultConstPtr result = ResultConstPtr((Result*)NULL))
Expand All @@ -89,6 +95,11 @@ class RealtimeServerGoalHandle
}
}

void setFeedback(FeedbackConstPtr feedback = FeedbackConstPtr((Feedback*)NULL))
{
req_feedback_ = feedback;
}

bool valid()
{
return gh_.getGoal() != NULL;
Expand All @@ -114,6 +125,10 @@ class RealtimeServerGoalHandle
else
gh_.setSucceeded();
}
if (req_feedback_ && gs.status == GoalStatus::ACTIVE)
{
gh_.publishFeedback(*req_feedback_);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens when req_feedback_ is NULL as per the default value of setFeedback(...)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to my test, just nothing gets published.

}
}
}
};
Expand Down