include
hardware_interface
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>
44
#include <
hardware_interface/internal/hardware_resource_manager.h
>
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
62
class
JointModeHandle
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
{
89
case
JointCommandModes::BEGIN
:
90
return
"not_operational"
;
91
case
JointCommandModes::MODE_POSITION
:
92
return
"position"
;
93
case
JointCommandModes::MODE_VELOCITY
:
94
return
"velocity"
;
95
case
JointCommandModes::MODE_EFFORT
:
96
return
"effort"
;
97
case
JointCommandModes::NOMODE
:
98
return
"other"
;
99
case
JointCommandModes::EMERGENCY_STOP
:
100
return
"emergency_stop"
;
101
case
JointCommandModes::SWITCHING
:
102
return
"switching"
;
103
case
JointCommandModes::ERROR
:
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
hardware_interface::JointModeHandle::name_
std::string name_
Definition:
joint_mode_interface.h:143
hardware_interface::JointModeHandle::getModePtr
const JointCommandModes * getModePtr() const
Definition:
joint_mode_interface.h:114
hardware_interface::JointModeHandle::getModeName
std::string getModeName(JointCommandModes mode) const
Definition:
joint_mode_interface.h:117
hardware_interface::JointCommandModes
JointCommandModes
Definition:
joint_mode_interface.h:81
hardware_interface::JointCommandModes::MODE_EFFORT
@ MODE_EFFORT
hardware_interface::JointCommandModes::BEGIN
@ BEGIN
hardware_interface::JointCommandModes::SWITCHING
@ SWITCHING
hardware_interface
Definition:
actuator_command_interface.h:36
hardware_interface::JointModeHandle::mode_
JointCommandModes * mode_
Definition:
joint_mode_interface.h:142
hardware_interface::JointCommandModes::ERROR
@ ERROR
hardware_interface::JointModeHandle::setMode
void setMode(JointCommandModes mode)
Definition:
joint_mode_interface.h:112
hardware_interface::JointCommandModes::MODE_POSITION
@ MODE_POSITION
hardware_interface::JointCommandModes::EMERGENCY_STOP
@ EMERGENCY_STOP
hardware_interface::JointModeHandle::getName
std::string getName() const
Definition:
joint_mode_interface.h:110
hardware_interface::JointCommandModes::NOMODE
@ NOMODE
hardware_interface::JointModeHandle::JointModeHandle
JointModeHandle()=default
hardware_interface::JointModeInterface
Hardware interface to support changing between control modes.
Definition:
joint_mode_interface.h:147
hardware_interface::JointModeHandle::getMode
JointCommandModes getMode() const
Definition:
joint_mode_interface.h:113
hardware_interface::JointCommandModes::MODE_VELOCITY
@ MODE_VELOCITY
hardware_interface::HardwareResourceManager
Base class for handling hardware resources.
Definition:
hardware_resource_manager.h:79
hardware_resource_manager.h
hardware_interface
Author(s): Wim Meeussen, Adolfo Rodriguez Tsouroukdissian
autogenerated on Tue Oct 15 2024 02:08:19