ModelSpace
All Classes Namespaces Functions Variables Enumerations Pages
Joint.hpp
1/******************************************************************************
2* Copyright (c) ATTX LLC 2024. All Rights Reserved.
3*
4* This software and associated documentation (the "Software") are the
5* proprietary and confidential information of ATTX, LLC. The Software is
6* furnished under a license agreement between ATTX and the user organization
7* and may be used or copied only in accordance with the terms of the agreement.
8* Refer to 'license/attx_license.adoc' for standard license terms.
9*
10* EXPORT CONTROL NOTICE: THIS SOFTWARE MAY INCLUDE CONTENT CONTROLLED UNDER THE
11* INTERNATIONAL TRAFFIC IN ARMS REGULATIONS (ITAR) OR THE EXPORT ADMINISTRATION
12* REGULATIONS (EAR99). No part of the Software may be used, reproduced, or
13* transmitted in any form or by any means, for any purpose, without the express
14* written permission of ATTX, LLC.
15******************************************************************************/
16/*
17Joint header file
18
19Alex Reynolds
20*/
21#ifndef JOINT_HPP
22#define JOINT_HPP
23
24namespace clockwerk {
25
26 enum joint_type_e {
27 NOT_SET,
28 MIXED,
29 FULLY_FREE,
30 FULLY_LOCKED
31 };
32
33 /// @brief Joint class defining relationship between frames
34 ///
35 /// The joint class defines the relationship between a frame and its parent for
36 /// a given motion type (translational or rotational). It defines two matrices:
37 /// the freedom matrix, which defines whether each axis is a degree of freedom,
38 /// and the dependency matrix, which is the opposite of the freedom matrix
39 /// defined as D = I - F.
40 ///
41 /// For now, the joint class is assumed to be fully free or fully locked for simplicity.
42 /// Updating to reflect configurable degrees of freedom is a TODO
43 template <typename T>
44 class Joint {
45 public:
46 /// @brief Default constructor for the joint object
47 /// @note Assumes fully locked by default
48 Joint();
49
50 /// @brief Constructor to set joint type
51 /// @param joint_type The type of joint to use
52 Joint(joint_type_e joint_type);
53
54 /// @brief Constructor to set free axes on the joint for the object
55 /// @param x_free Bool indicating whether x should be a degree of freedom (true)
56 /// @param y_free Bool indicating whether y should be a degree of freedom (true)
57 /// @param z_free Bool indicating whether z should be a degree of freedom (true)
58 Joint(bool x_free, bool y_free, bool z_free);
59
60 /// @brief Function to set the axes free on this joint
61 /// @param x_free Bool indicating whether x should be a degree of freedom (true)
62 /// @param y_free Bool indicating whether y should be a degree of freedom (true)
63 /// @param z_free Bool indicating whether z should be a degree of freedom (true)
64 void setFreeAxes(bool x_free, bool y_free, bool z_free);
65
66 /// @brief Function to set the joint type
67 /// @param joint_type The type of joint to use
68 void setJointType(joint_type_e joint_type);
69
70 /// Functions to return freedom or dependency matrix
71 const clockwerk::Matrix<T, 3, 3>& freedom() {return _freedom;}
72 const clockwerk::Matrix<T, 3, 3>& dependency() {return _dependency;}
73
74 /// Getter/setter for joint type
75 clockwerk::joint_type_e jointType() {return _joint_type;}
76 void jointType(joint_type_e joint_type) {_joint_type = joint_type;}
77 protected:
78 joint_type_e _joint_type;
79
80 /// Freedom and dependency matrix
81 Matrix<T, 3, 3> _freedom;
82 Matrix<T, 3, 3> _dependency;
83 };
84
85 template <typename T>
86 Joint<T>::Joint()
87 : _joint_type(FULLY_LOCKED),
88 _freedom({{0.0, 0.0, 0.0}, {0.0, 0.0, 0.0}, {0.0, 0.0, 0.0}}),
89 _dependency({{1.0, 0.0, 0.0}, {0.0, 1.0, 0.0}, {0.0, 0.0, 1.0}}) {}
90
91 template <typename T>
92 Joint<T>::Joint(joint_type_e joint_type) {
93 setJointType(joint_type);
94 }
95
96 template <typename T>
97 Joint<T>::Joint(bool x_free, bool y_free, bool z_free)
98 : _freedom({{(T)x_free, 0.0, 0.0}, {0.0, (T)y_free, 0.0}, {0.0, 0.0, (T)z_free}}),
99 _dependency({{(T)!x_free, 0.0, 0.0}, {0.0, (T)!y_free, 0.0}, {0.0, 0.0, (T)!z_free}}) {
100 /// Set our joint type based on the values passed in
101 if(x_free && y_free && z_free) {
102 _joint_type = FULLY_FREE;
103 } else if(!x_free && !y_free && !z_free) {
104 _joint_type = FULLY_LOCKED;
105 } else {
106 _joint_type = MIXED;
107 }
108 }
109
110 template <typename T>
111 void Joint<T>::setFreeAxes(bool x_free, bool y_free, bool z_free) {
112 _freedom.set(0, 0, (T)x_free);
113 _freedom.set(1, 1, (T)y_free);
114 _freedom.set(2, 2, (T)z_free);
115 _dependency.set(0, 0, (T)!x_free);
116 _dependency.set(1, 1, (T)!y_free);
117 _dependency.set(2, 2, (T)!z_free);
118
119 /// Set our joint type based on the values passed in
120 if(x_free && y_free && z_free) {
121 _joint_type = FULLY_FREE;
122 } else if(!x_free && !y_free && !z_free) {
123 _joint_type = FULLY_LOCKED;
124 } else {
125 _joint_type = MIXED;
126 }
127 }
128
129 template <typename T>
130 void Joint<T>::setJointType(joint_type_e joint_type) {
131 switch(joint_type) {
132 case FULLY_FREE:
133 _freedom.set(0, 0, 1.0);
134 _freedom.set(1, 1, 1.0);
135 _freedom.set(2, 2, 1.0);
136 _dependency.set(0, 0, 0.0);
137 _dependency.set(1, 1, 0.0);
138 _dependency.set(2, 2, 0.0);
139 _joint_type = FULLY_FREE;
140 break;
141 case FULLY_LOCKED:
142 _freedom.set(0, 0, 0.0);
143 _freedom.set(1, 1, 0.0);
144 _freedom.set(2, 2, 0.0);
145 _dependency.set(0, 0, 1.0);
146 _dependency.set(1, 1, 1.0);
147 _dependency.set(2, 2, 1.0);
148 _joint_type = FULLY_LOCKED;
149 break;
150 default:
151 /// Note: this includes mixed because we do not have
152 /// enough info to set joint
153 _joint_type = NOT_SET;
154 break;
155 };
156 }
157
158}
159
160#endif
Joint class defining relationship between frames.
Definition Joint.hpp:44
Joint()
Default constructor for the joint object.
Definition Joint.hpp:86
void setFreeAxes(bool x_free, bool y_free, bool z_free)
Function to set the axes free on this joint.
Definition Joint.hpp:111
Joint(bool x_free, bool y_free, bool z_free)
Constructor to set free axes on the joint for the object.
Definition Joint.hpp:97
void setJointType(joint_type_e joint_type)
Function to set the joint type.
Definition Joint.hpp:130
Matrix< T, 3, 3 > _freedom
Freedom and dependency matrix.
Definition Joint.hpp:81
clockwerk::joint_type_e jointType()
Getter/setter for joint type.
Definition Joint.hpp:75
const clockwerk::Matrix< T, 3, 3 > & freedom()
Functions to return freedom or dependency matrix.
Definition Joint.hpp:71
Joint(joint_type_e joint_type)
Constructor to set joint type.
Definition Joint.hpp:92