ofkt_nodes.cpp
Go to the documentation of this file.
1 
34 #include <tesseract_common/utils.h>
35 
36 namespace tesseract_scene_graph
37 {
38 /*********************************************************************/
39 /*************************** BASE NODE *******************************/
40 /*********************************************************************/
41 OFKTBaseNode::OFKTBaseNode(JointType type, OFKTNode* parent, std::string link_name)
42  : type_(type), parent_(parent), link_name_(std::move(link_name))
43 {
44 }
45 
47  OFKTNode* parent,
48  std::string link_name,
49  std::string joint_name,
50  const Eigen::Isometry3d& static_tf)
51  : type_(type)
52  , parent_(parent)
53  , link_name_(std::move(link_name))
54  , joint_name_(std::move(joint_name))
55  , static_tf_(static_tf)
56  , local_tf_(static_tf)
57 {
58 }
59 
61 
63 {
64  parent_ = parent;
66 }
68 const OFKTNode* OFKTBaseNode::getParent() const { return parent_; }
69 
70 const std::string& OFKTBaseNode::getLinkName() const { return link_name_; }
71 const std::string& OFKTBaseNode::getJointName() const { return joint_name_; }
72 
73 void OFKTBaseNode::storeJointValue(double joint_value)
74 {
76  {
77  joint_value_ = joint_value;
78  joint_value_changed_ = true;
79  }
80 }
81 
82 double OFKTBaseNode::getJointValue() const { return joint_value_; }
83 
85 
86 void OFKTBaseNode::setStaticTransformation(const Eigen::Isometry3d& static_tf)
87 {
88  static_tf_ = static_tf;
91 }
92 
93 const Eigen::Isometry3d& OFKTBaseNode::getStaticTransformation() const { return static_tf_; }
94 const Eigen::Isometry3d& OFKTBaseNode::getLocalTransformation() const { return local_tf_; }
95 // LCOV_EXCL_START
96 Eigen::Isometry3d OFKTBaseNode::computeLocalTransformation(double /*joint_value*/) const
97 {
98  throw std::runtime_error("OFKTBaseNode: computeLocalTransformation should never be called!");
99 }
100 // LCOV_EXCL_STOP
101 
103 {
105  update_world_required_ = false;
106 }
107 const Eigen::Isometry3d& OFKTBaseNode::getWorldTransformation() const { return world_tf_; }
109 
110 Eigen::Matrix<double, 6, 1> OFKTBaseNode::getLocalTwist() const { return local_twist_; }
111 
113 {
114  children_.push_back(node);
115  children_const_.push_back(node);
116 }
117 
119 {
120  children_.erase(std::remove(children_.begin(), children_.end(), node), children_.end());
121  children_const_.erase(std::remove(children_const_.begin(), children_const_.end(), node), children_const_.end());
122 }
123 
124 std::vector<OFKTNode*>& OFKTBaseNode::getChildren() { return children_; }
125 
126 const std::vector<const OFKTNode*>& OFKTBaseNode::getChildren() const { return children_const_; }
127 
128 /*********************************************************************/
129 /*************************** ROOT NODE *******************************/
130 /*********************************************************************/
131 OFKTRootNode::OFKTRootNode(std::string link_name)
132  : OFKTBaseNode(tesseract_scene_graph::JointType::FIXED, nullptr, std::move(link_name))
133 {
134  update_world_required_ = false;
135 }
136 
138 {
139  throw std::runtime_error("OFKTRootNode: does not have a parent!");
140 }
141 
142 void OFKTRootNode::storeJointValue(double /*joint_value*/)
143 {
144  throw std::runtime_error("OFKTRootNode: does not have a joint value!");
145 }
146 
147 void OFKTRootNode::setStaticTransformation(const Eigen::Isometry3d& /*static_tf*/)
148 {
149  throw std::runtime_error("OFKTRootNode: does not have a static transform!");
150 }
151 
155 
156 Eigen::Isometry3d OFKTRootNode::computeLocalTransformation(double /*joint_value*/) const { return static_tf_; }
157 
158 /**********************************************************************/
159 /*************************** FIXED NODE *******************************/
160 /**********************************************************************/
162  std::string link_name,
163  std::string joint_name,
164  const Eigen::Isometry3d& static_tf)
166  parent,
167  std::move(link_name),
168  std::move(joint_name),
169  static_tf)
170 {
172 }
173 
174 void OFKTFixedNode::storeJointValue(double /*joint_value*/)
175 {
176  throw std::runtime_error("OFKTFixedNode: does not have a joint value!");
177 }
178 
179 double OFKTFixedNode::getJointValue() const { throw std::runtime_error("OFKTFixedNode: does not have a joint value!"); }
180 
181 void OFKTFixedNode::setStaticTransformation(const Eigen::Isometry3d& static_tf)
182 {
183  static_tf_ = static_tf;
184  local_tf_ = static_tf;
185  update_world_required_ = true;
186 }
187 
189 
190 Eigen::Isometry3d OFKTFixedNode::computeLocalTransformation(double /*joint_value*/) const { return local_tf_; }
191 
192 /**********************************************************************/
193 /************************* FLOATING NODE ******************************/
194 /**********************************************************************/
196  std::string link_name,
197  std::string joint_name,
198  const Eigen::Isometry3d& static_tf)
200  parent,
201  std::move(link_name),
202  std::move(joint_name),
203  static_tf)
204 {
206 }
207 
208 void OFKTFloatingNode::storeJointValue(double /*joint_value*/)
209 {
210  throw std::runtime_error("OFKTFloatingNode: does not have a joint value!");
211 }
212 
214 {
215  throw std::runtime_error("OFKTFloatingNode: does not have a joint value!");
216 }
217 
218 void OFKTFloatingNode::setStaticTransformation(const Eigen::Isometry3d& static_tf)
219 {
220  static_tf_ = static_tf;
221  local_tf_ = static_tf;
222  update_world_required_ = true;
223 }
224 
226 
227 Eigen::Isometry3d OFKTFloatingNode::computeLocalTransformation(double /*joint_value*/) const { return local_tf_; }
228 
229 /*********************************************************************/
230 /************************* REVOLUTE NODE *****************************/
231 /*********************************************************************/
233  std::string link_name,
234  std::string joint_name,
235  const Eigen::Isometry3d& static_tf,
236  const Eigen::Vector3d& axis)
238  parent,
239  std::move(link_name),
240  std::move(joint_name),
241  static_tf)
242  , axis_(axis.normalized())
243 {
244  local_twist_.tail(3) = axis_;
247 }
248 
249 void OFKTRevoluteNode::storeJointValue(double joint_value) { OFKTBaseNode::storeJointValue(joint_value); }
250 
252 {
253  joint_tf_ = Eigen::AngleAxisd(joint_value_, axis_);
255  joint_value_changed_ = false;
256 }
257 
259 
260 Eigen::Isometry3d OFKTRevoluteNode::computeLocalTransformation(double joint_value) const
261 {
262  return static_tf_ * Eigen::AngleAxisd(joint_value, axis_);
263 }
264 
265 const Eigen::Vector3d& OFKTRevoluteNode::getAxis() const { return axis_; }
266 
267 /*********************************************************************/
268 /************************ CONTINUOUS NODE ****************************/
269 /*********************************************************************/
271  std::string link_name,
272  std::string joint_name,
273  const Eigen::Isometry3d& static_tf,
274  const Eigen::Vector3d& axis)
276  parent,
277  std::move(link_name),
278  std::move(joint_name),
279  static_tf)
280  , axis_(axis.normalized())
281 {
282  local_twist_.tail(3) = axis_;
285 }
286 
288 {
289  joint_tf_ = Eigen::AngleAxisd(joint_value_, axis_);
291  joint_value_changed_ = false;
292 }
293 
295 
296 Eigen::Isometry3d OFKTContinuousNode::computeLocalTransformation(double joint_value) const
297 {
298  return static_tf_ * Eigen::AngleAxisd(joint_value, axis_);
299 }
300 
301 const Eigen::Vector3d& OFKTContinuousNode::getAxis() const { return axis_; }
302 
303 /*********************************************************************/
304 /************************* PRISMATIC NODE ****************************/
305 /*********************************************************************/
307  std::string link_name,
308  std::string joint_name,
309  const Eigen::Isometry3d& static_tf,
310  const Eigen::Vector3d& axis)
312  parent,
313  std::move(link_name),
314  std::move(joint_name),
315  static_tf)
316  , axis_(axis.normalized())
317 {
318  local_twist_.head(3) = axis_;
321 }
322 
324 {
325  joint_tf_ = Eigen::Translation3d(joint_value_ * axis_);
327  joint_value_changed_ = false;
328 }
329 
331 
332 Eigen::Isometry3d OFKTPrismaticNode::computeLocalTransformation(double joint_value) const
333 {
334  return static_tf_ * Eigen::Translation3d(joint_value * axis_);
335 }
336 
337 const Eigen::Vector3d& OFKTPrismaticNode::getAxis() const { return axis_; }
338 } // namespace tesseract_scene_graph
tesseract_scene_graph::OFKTFloatingNode::computeLocalTransformation
Eigen::Isometry3d computeLocalTransformation(double joint_value) const override
Compute the local tranformation but do not save.
Definition: ofkt_nodes.cpp:227
tesseract_scene_graph::OFKTFixedNode::getJointValue
double getJointValue() const override
Get the current joint value.
Definition: ofkt_nodes.cpp:179
JointType::REVOLUTE
@ REVOLUTE
tesseract_scene_graph::OFKTRevoluteNode::computeLocalTransformation
Eigen::Isometry3d computeLocalTransformation(double joint_value) const override
Compute the local tranformation but do not save.
Definition: ofkt_nodes.cpp:260
tesseract_scene_graph::OFKTBaseNode::children_const_
std::vector< const OFKTNode * > children_const_
Definition: ofkt_nodes.h:103
tesseract_scene_graph::OFKTBaseNode::setStaticTransformation
void setStaticTransformation(const Eigen::Isometry3d &static_tf) override
Set the static transformation.
Definition: ofkt_nodes.cpp:86
tesseract_scene_graph::OFKTContinuousNode::computeAndStoreLocalTransformation
void computeAndStoreLocalTransformation() override
Compute and save the local transformation 'L = S * J(Joint Value)'.
Definition: ofkt_nodes.cpp:294
JointType::FLOATING
@ FLOATING
tesseract_scene_graph::OFKTBaseNode::joint_tf_
Eigen::Isometry3d joint_tf_
Definition: ofkt_nodes.h:94
tesseract_scene_graph::OFKTBaseNode::children_
std::vector< OFKTNode * > children_
Definition: ofkt_nodes.h:102
tesseract_scene_graph::OFKTFloatingNode::OFKTFloatingNode
EIGEN_MAKE_ALIGNED_OPERATOR_NEW OFKTFloatingNode(OFKTNode *parent, std::string link_name, std::string joint_name, const Eigen::Isometry3d &static_tf)
Definition: ofkt_nodes.cpp:195
tesseract_scene_graph::OFKTBaseNode::joint_name_
std::string joint_name_
Definition: ofkt_nodes.h:92
utils.h
tesseract_scene_graph::OFKTFloatingNode::computeAndStoreLocalTransformation
void computeAndStoreLocalTransformation() override
Compute and save the local transformation 'L = S * J(Joint Value)'.
Definition: ofkt_nodes.cpp:225
tesseract_scene_graph::OFKTBaseNode::computeAndStoreWorldTransformation
void computeAndStoreWorldTransformation() override
Compute and store the nodes world transformation.
Definition: ofkt_nodes.cpp:102
tesseract_scene_graph::OFKTPrismaticNode::computeAndStoreLocalTransformationImpl
void computeAndStoreLocalTransformationImpl()
Definition: ofkt_nodes.cpp:323
tesseract_scene_graph::OFKTPrismaticNode::computeLocalTransformation
Eigen::Isometry3d computeLocalTransformation(double joint_value) const override
Compute the local tranformation but do not save.
Definition: ofkt_nodes.cpp:332
tesseract_common::almostEqualRelativeAndAbs
bool almostEqualRelativeAndAbs(const Eigen::Ref< const Eigen::VectorXd > &v1, const Eigen::Ref< const Eigen::VectorXd > &v2, const Eigen::Ref< const Eigen::VectorXd > &max_diff, const Eigen::Ref< const Eigen::VectorXd > &max_rel_diff)
tesseract_scene_graph::OFKTBaseNode::joint_value_
double joint_value_
Definition: ofkt_nodes.h:99
tesseract_scene_graph::OFKTRootNode::setParent
void setParent(OFKTNode *parent) override
Set the parent node.
Definition: ofkt_nodes.cpp:137
tesseract_scene_graph::OFKTBaseNode::getJointName
const std::string & getJointName() const override
Get the joint name associated with the node.
Definition: ofkt_nodes.cpp:71
joint.h
tesseract_scene_graph::OFKTBaseNode::hasJointValueChanged
bool hasJointValueChanged() const override
Indicates that the joint value has changed and that local and world transformation need to be recompu...
Definition: ofkt_nodes.cpp:84
tesseract_scene_graph::OFKTBaseNode::type_
tesseract_scene_graph::JointType type_
Definition: ofkt_nodes.h:89
tesseract_scene_graph::OFKTRootNode::computeLocalTransformation
Eigen::Isometry3d computeLocalTransformation(double joint_value) const override
Compute the local tranformation but do not save.
Definition: ofkt_nodes.cpp:156
tesseract_scene_graph::OFKTFloatingNode::storeJointValue
void storeJointValue(double joint_value) override
Set the nodes joint value if it has one.
Definition: ofkt_nodes.cpp:208
ofkt_nodes.h
A implementation of the Optimized Forward Kinematic Tree Nodes.
tesseract_scene_graph::OFKTBaseNode::getLinkName
const std::string & getLinkName() const override
Get the link name associated with the node.
Definition: ofkt_nodes.cpp:70
tesseract_scene_graph::OFKTBaseNode::getLocalTwist
Eigen::Matrix< double, 6, 1 > getLocalTwist() const override
Return the twist of the node in its local frame.
Definition: ofkt_nodes.cpp:110
tesseract_scene_graph::OFKTFixedNode::computeLocalTransformation
Eigen::Isometry3d computeLocalTransformation(double joint_value) const override
Compute the local tranformation but do not save.
Definition: ofkt_nodes.cpp:190
tesseract_scene_graph::OFKTBaseNode::getWorldTransformation
const Eigen::Isometry3d & getWorldTransformation() const override
Get the nodes world transformation.
Definition: ofkt_nodes.cpp:107
tesseract_scene_graph::OFKTBaseNode::update_world_required_
bool update_world_required_
Definition: ofkt_nodes.h:105
tesseract_scene_graph::OFKTBaseNode::static_tf_
Eigen::Isometry3d static_tf_
Definition: ofkt_nodes.h:93
tesseract_scene_graph::OFKTPrismaticNode::computeAndStoreLocalTransformation
void computeAndStoreLocalTransformation() override
Compute and save the local transformation 'L = S * J(Joint Value)'.
Definition: ofkt_nodes.cpp:330
tesseract_scene_graph::OFKTContinuousNode::OFKTContinuousNode
EIGEN_MAKE_ALIGNED_OPERATOR_NEW OFKTContinuousNode(OFKTNode *parent, std::string link_name, std::string joint_name, const Eigen::Isometry3d &static_tf, const Eigen::Vector3d &axis)
Definition: ofkt_nodes.cpp:270
tesseract_scene_graph::OFKTBaseNode::local_tf_
Eigen::Isometry3d local_tf_
Definition: ofkt_nodes.h:95
tesseract_scene_graph::OFKTContinuousNode::computeLocalTransformation
Eigen::Isometry3d computeLocalTransformation(double joint_value) const override
Compute the local tranformation but do not save.
Definition: ofkt_nodes.cpp:296
tesseract_scene_graph::OFKTBaseNode::getType
JointType getType() const override
Get the type of joint associated with the node.
Definition: ofkt_nodes.cpp:60
tesseract_scene_graph::OFKTBaseNode::link_name_
std::string link_name_
Definition: ofkt_nodes.h:91
tesseract_scene_graph::OFKTBaseNode::getParent
OFKTNode * getParent() override
Get the parent node.
Definition: ofkt_nodes.cpp:67
tesseract_scene_graph::OFKTRootNode::OFKTRootNode
EIGEN_MAKE_ALIGNED_OPERATOR_NEW OFKTRootNode(std::string link_name)
This should only be used for the root node of the tree.
Definition: ofkt_nodes.cpp:131
tesseract_scene_graph::OFKTBaseNode::getLocalTransformation
const Eigen::Isometry3d & getLocalTransformation() const override
Get the local transformation: 'L = S * J'.
Definition: ofkt_nodes.cpp:94
tesseract_scene_graph::OFKTRevoluteNode::OFKTRevoluteNode
EIGEN_MAKE_ALIGNED_OPERATOR_NEW OFKTRevoluteNode(OFKTNode *parent, std::string link_name, std::string joint_name, const Eigen::Isometry3d &static_tf, const Eigen::Vector3d &axis)
Definition: ofkt_nodes.cpp:232
tesseract_scene_graph::OFKTContinuousNode::axis_
Eigen::Vector3d axis_
Definition: ofkt_nodes.h:233
tesseract_scene_graph::OFKTBaseNode::getChildren
std::vector< OFKTNode * > & getChildren() override
Get a vector of child nodes associated with this node.
Definition: ofkt_nodes.cpp:124
tesseract_scene_graph::OFKTFixedNode::OFKTFixedNode
EIGEN_MAKE_ALIGNED_OPERATOR_NEW OFKTFixedNode(OFKTNode *parent, std::string link_name, std::string joint_name, const Eigen::Isometry3d &static_tf)
Definition: ofkt_nodes.cpp:161
tesseract_scene_graph::OFKTBaseNode
Definition: ofkt_nodes.h:41
tesseract_scene_graph::OFKTRevoluteNode::getAxis
const Eigen::Vector3d & getAxis() const
Definition: ofkt_nodes.cpp:265
tesseract_scene_graph::OFKTBaseNode::OFKTBaseNode
EIGEN_MAKE_ALIGNED_OPERATOR_NEW OFKTBaseNode(JointType type, OFKTNode *parent, std::string link_name)
Definition: ofkt_nodes.cpp:41
JointType::PRISMATIC
@ PRISMATIC
tesseract_scene_graph::OFKTRootNode::updateWorldTransformationRequired
bool updateWorldTransformationRequired() const override
Indicates if an update of the world transformation is required.
Definition: ofkt_nodes.cpp:154
tesseract_scene_graph::OFKTFixedNode::computeAndStoreLocalTransformation
void computeAndStoreLocalTransformation() override
Compute and save the local transformation 'L = S * J(Joint Value)'.
Definition: ofkt_nodes.cpp:188
tesseract_scene_graph::OFKTFloatingNode::getJointValue
double getJointValue() const override
Get the current joint value.
Definition: ofkt_nodes.cpp:213
tesseract_scene_graph::OFKTNode
The OFKT node is contains multiple trasformation which are described below.
Definition: ofkt_node.h:55
tesseract_scene_graph::OFKTBaseNode::world_tf_
Eigen::Isometry3d world_tf_
Definition: ofkt_nodes.h:96
tesseract_scene_graph::OFKTBaseNode::parent_
OFKTNode * parent_
Definition: ofkt_nodes.h:90
tesseract_scene_graph::OFKTBaseNode::removeChild
void removeChild(const OFKTNode *node) override
Remove a child node assiciated with this node.
Definition: ofkt_nodes.cpp:118
tesseract_scene_graph::OFKTBaseNode::joint_value_changed_
bool joint_value_changed_
Definition: ofkt_nodes.h:100
tesseract_scene_graph::OFKTRevoluteNode::axis_
Eigen::Vector3d axis_
Definition: ofkt_nodes.h:205
tesseract_scene_graph::OFKTBaseNode::getJointValue
double getJointValue() const override
Get the current joint value.
Definition: ofkt_nodes.cpp:82
tesseract_scene_graph::OFKTRevoluteNode::computeAndStoreLocalTransformationImpl
void computeAndStoreLocalTransformationImpl()
Definition: ofkt_nodes.cpp:251
tesseract_scene_graph::OFKTRevoluteNode::computeAndStoreLocalTransformation
void computeAndStoreLocalTransformation() override
Compute and save the local transformation 'L = S * J(Joint Value)'.
Definition: ofkt_nodes.cpp:258
tesseract_scene_graph::OFKTPrismaticNode::OFKTPrismaticNode
EIGEN_MAKE_ALIGNED_OPERATOR_NEW OFKTPrismaticNode(OFKTNode *parent, std::string link_name, std::string joint_name, const Eigen::Isometry3d &static_tf, const Eigen::Vector3d &axis)
Definition: ofkt_nodes.cpp:306
tesseract_scene_graph::OFKTBaseNode::local_twist_
Eigen::Matrix< double, 6, 1 > local_twist_
Definition: ofkt_nodes.h:97
tesseract_scene_graph::OFKTPrismaticNode::axis_
Eigen::Vector3d axis_
Definition: ofkt_nodes.h:261
tesseract_scene_graph::OFKTFloatingNode::setStaticTransformation
void setStaticTransformation(const Eigen::Isometry3d &static_tf) override
Set the static transformation.
Definition: ofkt_nodes.cpp:218
JointType::CONTINUOUS
@ CONTINUOUS
tesseract_scene_graph::OFKTContinuousNode::getAxis
const Eigen::Vector3d & getAxis() const
Definition: ofkt_nodes.cpp:301
tesseract_scene_graph::OFKTPrismaticNode::getAxis
const Eigen::Vector3d & getAxis() const
Definition: ofkt_nodes.cpp:337
tesseract_scene_graph::OFKTBaseNode::addChild
void addChild(OFKTNode *node) override
Add a child node.
Definition: ofkt_nodes.cpp:112
type
type
tesseract_scene_graph::OFKTContinuousNode::computeAndStoreLocalTransformationImpl
void computeAndStoreLocalTransformationImpl()
Definition: ofkt_nodes.cpp:287
tesseract_scene_graph::OFKTBaseNode::storeJointValue
void storeJointValue(double joint_value) override
Set the nodes joint value if it has one.
Definition: ofkt_nodes.cpp:73
tesseract_scene_graph::JointType
JointType
tesseract_scene_graph::OFKTFixedNode::storeJointValue
void storeJointValue(double joint_value) override
Set the nodes joint value if it has one.
Definition: ofkt_nodes.cpp:174
tesseract_scene_graph::OFKTBaseNode::getStaticTransformation
const Eigen::Isometry3d & getStaticTransformation() const override
Get the nodes static transformation.
Definition: ofkt_nodes.cpp:93
tesseract_scene_graph::OFKTFixedNode::setStaticTransformation
void setStaticTransformation(const Eigen::Isometry3d &static_tf) override
Set the static transformation.
Definition: ofkt_nodes.cpp:181
tesseract_scene_graph::OFKTBaseNode::computeLocalTransformation
Eigen::Isometry3d computeLocalTransformation(double joint_value) const override
Compute the local tranformation but do not save.
Definition: ofkt_nodes.cpp:96
tesseract_scene_graph::OFKTRevoluteNode::storeJointValue
void storeJointValue(double joint_value) override
Set the nodes joint value if it has one.
Definition: ofkt_nodes.cpp:249
tesseract_scene_graph::OFKTRootNode::storeJointValue
void storeJointValue(double joint_value) override
Set the nodes joint value if it has one.
Definition: ofkt_nodes.cpp:142
tesseract_scene_graph::OFKTRootNode::setStaticTransformation
void setStaticTransformation(const Eigen::Isometry3d &static_tf) override
Set the static transformation.
Definition: ofkt_nodes.cpp:147
tesseract_scene_graph::OFKTBaseNode::setParent
void setParent(OFKTNode *parent) override
Set the parent node.
Definition: ofkt_nodes.cpp:62
tesseract_scene_graph
tesseract_scene_graph::OFKTNode::getWorldTransformation
virtual const Eigen::Isometry3d & getWorldTransformation() const =0
Get the nodes world transformation.
tesseract_scene_graph::OFKTRootNode::computeAndStoreWorldTransformation
void computeAndStoreWorldTransformation() override
Compute and store the nodes world transformation.
Definition: ofkt_nodes.cpp:153
JointType::FIXED
@ FIXED
tesseract_scene_graph::OFKTRootNode::computeAndStoreLocalTransformation
void computeAndStoreLocalTransformation() override
Compute and save the local transformation 'L = S * J(Joint Value)'.
Definition: ofkt_nodes.cpp:152
tesseract_scene_graph::OFKTBaseNode::updateWorldTransformationRequired
bool updateWorldTransformationRequired() const override
Indicates if an update of the world transformation is required.
Definition: ofkt_nodes.cpp:108


tesseract_state_solver
Author(s): Levi Armstrong
autogenerated on Sun May 18 2025 03:02:10