|
From: <ei...@us...> - 2009-08-10 22:57:36
|
Revision: 21485
http://personalrobots.svn.sourceforge.net/personalrobots/?rev=21485&view=rev
Author: eitanme
Date: 2009-08-10 22:57:21 +0000 (Mon, 10 Aug 2009)
Log Message:
-----------
Moving nav_robot_actions to deprecated since it didn't seem to go through last time. Also, moving internal classes to the ActionServer outside to create smaller header files.
Modified Paths:
--------------
pkg/trunk/stacks/common/actionlib/include/actionlib/server/action_server.h
pkg/trunk/stacks/common/actionlib/include/actionlib/server/action_server_imp.h
pkg/trunk/stacks/common/actionlib/include/actionlib/server/goal_handle_imp.h
pkg/trunk/stacks/common/actionlib/include/actionlib/server/handle_tracker_deleter_imp.h
pkg/trunk/stacks/common/actionlib/include/actionlib/server/status_tracker_imp.h
Added Paths:
-----------
pkg/trunk/deprecated/nav_robot_actions/
pkg/trunk/stacks/common/actionlib/include/actionlib/server/handle_tracker_deleter.h
pkg/trunk/stacks/common/actionlib/include/actionlib/server/server_goal_handle.h
pkg/trunk/stacks/common/actionlib/include/actionlib/server/status_tracker.h
Removed Paths:
-------------
pkg/trunk/stacks/navigation/nav_robot_actions/
Modified: pkg/trunk/stacks/common/actionlib/include/actionlib/server/action_server.h
===================================================================
--- pkg/trunk/stacks/common/actionlib/include/actionlib/server/action_server.h 2009-08-10 22:56:55 UTC (rev 21484)
+++ pkg/trunk/stacks/common/actionlib/include/actionlib/server/action_server.h 2009-08-10 22:57:21 UTC (rev 21485)
@@ -46,6 +46,9 @@
#include <actionlib/RequestType.h>
#include <actionlib/enclosure_deleter.h>
#include <actionlib/action_definition.h>
+#include <actionlib/server/status_tracker.h>
+#include <actionlib/server/handle_tracker_deleter.h>
+#include <actionlib/server/server_goal_handle.h>
#include <list>
@@ -62,150 +65,16 @@
*/
template <class ActionSpec>
class ActionServer {
+ public:
+ //for convenience when referring to ServerGoalHandles
+ typedef ServerGoalHandle<ActionSpec> GoalHandle;
+
private:
//generates typedefs that we'll use to make our lives easier
ACTION_DEFINITION(ActionSpec);
- /**
- * @class StatusTracker
- * @brief A class for storing the status of each goal the action server
- * is currently working on
- */
- class StatusTracker {
- public:
- StatusTracker(const GoalID& goal_id, unsigned int status);
-
- StatusTracker(const boost::shared_ptr<const ActionGoal>& goal);
-
- boost::shared_ptr<const ActionGoal> goal_;
- boost::weak_ptr<void> handle_tracker_;
- GoalStatus status_;
- ros::Time handle_destruction_time_;
- };
-
- /**
- * @class HandleTrackerDeleter
- * @brief A class to help with tracking GoalHandles and removing goals
- * from the status list when the last GoalHandle associated with a given
- * goal is deleted.
- */
- //class to help with tracking status objects
- class HandleTrackerDeleter {
- public:
- HandleTrackerDeleter(ActionServer<ActionSpec>* as,
- typename std::list<StatusTracker>::iterator status_it);
-
- void operator()(void* ptr);
-
- private:
- ActionServer<ActionSpec>* as_;
- typename std::list<StatusTracker>::iterator status_it_;
- };
-
public:
/**
- * @class GoalHandle
- * @brief Encapsulates a state machine for a given goal that the user can
- * trigger transisions on. All ROS interfaces for the goal are managed by
- * the ActionServer to lessen the burden on the user.
- */
- class GoalHandle {
- public:
- /**
- * @brief Default constructor for a GoalHandle
- */
- GoalHandle();
-
- /** @brief Accept the goal referenced by the goal handle. This will
- * transition to the ACTIVE state or the PREEMPTING state depending
- * on whether a cancel request has been received for the goal
- */
- void setAccepted();
-
- /**
- * @brief Set the status of the goal associated with the GoalHandle to RECALLED or PREEMPTED
- * depending on what the current status of the goal is
- * @param result Optionally, the user can pass in a result to be sent to any clients of the goal
- */
- void setCanceled(const Result& result = Result());
-
- /**
- * @brief Set the status of the goal associated with the GoalHandle to rejected
- * @param result Optionally, the user can pass in a result to be sent to any clients of the goal
- */
- void setRejected(const Result& result = Result());
-
- /**
- * @brief Set the status of the goal associated with the GoalHandle to aborted
- * @param result Optionally, the user can pass in a result to be sent to any clients of the goal
- */
- void setAborted(const Result& result = Result());
-
- /**
- * @brief Set the status of the goal associated with the GoalHandle to succeeded
- * @param result Optionally, the user can pass in a result to be sent to any clients of the goal
- */
- void setSucceeded(const Result& result = Result());
-
- /**
- * @brief Send feedback to any clients of the goal associated with this GoalHandle
- * @param feedback The feedback to send to the client
- */
- void publishFeedback(const Feedback& feedback);
-
- /**
- * @brief Accessor for the goal associated with the GoalHandle
- * @return A shared_ptr to the goal object
- */
- boost::shared_ptr<const Goal> getGoal() const;
-
- /**
- * @brief Accessor for the goal id associated with the GoalHandle
- * @return The goal id
- */
- GoalID getGoalID() const;
-
- /**
- * @brief Accessor for the status associated with the GoalHandle
- * @return The goal status
- */
- GoalStatus getGoalStatus() const;
-
- /**
- * @brief Equals operator for GoalHandles
- * @param other The GoalHandle to compare to
- * @return True if the GoalHandles refer to the same goal, false otherwise
- */
- bool operator==(const GoalHandle& other);
-
- /**
- * @brief != operator for GoalHandles
- * @param other The GoalHandle to compare to
- * @return True if the GoalHandles refer to different goals, false otherwise
- */
- bool operator!=(const GoalHandle& other);
-
- private:
- /**
- * @brief A private constructor used by the ActionServer to initialize a GoalHandle
- */
- GoalHandle(typename std::list<StatusTracker>::iterator status_it,
- ActionServer<ActionSpec>* as, boost::shared_ptr<void> handle_tracker);
-
- /**
- * @brief A private method to set status to PENDING or RECALLING
- * @return True if the cancel request should be passed on to the user, false otherwise
- */
- bool setCancelRequested();
-
- typename std::list<StatusTracker>::iterator status_it_;
- boost::shared_ptr<const ActionGoal> goal_;
- ActionServer<ActionSpec>* as_;
- boost::shared_ptr<void> handle_tracker_;
- friend class ActionServer<ActionSpec>;
- };
-
- /**
* @brief Constructor for an ActionServer
* @param n A NodeHandle to create a namespace under
* @param name The name of the action
@@ -272,7 +141,7 @@
ros::Timer status_timer_;
- std::list<StatusTracker> status_list_;
+ std::list<StatusTracker<ActionSpec> > status_list_;
boost::function<void (GoalHandle)> goal_callback_;
boost::function<void (GoalHandle)> cancel_callback_;
@@ -280,14 +149,13 @@
ros::Time last_cancel_;
ros::Duration status_list_timeout_;
+ //we need to allow access to our private fields to our helper classes
+ friend class ServerGoalHandle<ActionSpec>;
+ friend class HandleTrackerDeleter<ActionSpec>;
};
};
-//Sinc all of this is templated things need to be header-based, but its still
-//nice to separate out the implementation which we'll include here
-#include <actionlib/server/status_tracker_imp.h>
-#include <actionlib/server/handle_tracker_deleter_imp.h>
-#include <actionlib/server/goal_handle_imp.h>
+//include the implementation
#include <actionlib/server/action_server_imp.h>
#endif
Modified: pkg/trunk/stacks/common/actionlib/include/actionlib/server/action_server_imp.h
===================================================================
--- pkg/trunk/stacks/common/actionlib/include/actionlib/server/action_server_imp.h 2009-08-10 22:56:55 UTC (rev 21484)
+++ pkg/trunk/stacks/common/actionlib/include/actionlib/server/action_server_imp.h 2009-08-10 22:57:21 UTC (rev 21485)
@@ -100,7 +100,7 @@
//we need to handle a cancel for the user
ROS_DEBUG("The action server has received a new cancel request");
bool goal_id_found = false;
- for(typename std::list<StatusTracker>::iterator it = status_list_.begin(); it != status_list_.end(); ++it){
+ for(typename std::list<StatusTracker<ActionSpec> >::iterator it = status_list_.begin(); it != status_list_.end(); ++it){
//check if the goal id is zero or if it is equal to the goal id of
//the iterator or if the time of the iterator warrants a cancel
if(
@@ -117,7 +117,7 @@
if((*it).handle_tracker_.expired()){
//if the handle tracker is expired, then we need to create a new one
- HandleTrackerDeleter d(this, it);
+ HandleTrackerDeleter<ActionSpec> d(this, it);
handle_tracker = boost::shared_ptr<void>((void *)NULL, d);
(*it).handle_tracker_ = handle_tracker;
@@ -138,8 +138,8 @@
//if the requested goal_id was not found, and it is non-zero, then we need to store the cancel request
if(goal_id->id != ros::Time() && !goal_id_found){
- typename std::list<StatusTracker>::iterator it = status_list_.insert(status_list_.end(),
- StatusTracker(*goal_id, GoalStatus::RECALLING));
+ typename std::list<StatusTracker<ActionSpec> >::iterator it = status_list_.insert(status_list_.end(),
+ StatusTracker<ActionSpec> (*goal_id, GoalStatus::RECALLING));
//start the timer for how long the status will live in the list without a goal handle to it
(*it).handle_destruction_time_ = ros::Time::now();
}
@@ -156,7 +156,7 @@
ROS_DEBUG("The action server has received a new goal request");
//we need to check if this goal already lives in the status list
- for(typename std::list<StatusTracker>::iterator it = status_list_.begin(); it != status_list_.end(); ++it){
+ for(typename std::list<StatusTracker<ActionSpec> >::iterator it = status_list_.begin(); it != status_list_.end(); ++it){
if(goal->goal_id.id == (*it).status_.goal_id.id){
//if this is a request for a goal that has no active handles left,
@@ -171,10 +171,10 @@
}
//if the goal is not in our list, we need to create a StatusTracker associated with this goal and push it on
- typename std::list<StatusTracker>::iterator it = status_list_.insert(status_list_.end(), StatusTracker(goal));
+ typename std::list<StatusTracker<ActionSpec> >::iterator it = status_list_.insert(status_list_.end(), StatusTracker<ActionSpec> (goal));
//we need to create a handle tracker for the incoming goal and update the StatusTracker
- HandleTrackerDeleter d(this, it);
+ HandleTrackerDeleter<ActionSpec> d(this, it);
boost::shared_ptr<void> handle_tracker((void *)NULL, d);
(*it).handle_tracker_ = handle_tracker;
@@ -205,7 +205,7 @@
status_array.set_status_list_size(status_list_.size());
unsigned int i = 0;
- for(typename std::list<StatusTracker>::iterator it = status_list_.begin(); it != status_list_.end();){
+ for(typename std::list<StatusTracker<ActionSpec> >::iterator it = status_list_.begin(); it != status_list_.end();){
status_array.status_list[i] = (*it).status_;
//check if the item is due for deletion from the status list
Modified: pkg/trunk/stacks/common/actionlib/include/actionlib/server/goal_handle_imp.h
===================================================================
--- pkg/trunk/stacks/common/actionlib/include/actionlib/server/goal_handle_imp.h 2009-08-10 22:56:55 UTC (rev 21484)
+++ pkg/trunk/stacks/common/actionlib/include/actionlib/server/goal_handle_imp.h 2009-08-10 22:57:21 UTC (rev 21485)
@@ -38,10 +38,10 @@
#define ACTIONLIB_GOAL_HANDLE_IMP_H_
namespace actionlib {
template <class ActionSpec>
- ActionServer<ActionSpec>::GoalHandle::GoalHandle(){}
+ ServerGoalHandle<ActionSpec>::ServerGoalHandle(){}
template <class ActionSpec>
- void ActionServer<ActionSpec>::GoalHandle::setAccepted(){
+ void ServerGoalHandle<ActionSpec>::setAccepted(){
ROS_DEBUG("Accepting goal, id: %.2f, stamp: %.2f", getGoalID().id.toSec(), getGoalID().stamp.toSec());
if(goal_){
unsigned int status = (*status_it_).status_.status;
@@ -61,11 +61,11 @@
(*status_it_).status_.status);
}
else
- ROS_ERROR("Attempt to set status on an uninitialized GoalHandle");
+ ROS_ERROR("Attempt to set status on an uninitialized ServerGoalHandle");
}
template <class ActionSpec>
- void ActionServer<ActionSpec>::GoalHandle::setCanceled(const Result& result){
+ void ServerGoalHandle<ActionSpec>::setCanceled(const Result& result){
ROS_DEBUG("Setting status to canceled on goal, id: %.2f, stamp: %.2f", getGoalID().id.toSec(), getGoalID().stamp.toSec());
if(goal_){
unsigned int status = (*status_it_).status_.status;
@@ -82,11 +82,11 @@
(*status_it_).status_.status);
}
else
- ROS_ERROR("Attempt to set status on an uninitialized GoalHandle");
+ ROS_ERROR("Attempt to set status on an uninitialized ServerGoalHandle");
}
template <class ActionSpec>
- void ActionServer<ActionSpec>::GoalHandle::setRejected(const Result& result){
+ void ServerGoalHandle<ActionSpec>::setRejected(const Result& result){
ROS_DEBUG("Setting status to rejected on goal, id: %.2f, stamp: %.2f", getGoalID().id.toSec(), getGoalID().stamp.toSec());
if(goal_){
unsigned int status = (*status_it_).status_.status;
@@ -99,11 +99,11 @@
(*status_it_).status_.status);
}
else
- ROS_ERROR("Attempt to set status on an uninitialized GoalHandle");
+ ROS_ERROR("Attempt to set status on an uninitialized ServerGoalHandle");
}
template <class ActionSpec>
- void ActionServer<ActionSpec>::GoalHandle::setAborted(const Result& result){
+ void ServerGoalHandle<ActionSpec>::setAborted(const Result& result){
ROS_DEBUG("Setting status to aborted on goal, id: %.2f, stamp: %.2f", getGoalID().id.toSec(), getGoalID().stamp.toSec());
if(goal_){
unsigned int status = (*status_it_).status_.status;
@@ -116,11 +116,11 @@
status);
}
else
- ROS_ERROR("Attempt to set status on an uninitialized GoalHandle");
+ ROS_ERROR("Attempt to set status on an uninitialized ServerGoalHandle");
}
template <class ActionSpec>
- void ActionServer<ActionSpec>::GoalHandle::setSucceeded(const Result& result){
+ void ServerGoalHandle<ActionSpec>::setSucceeded(const Result& result){
ROS_DEBUG("Setting status to succeeded on goal, id: %.2f, stamp: %.2f", getGoalID().id.toSec(), getGoalID().stamp.toSec());
if(goal_){
unsigned int status = (*status_it_).status_.status;
@@ -133,21 +133,21 @@
status);
}
else
- ROS_ERROR("Attempt to set status on an uninitialized GoalHandle");
+ ROS_ERROR("Attempt to set status on an uninitialized ServerGoalHandle");
}
template <class ActionSpec>
- void ActionServer<ActionSpec>::GoalHandle::publishFeedback(const Feedback& feedback){
+ void ServerGoalHandle<ActionSpec>::publishFeedback(const Feedback& feedback){
ROS_DEBUG("Publishing feedback for goal, id: %.2f, stamp: %.2f", getGoalID().id.toSec(), getGoalID().stamp.toSec());
if(goal_) {
as_->publishFeedback((*status_it_).status_, feedback);
}
else
- ROS_ERROR("Attempt to publish feedback on an uninitialized GoalHandle");
+ ROS_ERROR("Attempt to publish feedback on an uninitialized ServerGoalHandle");
}
template <class ActionSpec>
- boost::shared_ptr<const typename ActionServer<ActionSpec>::Goal> ActionServer<ActionSpec>::GoalHandle::getGoal() const{
+ boost::shared_ptr<const typename ServerGoalHandle<ActionSpec>::Goal> ServerGoalHandle<ActionSpec>::getGoal() const{
//if we have a goal that is non-null
if(goal_){
//create the deleter for our goal subtype
@@ -158,27 +158,27 @@
}
template <class ActionSpec>
- GoalID ActionServer<ActionSpec>::GoalHandle::getGoalID() const{
+ GoalID ServerGoalHandle<ActionSpec>::getGoalID() const{
if(goal_)
return (*status_it_).status_.goal_id;
else{
- ROS_ERROR("Attempt to get a goal id on an uninitialized GoalHandle");
+ ROS_ERROR("Attempt to get a goal id on an uninitialized ServerGoalHandle");
return GoalID();
}
}
template <class ActionSpec>
- GoalStatus ActionServer<ActionSpec>::GoalHandle::getGoalStatus() const{
+ GoalStatus ServerGoalHandle<ActionSpec>::getGoalStatus() const{
if(goal_)
return (*status_it_).status_;
else{
- ROS_ERROR("Attempt to get goal status on an uninitialized GoalHandle");
+ ROS_ERROR("Attempt to get goal status on an uninitialized ServerGoalHandle");
return GoalStatus();
}
}
template <class ActionSpec>
- bool ActionServer<ActionSpec>::GoalHandle::operator==(const GoalHandle& other){
+ bool ServerGoalHandle<ActionSpec>::operator==(const ServerGoalHandle& other){
if(!goal_ || !other.goal_)
return false;
GoalID my_id = getGoalID();
@@ -187,7 +187,7 @@
}
template <class ActionSpec>
- bool ActionServer<ActionSpec>::GoalHandle::operator!=(const GoalHandle& other){
+ bool ServerGoalHandle<ActionSpec>::operator!=(const ServerGoalHandle& other){
if(!goal_ || !other.goal_)
return true;
GoalID my_id = getGoalID();
@@ -196,13 +196,13 @@
}
template <class ActionSpec>
- ActionServer<ActionSpec>::GoalHandle::GoalHandle(typename std::list<StatusTracker>::iterator status_it,
+ ServerGoalHandle<ActionSpec>::ServerGoalHandle(typename std::list<StatusTracker<ActionSpec> >::iterator status_it,
ActionServer<ActionSpec>* as, boost::shared_ptr<void> handle_tracker)
: status_it_(status_it), goal_((*status_it).goal_),
as_(as), handle_tracker_(handle_tracker){}
template <class ActionSpec>
- bool ActionServer<ActionSpec>::GoalHandle::setCancelRequested(){
+ bool ServerGoalHandle<ActionSpec>::setCancelRequested(){
ROS_DEBUG("Transisitoning to a cancel requested state on goal id: %.2f, stamp: %.2f", getGoalID().id.toSec(), getGoalID().stamp.toSec());
if(goal_){
unsigned int status = (*status_it_).status_.status;
Added: pkg/trunk/stacks/common/actionlib/include/actionlib/server/handle_tracker_deleter.h
===================================================================
--- pkg/trunk/stacks/common/actionlib/include/actionlib/server/handle_tracker_deleter.h (rev 0)
+++ pkg/trunk/stacks/common/actionlib/include/actionlib/server/handle_tracker_deleter.h 2009-08-10 22:57:21 UTC (rev 21485)
@@ -0,0 +1,67 @@
+/*********************************************************************
+*
+* Software License Agreement (BSD License)
+*
+* Copyright (c) 2008, Willow Garage, 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 Willow Garage, Inc. 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 OWNER 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: Eitan Marder-Eppstein
+*********************************************************************/
+#ifndef ACTONLIB_HANDLE_TRACKER_DELETER_H_
+#define ACTONLIB_HANDLE_TRACKER_DELETER_H_
+#include <actionlib/action_definition.h>
+#include <actionlib/server/status_tracker.h>
+namespace actionlib {
+ //we need to forward declare the ActionServer class
+ template <class ActionSpec>
+ class ActionServer;
+
+ /**
+ * @class HandleTrackerDeleter
+ * @brief A class to help with tracking GoalHandles and removing goals
+ * from the status list when the last GoalHandle associated with a given
+ * goal is deleted.
+ */
+ //class to help with tracking status objects
+ template <class ActionSpec>
+ class HandleTrackerDeleter {
+ public:
+ HandleTrackerDeleter(ActionServer<ActionSpec>* as,
+ typename std::list<StatusTracker<ActionSpec> >::iterator status_it);
+
+ void operator()(void* ptr);
+
+ private:
+ ActionServer<ActionSpec>* as_;
+ typename std::list<StatusTracker<ActionSpec> >::iterator status_it_;
+ };
+};
+#include <actionlib/server/handle_tracker_deleter_imp.h>
+#endif
Modified: pkg/trunk/stacks/common/actionlib/include/actionlib/server/handle_tracker_deleter_imp.h
===================================================================
--- pkg/trunk/stacks/common/actionlib/include/actionlib/server/handle_tracker_deleter_imp.h 2009-08-10 22:56:55 UTC (rev 21484)
+++ pkg/trunk/stacks/common/actionlib/include/actionlib/server/handle_tracker_deleter_imp.h 2009-08-10 22:57:21 UTC (rev 21485)
@@ -38,12 +38,12 @@
#define ACTIONLIB_HANDLE_TRACKER_DELETER_IMP_H_
namespace actionlib {
template <class ActionSpec>
- ActionServer<ActionSpec>::HandleTrackerDeleter::HandleTrackerDeleter(ActionServer<ActionSpec>* as,
- typename std::list<typename ActionServer<ActionSpec>::StatusTracker>::iterator status_it)
+ HandleTrackerDeleter<ActionSpec>::HandleTrackerDeleter(ActionServer<ActionSpec>* as,
+ typename std::list<StatusTracker<ActionSpec> >::iterator status_it)
: as_(as), status_it_(status_it) {}
template <class ActionSpec>
- void ActionServer<ActionSpec>::HandleTrackerDeleter::operator()(void* ptr){
+ void HandleTrackerDeleter<ActionSpec>::operator()(void* ptr){
if(as_){
//make sure to lock while we erase status for this goal from the list
as_->lock_.lock();
Added: pkg/trunk/stacks/common/actionlib/include/actionlib/server/server_goal_handle.h
===================================================================
--- pkg/trunk/stacks/common/actionlib/include/actionlib/server/server_goal_handle.h (rev 0)
+++ pkg/trunk/stacks/common/actionlib/include/actionlib/server/server_goal_handle.h 2009-08-10 22:57:21 UTC (rev 21485)
@@ -0,0 +1,163 @@
+/*********************************************************************
+*
+* Software License Agreement (BSD License)
+*
+* Copyright (c) 2008, Willow Garage, 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 Willow Garage, Inc. 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 OWNER 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: Eitan Marder-Eppstein
+*********************************************************************/
+#ifndef ACTIONLIB_SERVER_GOAL_HANDLE_H_
+#define ACTIONLIB_SERVER_GOAL_HANDLE_H_
+
+#include <actionlib/GoalID.h>
+#include <actionlib/GoalStatus.h>
+#include <actionlib/action_definition.h>
+#include <actionlib/server/status_tracker.h>
+#include <boost/shared_ptr.hpp>
+
+namespace actionlib {
+ //forward declaration of ActionServer
+ template <class ActionSpec>
+ class ActionServer;
+
+ /**
+ * @class ServerGoalHandle
+ * @brief Encapsulates a state machine for a given goal that the user can
+ * trigger transisions on. All ROS interfaces for the goal are managed by
+ * the ActionServer to lessen the burden on the user.
+ */
+ template <class ActionSpec>
+ class ServerGoalHandle {
+ private:
+ //generates typedefs that we'll use to make our lives easier
+ ACTION_DEFINITION(ActionSpec);
+
+ public:
+ /**
+ * @brief Default constructor for a ServerGoalHandle
+ */
+ ServerGoalHandle();
+
+ /** @brief Accept the goal referenced by the goal handle. This will
+ * transition to the ACTIVE state or the PREEMPTING state depending
+ * on whether a cancel request has been received for the goal
+ */
+ void setAccepted();
+
+ /**
+ * @brief Set the status of the goal associated with the ServerGoalHandle to RECALLED or PREEMPTED
+ * depending on what the current status of the goal is
+ * @param result Optionally, the user can pass in a result to be sent to any clients of the goal
+ */
+ void setCanceled(const Result& result = Result());
+
+ /**
+ * @brief Set the status of the goal associated with the ServerGoalHandle to rejected
+ * @param result Optionally, the user can pass in a result to be sent to any clients of the goal
+ */
+ void setRejected(const Result& result = Result());
+
+ /**
+ * @brief Set the status of the goal associated with the ServerGoalHandle to aborted
+ * @param result Optionally, the user can pass in a result to be sent to any clients of the goal
+ */
+ void setAborted(const Result& result = Result());
+
+ /**
+ * @brief Set the status of the goal associated with the ServerGoalHandle to succeeded
+ * @param result Optionally, the user can pass in a result to be sent to any clients of the goal
+ */
+ void setSucceeded(const Result& result = Result());
+
+ /**
+ * @brief Send feedback to any clients of the goal associated with this ServerGoalHandle
+ * @param feedback The feedback to send to the client
+ */
+ void publishFeedback(const Feedback& feedback);
+
+ /**
+ * @brief Accessor for the goal associated with the ServerGoalHandle
+ * @return A shared_ptr to the goal object
+ */
+ boost::shared_ptr<const Goal> getGoal() const;
+
+ /**
+ * @brief Accessor for the goal id associated with the ServerGoalHandle
+ * @return The goal id
+ */
+ GoalID getGoalID() const;
+
+ /**
+ * @brief Accessor for the status associated with the ServerGoalHandle
+ * @return The goal status
+ */
+ GoalStatus getGoalStatus() const;
+
+ /**
+ * @brief Equals operator for ServerGoalHandles
+ * @param other The ServerGoalHandle to compare to
+ * @return True if the ServerGoalHandles refer to the same goal, false otherwise
+ */
+ bool operator==(const ServerGoalHandle& other);
+
+ /**
+ * @brief != operator for ServerGoalHandles
+ * @param other The ServerGoalHandle to compare to
+ * @return True if the ServerGoalHandles refer to different goals, false otherwise
+ */
+ bool operator!=(const ServerGoalHandle& other);
+
+ private:
+ /**
+ * @brief A private constructor used by the ActionServer to initialize a ServerGoalHandle
+ */
+ ServerGoalHandle(typename std::list<StatusTracker<ActionSpec> >::iterator status_it,
+ ActionServer<ActionSpec>* as, boost::shared_ptr<void> handle_tracker);
+
+ /**
+ * @brief A private method to set status to PENDING or RECALLING
+ * @return True if the cancel request should be passed on to the user, false otherwise
+ */
+ bool setCancelRequested();
+
+ typename std::list<StatusTracker<ActionSpec> >::iterator status_it_;
+ boost::shared_ptr<const ActionGoal> goal_;
+ ActionServer<ActionSpec>* as_;
+ boost::shared_ptr<void> handle_tracker_;
+ friend class ActionServer<ActionSpec>;
+ };
+
+};
+
+//include the implementation
+#include <actionlib/server/goal_handle_imp.h>
+
+#endif
Added: pkg/trunk/stacks/common/actionlib/include/actionlib/server/status_tracker.h
===================================================================
--- pkg/trunk/stacks/common/actionlib/include/actionlib/server/status_tracker.h (rev 0)
+++ pkg/trunk/stacks/common/actionlib/include/actionlib/server/status_tracker.h 2009-08-10 22:57:21 UTC (rev 21485)
@@ -0,0 +1,71 @@
+/*********************************************************************
+ *
+ * Software License Agreement (BSD License)
+ *
+ * Copyright (c) 2008, Willow Garage, 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 Willow Garage, Inc. 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 OWNER 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: Eitan Marder-Eppstein
+ *********************************************************************/
+#ifndef ACTIONLIB_STATUS_TRACKER_H_
+#define ACTIONLIB_STATUS_TRACKER_H_
+
+#include <actionlib/GoalID.h>
+#include <actionlib/GoalStatus.h>
+#include <actionlib/action_definition.h>
+
+namespace actionlib {
+
+ /**
+ * @class StatusTracker
+ * @brief A class for storing the status of each goal the action server
+ * is currently working on
+ */
+ template <class ActionSpec>
+ class StatusTracker {
+ private:
+ //generates typedefs that we'll use to make our lives easier
+ ACTION_DEFINITION(ActionSpec);
+
+ public:
+ StatusTracker(const GoalID& goal_id, unsigned int status);
+
+ StatusTracker(const boost::shared_ptr<const ActionGoal>& goal);
+
+ boost::shared_ptr<const ActionGoal> goal_;
+ boost::weak_ptr<void> handle_tracker_;
+ GoalStatus status_;
+ ros::Time handle_destruction_time_;
+ };
+};
+
+//include the implementation
+#include <actionlib/server/status_tracker_imp.h>
+#endif
Modified: pkg/trunk/stacks/common/actionlib/include/actionlib/server/status_tracker_imp.h
===================================================================
--- pkg/trunk/stacks/common/actionlib/include/actionlib/server/status_tracker_imp.h 2009-08-10 22:56:55 UTC (rev 21484)
+++ pkg/trunk/stacks/common/actionlib/include/actionlib/server/status_tracker_imp.h 2009-08-10 22:57:21 UTC (rev 21485)
@@ -38,14 +38,14 @@
#define ACTIONLIB_STATUS_TRACKER_IMP_H_
namespace actionlib {
template <class ActionSpec>
- ActionServer<ActionSpec>::StatusTracker::StatusTracker(const GoalID& goal_id, unsigned int status){
+ StatusTracker<ActionSpec>::StatusTracker(const GoalID& goal_id, unsigned int status){
//set the goal id and status appropriately
status_.goal_id = goal_id;
status_.status = status;
}
template <class ActionSpec>
- ActionServer<ActionSpec>::StatusTracker::StatusTracker(const boost::shared_ptr<const typename ActionServer<ActionSpec>::ActionGoal>& goal)
+ StatusTracker<ActionSpec>::StatusTracker(const boost::shared_ptr<const ActionGoal>& goal)
: goal_(goal) {
//set the goal_id from the message
status_.goal_id = goal_->goal_id;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|