Franky 0.12.0
A High-Level Motion API for Franka
Loading...
Searching...
No Matches
elbow_state.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <optional>
4#include <array>
5#include <iostream>
6
7namespace franky {
8
12enum class FlipDirection {
13 kNegative = -1,
14 kNeutral = 0,
15 kPositive = 1
16};
17
18std::ostream& operator<<(std::ostream& os, const FlipDirection& flip_direction);
19
28 public:
35 explicit ElbowState(double joint_3_pos, std::optional<FlipDirection> joint_4_flip = std::nullopt)
36 : joint_3_pos_(joint_3_pos), joint_4_flip_(joint_4_flip) {}
37
43 explicit ElbowState(const std::array<double, 2>& elbow_state)
44 : joint_3_pos_(elbow_state[0]),
45 joint_4_flip_([&]() -> std::optional<FlipDirection> {
46 if (elbow_state[1] < 0.0) {
48 } else if (elbow_state[1] == 0.0) {
50 } else {
52 }
53 }()) {}
54
55 ElbowState(const ElbowState&) = default;
56 ElbowState() = default;
57
64 [[nodiscard]] inline std::array<double, 2> to_array(
65 FlipDirection default_flip_direction = FlipDirection::kNegative) const {
66 return {joint_3_pos_, static_cast<double>(joint_4_flip_.value_or(default_flip_direction))};
67 }
68
72 [[nodiscard]] inline double joint_3_pos() const { return joint_3_pos_; }
73
77 [[nodiscard]] inline std::optional<FlipDirection> joint_4_flip() const { return joint_4_flip_; }
78
79 friend std::ostream& operator<<(std::ostream& os, const ElbowState& elbow_state);
80
81 private:
82 double joint_3_pos_{0.0};
83 std::optional<FlipDirection> joint_4_flip_{std::nullopt};
84};
85
86} // namespace franky
Elbow state of the robot.
Definition elbow_state.hpp:27
ElbowState(const std::array< double, 2 > &elbow_state)
Construct an elbow state from an array containing joint position and flip direction.
Definition elbow_state.hpp:43
friend std::ostream & operator<<(std::ostream &os, const ElbowState &elbow_state)
Definition elbow_state.cpp:7
std::array< double, 2 > to_array(FlipDirection default_flip_direction=FlipDirection::kNegative) const
Get the joint position and flip direction as an array.
Definition elbow_state.hpp:64
double joint_3_pos() const
The position of the 3rd joint.
Definition elbow_state.hpp:72
std::optional< FlipDirection > joint_4_flip() const
The flip direction of the 4th joint.
Definition elbow_state.hpp:77
ElbowState(double joint_3_pos, std::optional< FlipDirection > joint_4_flip=std::nullopt)
Construct an elbow state with the given joint position and optional flip direction.
Definition elbow_state.hpp:35
ElbowState()=default
ElbowState(const ElbowState &)=default
Definition dynamics_limit.cpp:8
std::ostream & operator<<(std::ostream &os, const DynamicsLimit< Vector7d > &limit)
Definition dynamics_limit.cpp:47
FlipDirection
Flip direction of a joint.
Definition elbow_state.hpp:12