XBotInterface  2.4.1
XBotInterface provides a generic API to model and control a robot.
ControlMode.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2016 IIT-ADVR
3  * Author: Arturo Laurenzi, Luca Muratore
4  * email: arturo.laurenzi@iit.it, luca.muratore@iit.it
5  *
6  * This program is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU Lesser General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public License
17  * along with this program. If not, see <http://www.gnu.org/licenses/>
18 */
19 
20 #ifndef __XBOT_XBOTINTERFACE_CONTROLMODE_H__
21 #define __XBOT_XBOTINTERFACE_CONTROLMODE_H__
22 
23 #include <string>
24 #include <bitset>
25 
26 namespace XBot{
27 
28  class ControlMode {
29 
30  public:
31 
41  typedef std::bitset<5> Bitset;
42 
43  ControlMode(const std::string& name = "",
44  bool position_enabled = false,
45  bool velocity_enabled = false,
46  bool effort_enabled = false,
47  bool stiffness_enabled = false,
48  bool damping_enabled = false);
49 
50 
51  bool isPositionEnabled() const;
52  bool isVelocityEnabled() const;
53  bool isEffortEnabled() const;
54  bool isStiffnessEnabled() const;
55  bool isDampingEnabled() const;
56 
57  ControlMode operator+(const ControlMode& ctrl_mode) const;
58  bool operator==(const ControlMode& ctrl_mode) const;
59 
60  const std::string& getName() const;
61 
62  static ControlMode Position();
63  static ControlMode Velocity();
64  static ControlMode Effort();
65  static ControlMode PosImpedance();
66  static ControlMode Stiffness();
67  static ControlMode Damping();
68  static ControlMode Idle();
69 
70  static ControlMode FromBitset(Bitset bitset);
71  static Bitset AsBitset(const ControlMode& ctrl_mode);
72 
73 
74 
75 
76  protected:
77 
78  private:
79 
80  std::string _name;
81 
82  bool _position_enabled;
83  bool _velocity_enabled;
84  bool _effort_enabled;
85  bool _stiffness_enabled;
86  bool _damping_enabled;
87 
88  bool setPositionEnabled(bool is_enabled);
89  bool setVelocityEnabled(bool is_enabled);
90  bool setEffortEnabled(bool is_enabled);
91  bool setStiffnessEnabled(bool is_enabled);
92  bool setDampingEnabled(bool is_enabled);
93 
94  };
95 
96 
97 
98 }
99 
100 #endif
XBot::ControlMode::isVelocityEnabled
bool isVelocityEnabled() const
Definition: ControlMode.cpp:82
XBot::ControlMode::isDampingEnabled
bool isDampingEnabled() const
Definition: ControlMode.cpp:62
XBot::ControlMode::Effort
static ControlMode Effort()
Definition: ControlMode.cpp:124
XBot::ControlMode::Bitset
std::bitset< 5 > Bitset
Representation of a control mode as a bitset.
Definition: ControlMode.h:41
XBot::ControlMode
Definition: ControlMode.h:28
XBot::ControlMode::isEffortEnabled
bool isEffortEnabled() const
Definition: ControlMode.cpp:67
XBot::ControlMode::PosImpedance
static ControlMode PosImpedance()
Definition: ControlMode.cpp:131
XBot::ControlMode::isStiffnessEnabled
bool isStiffnessEnabled() const
Definition: ControlMode.cpp:77
XBot::ControlMode::isPositionEnabled
bool isPositionEnabled() const
Definition: ControlMode.cpp:72
XBot::ControlMode::getName
const std::string & getName() const
Definition: ControlMode.cpp:223
XBot::ControlMode::Idle
static ControlMode Idle()
Definition: ControlMode.cpp:161
XBot::ControlMode::Damping
static ControlMode Damping()
Definition: ControlMode.cpp:117
XBot::ControlMode::ControlMode
ControlMode(const std::string &name="", bool position_enabled=false, bool velocity_enabled=false, bool effort_enabled=false, bool stiffness_enabled=false, bool damping_enabled=false)
Definition: ControlMode.cpp:24
XBot::ControlMode::AsBitset
static Bitset AsBitset(const ControlMode &ctrl_mode)
Definition: ControlMode.cpp:166
XBot::ControlMode::Stiffness
static ControlMode Stiffness()
Definition: ControlMode.cpp:147
XBot::ControlMode::operator==
bool operator==(const ControlMode &ctrl_mode) const
Definition: ControlMode.cpp:218
XBot::ControlMode::FromBitset
static ControlMode FromBitset(Bitset bitset)
Definition: ControlMode.cpp:178
XBot::ControlMode::operator+
ControlMode operator+(const ControlMode &ctrl_mode) const
Definition: ControlMode.cpp:42
XBot::ControlMode::Velocity
static ControlMode Velocity()
Definition: ControlMode.cpp:154
XBot
Definition: IXBotModel.h:20
XBot::ControlMode::Position
static ControlMode Position()
Definition: ControlMode.cpp:140