control_mode.h
Go to the documentation of this file.
1 // Copyright (c) 2017 Franka Emika GmbH
2 // Use of this source code is governed by the Apache-2.0 license, see LICENSE
3 #pragma once
4 
5 #include <ostream>
6 #include <type_traits>
7 
8 namespace franka_hw {
9 
10 enum class ControlMode {
11  None = 0,
12  JointTorque = (1 << 0),
13  JointPosition = (1 << 1),
14  JointVelocity = (1 << 2),
15  CartesianVelocity = (1 << 3),
16  CartesianPose = (1 << 4),
17 };
18 
19 std::ostream& operator<<(std::ostream& ostream, ControlMode mode);
20 
21 // Implement operators for BitmaskType concept
22 constexpr ControlMode operator&(ControlMode left, ControlMode right) {
23  return static_cast<ControlMode>(static_cast<std::underlying_type_t<ControlMode>>(left) &
24  static_cast<std::underlying_type_t<ControlMode>>(right));
25 }
26 
27 constexpr ControlMode operator|(ControlMode left, ControlMode right) {
28  return static_cast<ControlMode>(static_cast<std::underlying_type_t<ControlMode>>(left) |
29  static_cast<std::underlying_type_t<ControlMode>>(right));
30 }
31 
32 constexpr ControlMode operator^(ControlMode left, ControlMode right) {
33  return static_cast<ControlMode>(static_cast<std::underlying_type_t<ControlMode>>(left) ^
34  static_cast<std::underlying_type_t<ControlMode>>(right));
35 }
36 
38  return static_cast<ControlMode>(~static_cast<std::underlying_type_t<ControlMode>>(mode));
39 }
40 
41 constexpr ControlMode& operator&=(ControlMode& left, ControlMode right) {
42  return left = left & right;
43 }
44 
45 constexpr ControlMode& operator|=(ControlMode& left, ControlMode right) {
46  return left = left | right;
47 }
48 
49 } // namespace franka_hw
franka_hw::ControlMode::None
@ None
franka_hw::ControlMode
ControlMode
Definition: control_mode.h:10
franka_hw::operator&
constexpr ControlMode operator&(ControlMode left, ControlMode right)
Definition: control_mode.h:22
franka_hw::operator&=
constexpr ControlMode & operator&=(ControlMode &left, ControlMode right)
Definition: control_mode.h:41
franka_hw::operator|
constexpr ControlMode operator|(ControlMode left, ControlMode right)
Definition: control_mode.h:27
franka_hw::operator<<
std::ostream & operator<<(std::ostream &ostream, ControlMode mode)
Definition: control_mode.cpp:12
franka_hw::ControlMode::JointVelocity
@ JointVelocity
franka_hw::operator|=
constexpr ControlMode & operator|=(ControlMode &left, ControlMode right)
Definition: control_mode.h:45
franka_hw::operator^
constexpr ControlMode operator^(ControlMode left, ControlMode right)
Definition: control_mode.h:32
franka_hw::ControlMode::CartesianVelocity
@ CartesianVelocity
franka_hw
Definition: control_mode.h:8
franka_hw::ControlMode::JointPosition
@ JointPosition
franka_hw::operator~
constexpr ControlMode operator~(ControlMode mode)
Definition: control_mode.h:37
franka_hw::ControlMode::CartesianPose
@ CartesianPose
franka_hw::ControlMode::JointTorque
@ JointTorque


franka_hw
Author(s): Franka Emika GmbH
autogenerated on Mon Sep 19 2022 02:33:21