controller_manager.h
Go to the documentation of this file.
1 /*********************************************************************
2  * Software License Agreement (BSD License)
3  *
4  * Copyright (c) 2012, 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 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 /* Author: Ioan Sucan */
36 
37 #pragma once
38 
39 #include <vector>
40 #include <string>
41 #include <moveit_msgs/RobotTrajectory.h>
43 
46 {
48 struct ExecutionStatus
49 {
50  enum Value
51  {
52  UNKNOWN,
53  RUNNING,
54  SUCCEEDED,
55  PREEMPTED,
56  TIMED_OUT,
57  ABORTED,
58  FAILED
59  };
60 
61  ExecutionStatus(Value value = UNKNOWN) : status_(value)
62  {
63  }
64 
65  operator Value() const
66  {
67  return status_;
68  }
69 
70  explicit operator bool() const
71  {
72  return status_ == SUCCEEDED;
73  }
74 
76  std::string asString() const
77  {
78  switch (status_)
79  {
80  case RUNNING:
81  return "RUNNING";
82  case SUCCEEDED:
83  return "SUCCEEDED";
84  case PREEMPTED:
85  return "PREEMPTED";
86  case TIMED_OUT:
87  return "TIMED_OUT";
88  case ABORTED:
89  return "ABORTED";
90  case FAILED:
91  return "FAILED";
92  default:
93  return "UNKNOWN";
94  }
95  }
96 
97 private:
98  Value status_;
99 };
100 
101 MOVEIT_CLASS_FORWARD(MoveItControllerHandle); // Defines MoveItControllerHandlePtr, ConstPtr, WeakPtr... etc
102 
104 class MoveItControllerHandle
105 {
106 public:
108  MoveItControllerHandle(const std::string& name) : name_(name)
109  {
110  }
111 
112  virtual ~MoveItControllerHandle()
113  {
114  }
115 
117  const std::string& getName() const
118  {
119  return name_;
120  }
121 
127  virtual bool sendTrajectory(const moveit_msgs::RobotTrajectory& trajectory) = 0;
128 
133  virtual bool cancelExecution() = 0;
134 
140  virtual bool waitForExecution(const ros::Duration& timeout = ros::Duration(0)) = 0;
141 
144 
145 protected:
146  std::string name_;
147 };
148 
149 MOVEIT_CLASS_FORWARD(MoveItControllerManager); // Defines MoveItControllerManagerPtr, ConstPtr, WeakPtr... etc
150 
157 {
158 public:
161  struct ControllerState
162  {
163  ControllerState() : active_(false), default_(false)
164  {
165  }
166 
169  bool active_;
170 
173  bool default_;
174  };
175 
178  {
179  }
180 
181  virtual ~MoveItControllerManager()
182  {
183  }
184 
186  virtual MoveItControllerHandlePtr getControllerHandle(const std::string& name) = 0;
187 
189  virtual void getControllersList(std::vector<std::string>& names) = 0;
190 
195  virtual void getActiveControllers(std::vector<std::string>& names) = 0;
196 
201  virtual void getControllerJoints(const std::string& name, std::vector<std::string>& joints) = 0;
202 
204  virtual ControllerState getControllerState(const std::string& name) = 0;
205 
207  virtual bool switchControllers(const std::vector<std::string>& activate,
208  const std::vector<std::string>& deactivate) = 0;
209 };
210 } // namespace moveit_controller_manager
moveit_controller_manager
Namespace for the base class of a MoveIt controller manager.
Definition: controller_manager.h:45
moveit_controller_manager::ExecutionStatus::RUNNING
@ RUNNING
Definition: controller_manager.h:149
moveit_controller_manager::MoveItControllerManager::ControllerState::ControllerState
ControllerState()
Definition: controller_manager.h:195
moveit_controller_manager::MoveItControllerHandle::MoveItControllerHandle
MoveItControllerHandle(const std::string &name)
Each controller has a name. The handle is initialized with that name.
Definition: controller_manager.h:140
moveit_controller_manager::ExecutionStatus::PREEMPTED
@ PREEMPTED
Definition: controller_manager.h:151
moveit_controller_manager::ExecutionStatus::ABORTED
@ ABORTED
Definition: controller_manager.h:153
moveit_controller_manager::ExecutionStatus::UNKNOWN
@ UNKNOWN
Definition: controller_manager.h:148
moveit_controller_manager::MoveItControllerManager::getControllerState
virtual ControllerState getControllerState(const std::string &name)=0
Report the state of a controller, given its name.
moveit_controller_manager::MOVEIT_CLASS_FORWARD
MOVEIT_CLASS_FORWARD(MoveItControllerHandle)
moveit_controller_manager::MoveItControllerManager::getActiveControllers
virtual void getActiveControllers(std::vector< std::string > &names)=0
Get the list of active controllers.
moveit_controller_manager::MoveItControllerManager::getControllerHandle
virtual MoveItControllerHandlePtr getControllerHandle(const std::string &name)=0
Return a given named controller.
moveit_controller_manager::MoveItControllerManager::ControllerState::active_
bool active_
A controller can be active or inactive. This means that MoveIt could activate the controller when nee...
Definition: controller_manager.h:201
moveit_controller_manager::ExecutionStatus::TIMED_OUT
@ TIMED_OUT
Definition: controller_manager.h:152
class_forward.h
moveit_controller_manager::ExecutionStatus::Value
Value
Definition: controller_manager.h:114
moveit_controller_manager::MoveItControllerManager::switchControllers
virtual bool switchControllers(const std::vector< std::string > &activate, const std::vector< std::string > &deactivate)=0
Activate and deactivate controllers.
moveit_controller_manager::MoveItControllerManager::getControllersList
virtual void getControllersList(std::vector< std::string > &names)=0
Get the list of known controller names.
name
std::string name
moveit_controller_manager::ExecutionStatus::SUCCEEDED
@ SUCCEEDED
Definition: controller_manager.h:150
moveit_controller_manager::ExecutionStatus::status_
Value status_
Definition: controller_manager.h:162
moveit_controller_manager::MoveItControllerHandle::name_
std::string name_
Definition: controller_manager.h:178
moveit_controller_manager::MoveItControllerManager::MoveItControllerManager
MoveItControllerManager()
Default constructor. This needs to have no arguments so that the plugin system can construct the obje...
Definition: controller_manager.h:209
moveit_controller_manager::MoveItControllerManager::ControllerState
Each controller known to MoveIt has a state. This structure describes that controller's state.
Definition: controller_manager.h:193
moveit_controller_manager::MoveItControllerManager::~MoveItControllerManager
virtual ~MoveItControllerManager()
Definition: controller_manager.h:213
moveit_controller_manager::MoveItControllerHandle::~MoveItControllerHandle
virtual ~MoveItControllerHandle()
Definition: controller_manager.h:144
moveit_controller_manager::MoveItControllerHandle::getLastExecutionStatus
virtual ExecutionStatus getLastExecutionStatus()=0
Return the execution status of the last trajectory sent to the controller.
moveit_controller_manager::ExecutionStatus::FAILED
@ FAILED
Definition: controller_manager.h:154
moveit_controller_manager::MoveItControllerHandle::cancelExecution
virtual bool cancelExecution()=0
Cancel the execution of any motion using this controller.
moveit_controller_manager::MoveItControllerHandle::sendTrajectory
virtual bool sendTrajectory(const moveit_msgs::RobotTrajectory &trajectory)=0
Send a trajectory to the controller.
moveit_controller_manager::MoveItControllerManager
MoveIt does not enforce how controllers are implemented. To make your controllers usable by MoveIt,...
Definition: controller_manager.h:188
moveit_controller_manager::ExecutionStatus::ExecutionStatus
ExecutionStatus(Value value=UNKNOWN)
Definition: controller_manager.h:125
moveit_controller_manager::MoveItControllerHandle::waitForExecution
virtual bool waitForExecution(const ros::Duration &timeout=ros::Duration(0))=0
Wait for the current execution to complete, or until the timeout is reached.
moveit_controller_manager::MoveItControllerManager::getControllerJoints
virtual void getControllerJoints(const std::string &name, std::vector< std::string > &joints)=0
Report the joints a controller operates on, given the controller name.
ros::Duration
moveit_controller_manager::ExecutionStatus
The reported execution status.
Definition: controller_manager.h:80
moveit_controller_manager::MoveItControllerHandle::getName
const std::string & getName() const
Get the name of the controller this handle can send commands to.
Definition: controller_manager.h:149
moveit_controller_manager::MoveItControllerManager::ControllerState::default_
bool default_
It is often the case that multiple controllers could be used to execute a motion. Marking a controlle...
Definition: controller_manager.h:205
moveit_controller_manager::ExecutionStatus::asString
std::string asString() const
Convert the execution status to a string.
Definition: controller_manager.h:140


moveit_core
Author(s): Ioan Sucan , Sachin Chitta , Acorn Pooley
autogenerated on Thu Nov 21 2024 03:23:41