joint_mode_interface.h
Go to the documentation of this file.
1 /*********************************************************************
2  * Software License Agreement (BSD License)
3  *
4  * Copyright (c) 2013, University of Colorado, Boulder
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 Univ of CO, Boulder 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: Dave Coleman
36  Desc: This interface is for switching a hardware interface between different controller modes
37  i.e. position, velocity, effort
38 */
39 
40 #pragma once
41 
42 
43 #include <cassert>
45 
46 namespace hardware_interface
47 {
48 
49  enum class JointCommandModes
50  {
51  BEGIN = -1,
52  MODE_POSITION = 0,
53  MODE_VELOCITY = 1,
54  MODE_EFFORT = 2,
55  NOMODE = 3,
56  EMERGENCY_STOP = 4,
57  SWITCHING = 5,
58  ERROR = 6
59  };
60 
63  {
64  public:
65  JointModeHandle() = default;
66 
68  JointModeHandle(std::string name, JointCommandModes* mode)
69  : mode_(mode)
70  , name_(name)
71  {
72  if (!mode_)
73  {
74  throw HardwareInterfaceException("Cannot create mode interface. Mode data pointer is null.");
75  }
76  }
77 
78  std::string getName() const {return name_;}
79 
80  void setMode(JointCommandModes mode) {assert(mode_); *mode_ = mode;}
81  JointCommandModes getMode() const {assert(mode_); return *mode_;}
82  const JointCommandModes* getModePtr() const {assert(mode_); return mode_;}
83 
84  // Helper function for console messages
85  std::string getModeName(JointCommandModes mode) const
86  {
87  switch(mode)
88  {
90  return "not_operational";
92  return "position";
94  return "velocity";
96  return "effort";
98  return "other";
100  return "emergency_stop";
102  return "switching";
104  return "error";
105  }
106  return "unknown";
107  }
108 
109  private:
110  JointCommandModes* mode_ = {nullptr};
111  std::string name_;
112  };
113 
115  class JointModeInterface : public HardwareResourceManager<JointModeHandle, DontClaimResources> {};
116 
117 } // namespace
void setMode(JointCommandModes mode)
An exception related to a HardwareInterface.
JointModeHandle(std::string name, JointCommandModes *mode)
const JointCommandModes * getModePtr() const
Hardware interface to support changing between control modes.
Base class for handling hardware resources.
A handle used to read and mode a single joint.
std::string getModeName(JointCommandModes mode) const


hardware_interface
Author(s): Wim Meeussen, Adolfo Rodriguez Tsouroukdissian
autogenerated on Mon Dec 7 2020 03:15:43