SpatialAcceleration.cpp
Go to the documentation of this file.
1 /*
2  * RDL - Robot Dynamics Library
3  * Copyright (c) 2017 Jordan Lack <jlack1987@gmail.com>
4  *
5  * Licensed under the zlib license. See LICENSE for more details.
6  */
7 
9 
10 namespace RobotDynamics
11 {
12 namespace Math
13 {
14 void SpatialAcceleration::changeFrameWithRelativeMotion(ReferenceFramePtr newFrame, SpatialMotion twistOfCurrentFrameWithRespectToNewFrame,
15  const SpatialMotion& twistOfBodyWrtBaseExpressedInCurrent)
16 {
17  if (this->referenceFrame == newFrame)
18  {
19  return;
20  }
21 
22  referenceFrame->checkReferenceFramesMatch(twistOfCurrentFrameWithRespectToNewFrame.getReferenceFrame());
23  referenceFrame->checkReferenceFramesMatch(twistOfCurrentFrameWithRespectToNewFrame.getBodyFrame());
24  newFrame->checkReferenceFramesMatch(twistOfCurrentFrameWithRespectToNewFrame.getBaseFrame());
25 
26  checkReferenceFramesMatch(&twistOfBodyWrtBaseExpressedInCurrent);
27  bodyFrame->checkReferenceFramesMatch(twistOfBodyWrtBaseExpressedInCurrent.getBodyFrame());
28  baseFrame->checkReferenceFramesMatch(twistOfBodyWrtBaseExpressedInCurrent.getBaseFrame());
29 
30  twistOfCurrentFrameWithRespectToNewFrame %= twistOfBodyWrtBaseExpressedInCurrent;
31 
32  this->wx() += twistOfCurrentFrameWithRespectToNewFrame.wx();
33  this->wy() += twistOfCurrentFrameWithRespectToNewFrame.wy();
34  this->wz() += twistOfCurrentFrameWithRespectToNewFrame.wz();
35  this->vx() += twistOfCurrentFrameWithRespectToNewFrame.vx();
36  this->vy() += twistOfCurrentFrameWithRespectToNewFrame.vy();
37  this->vz() += twistOfCurrentFrameWithRespectToNewFrame.vz();
38 
39  this->changeFrame(newFrame);
40 }
41 
43 {
44  this->checkReferenceFramesMatch(&v);
45  this->bodyFrame->checkReferenceFramesMatch(v.baseFrame);
46 
47  this->wx() += v.wx();
48  this->wy() += v.wy();
49  this->wz() += v.wz();
50 
51  this->vx() += v.vx();
52  this->vy() += v.vy();
53  this->vz() += v.vz();
54 
55  this->bodyFrame = v.bodyFrame;
56 }
57 
59 {
61 
62  this->wx() -= v.wx();
63  this->wy() -= v.wy();
64  this->wz() -= v.wz();
65 
66  this->vx() -= v.vx();
67  this->vy() -= v.vy();
68  this->vz() -= v.vz();
69 
70  if (this->baseFrame == v.getBaseFrame())
71  {
72  this->baseFrame = v.bodyFrame;
73  }
74  else if (this->bodyFrame == v.bodyFrame)
75  {
76  this->bodyFrame = v.baseFrame;
77  }
78  else
79  {
80  throw ReferenceFrameException("Reference frame mismatch during subtraction of SpatialAccelerations!");
81  }
82 }
83 } // namespace Math
84 } // namespace RobotDynamics
ReferenceFramePtr getReferenceFrame() const
Get a pointer to the reference frame this FrameObject is expressed in.
Definition: FrameObject.hpp:52
A custom exception for frame operations.
EIGEN_STRONG_INLINE double & vz()
Get a reference to the linear-z component.
ReferenceFramePtr referenceFrame
Definition: FrameObject.hpp:81
EIGEN_STRONG_INLINE double & wx()
Get a reference to the angular-x component.
EIGEN_STRONG_INLINE double & wy()
Get a reference to the angular-y component.
void checkReferenceFramesMatch(const FrameObject *frameObject) const
Check if two ReferenceFrameHolders hold the same ReferenceFrame.
Definition: FrameObject.hpp:70
EIGEN_STRONG_INLINE double & vx()
Get a reference to the linear-x component.
std::shared_ptr< ReferenceFrame > ReferenceFramePtr
virtual void changeFrame(ReferenceFramePtr desiredFrame)
Change the ReferenceFrame this FrameObject is expressed in.
Definition: FrameObject.cpp:12
A SpatialMotion vector is a MotionVector with a RobotDynamics::ReferenceFrame it is expressed in...
void operator+=(const SpatialAcceleration &vector)
Add a SpatialAcceleration, . Frame checks are performed to ensure frame rules are adhered to...
ReferenceFramePtr getBaseFrame() const
Get a SpatialMotions SpatialMotion::baseFrame.
EIGEN_STRONG_INLINE double & wz()
Get a reference to the angular-z component.
void operator-=(const SpatialAcceleration &vector)
Subtract a SpatialAcceleration, . Frame checks are performed to ensure frame rules are adhered to...
EIGEN_STRONG_INLINE double & vy()
Get a reference to the linear-y component.
ReferenceFramePtr getBodyFrame() const
Get a SpatialMotions SpatialMotion::bodyFrame.
SpatialAcceleration. For clarity, the ReferenceFrames are stated as follows. A spatial acceleration i...
void changeFrameWithRelativeMotion(ReferenceFramePtr newFrame, SpatialMotion twistOfCurrentFrameWithRespectToNewFrame, const SpatialMotion &twistOfBodyWrtBaseExpressedInCurrent)
Use this method to change the ReferenceFrame::expressedInFrame of a SpatialAcceleration if there is r...
Namespace for all structures of the RobotDynamics library.
Definition: Body.h:21


rdl_dynamics
Author(s):
autogenerated on Tue Apr 20 2021 02:25:28