libfranka  0.8.0
FCI C++ API
control_tools.h
Go to the documentation of this file.
1 // Copyright (c) 2019 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 <array>
6 #include <cmath>
7 #include <string>
8 
14 namespace franka {
15 
23 inline bool isValidElbow(const std::array<double, 2>& elbow) noexcept {
24  return elbow[1] == -1.0 || elbow[1] == 1.0;
25 }
26 
34 inline bool isHomogeneousTransformation(const std::array<double, 16>& transform) noexcept {
35  constexpr double kOrthonormalThreshold = 1e-5;
36 
37  if (transform[3] != 0.0 || transform[7] != 0.0 || transform[11] != 0.0 || transform[15] != 1.0) {
38  return false;
39  }
40  for (size_t j = 0; j < 3; ++j) { // i..column
41  if (std::abs(std::sqrt(std::pow(transform[j * 4 + 0], 2) + std::pow(transform[j * 4 + 1], 2) +
42  std::pow(transform[j * 4 + 2], 2)) -
43  1.0) > kOrthonormalThreshold) {
44  return false;
45  }
46  }
47  for (size_t i = 0; i < 3; ++i) { // j..row
48  if (std::abs(std::sqrt(std::pow(transform[0 * 4 + i], 2) + std::pow(transform[1 * 4 + i], 2) +
49  std::pow(transform[2 * 4 + i], 2)) -
50  1.0) > kOrthonormalThreshold) {
51  return false;
52  }
53  }
54  return true;
55 }
56 
65 bool hasRealtimeKernel();
66 
75 bool setCurrentThreadToHighestSchedulerPriority(std::string* error_message);
76 
77 } // namespace franka
bool isHomogeneousTransformation(const std::array< double, 16 > &transform) noexcept
Determines whether the given array represents a valid homogeneous transformation matrix.
Definition: control_tools.h:34
bool isValidElbow(const std::array< double, 2 > &elbow) noexcept
Determines whether the given elbow configuration is valid or not.
Definition: control_tools.h:23
Definition: command_types.h:13
bool hasRealtimeKernel()
Determines whether the current OS kernel is a realtime kernel.
bool setCurrentThreadToHighestSchedulerPriority(std::string *error_message)
Sets the current thread to the highest possible scheduler priority.