client_goal_status.h
Go to the documentation of this file.
1 /*********************************************************************
2 * Software License Agreement (BSD License)
3 *
4 * Copyright (c) 2008, Willow Garage, Inc.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 *
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above
14 * copyright notice, this list of conditions and the following
15 * disclaimer in the documentation and/or other materials provided
16 * with the distribution.
17 * * Neither the name of the Willow Garage nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 * POSSIBILITY OF SUCH DAMAGE.
33 *********************************************************************/
34 
35 #ifndef ACTIONLIB__CLIENT_GOAL_STATUS_H_
36 #define ACTIONLIB__CLIENT_GOAL_STATUS_H_
37 
38 #include <string>
39 
40 #include "actionlib/GoalStatus.h"
41 #include "ros/console.h"
42 
43 namespace actionlib
44 {
45 
52 {
53 public:
55  enum StateEnum
56  {
64  };
65 
67  {
68  state_ = state;
69  }
70 
77  ClientGoalStatus(const GoalStatus & goal_status)
78  {
79  fromGoalStatus(goal_status);
80  }
81 
86  inline bool isDone() const
87  {
88  if (state_ == PENDING || state_ == ACTIVE) {
89  return false;
90  }
91  return true;
92  }
93 
97  inline const StateEnum & operator=(const StateEnum & state)
98  {
99  state_ = state;
100  return state;
101  }
102 
106  inline bool operator==(const ClientGoalStatus & rhs) const
107  {
108  return state_ == rhs.state_;
109  }
110 
114  inline bool operator!=(const ClientGoalStatus & rhs) const
115  {
116  return !(state_ == rhs.state_);
117  }
118 
125  void fromGoalStatus(const GoalStatus & goal_status)
126  {
127  switch (goal_status.status) {
128  case GoalStatus::PREEMPTED:
130  case GoalStatus::SUCCEEDED:
132  case GoalStatus::ABORTED:
134  case GoalStatus::REJECTED:
136  default:
138  ROS_ERROR_NAMED("actionlib", "Cannot convert GoalStatus %u to ClientGoalState",
139  goal_status.status); break;
140  }
141  }
142 
147  std::string toString() const
148  {
149  switch (state_) {
150  case PENDING:
151  return "PENDING";
152  case ACTIVE:
153  return "ACTIVE";
154  case PREEMPTED:
155  return "PREEMPTED";
156  case SUCCEEDED:
157  return "SUCCEEDED";
158  case ABORTED:
159  return "ABORTED";
160  case REJECTED:
161  return "REJECTED";
162  case LOST:
163  return "LOST";
164  default:
165  ROS_ERROR_NAMED("actionlib", "BUG: Unhandled ClientGoalStatus");
166  break;
167  }
168  return "BUG-UNKNOWN";
169  }
170 
171 private:
173  ClientGoalStatus();
174 };
175 
176 } // namespace actionlib
177 
178 #endif // ACTIONLIB__CLIENT_GOAL_STATUS_H_
StateEnum
Defines the various states the Goal can be in, as perceived by the client.
The goal was preempted by either another goal, or a preempt message being sent to the action server...
The goal is currently being processed by the action server.
The goal was sent by the ActionClient, but disappeared due to some communication error.
The ActionServer refused to start processing the goal, possibly because a goal is infeasible...
The goal was aborted by the action server.
void fromGoalStatus(const GoalStatus &goal_status)
Store a GoalStatus in a ClientGoalStatus Note that the only GoalStatuses that can be converted into a...
bool isDone() const
Check if the goal is in a terminal state.
ClientGoalStatus()
Need to always specific an initial state. Thus, no empty constructor.
bool operator!=(const ClientGoalStatus &rhs) const
Straightforward enum inequality check.
#define ROS_ERROR_NAMED(name,...)
Thin wrapper around an enum in order to help interpret the client-side status of a goal request The p...
bool operator==(const ClientGoalStatus &rhs) const
Straightforward enum equality check.
The goal has yet to be processed by the action server.
The goal was achieved successfully by the action server.
const StateEnum & operator=(const StateEnum &state)
Copy the raw enum into the object.
ClientGoalStatus(const GoalStatus &goal_status)
Build a ClientGoalStatus from a GoalStatus. Note that the only GoalStatuses that can be converted int...
std::string toString() const
Stringify the enum.


actionlib
Author(s): Eitan Marder-Eppstein, Vijay Pradeep, Mikael Arguedas
autogenerated on Mon Feb 18 2019 03:59:59