iMSTK
Interactive Medical Simulation Toolkit
imstkTrackingDeviceControl.h
1 /*
2 ** This file is part of the Interactive Medical Simulation Toolkit (iMSTK)
3 ** iMSTK is distributed under the Apache License, Version 2.0.
4 ** See accompanying NOTICE for details.
5 */
6 
7 #pragma once
8 
9 #include "imstkDeviceControl.h"
10 #include "imstkMath.h"
11 
12 namespace imstk
13 {
21 {
22 public:
23  enum InvertFlag
24  {
25  transX = 0x01,
26  transY = 0x02,
27  transZ = 0x04,
28  rotX = 0x08,
29  rotY = 0x10,
30  rotZ = 0x20
31  };
32 
33 protected:
34  TrackingDeviceControl(const std::string& name = "TrackingDeviceControl");
35 
36 public:
37  ~TrackingDeviceControl() override = default;
38 
42  virtual void applyForces() { }
43 
47  const Vec3d& getPosition() const;
48  void setPosition(const Vec3d& pos);
50 
54  const Quatd& getOrientation() const;;
55  void setOrientation(const Quatd& orientation);
57 
62  void setComputeVelocity(const bool computeVelocity);
63  bool getComputeVelocity() const;
65 
70  void setComputeAngularVelocity(const bool computeAngularVelocity);
71  bool getComputeAngularVelocity() const;
73 
77  const Vec3d& getAngularVelocity() const;
78  void setAngularVelocity(const Vec3d& angularVelocity);
80 
84  const Vec3d& getVelocity() const;
85  void setVelocity(const Vec3d& velocity);
87 
91  double getTranslationScaling() const;
92  void setTranslationScaling(const double scaling);
94 
98  const Vec3d& getTranslationOffset() const;
99  void setTranslationOffset(const Vec3d& t);
101 
106  const Quatd& getRotationOffset();
107  void setRotationOffset(const Quatd& r);
109 
114  const Quatd& getEffectorRotationOffset();
115  void setEffectorRotationOffset(const Quatd& r);
117 
122  unsigned char getInversionFlags();
123  void setInversionFlags(const unsigned char f);
125 
129  virtual bool updateTrackingData(const double dt);
130 
131 protected:
132  double m_scaling = 1.0;
133  Vec3d m_translationOffset = Vec3d::Zero();
134  Quatd m_rotationOffset = Quatd::Identity();
135  Quatd m_effectorRotationOffset = Quatd::Identity();
136  unsigned char m_invertFlags = 0x00;
137 
138  Vec3d m_currentPos = Vec3d::Zero();
139  Quatd m_currentOrientation = Quatd::Identity();
140  Vec3d m_currentVelocity = Vec3d::Zero();
141  Vec3d m_currentAngularVelocity = Vec3d::Zero();
142 
143  Vec3d m_currentDisplacement = Vec3d::Zero();
144  Quatd m_currentRotation = Quatd::Identity();
145 
147  bool m_computeVelocity = false;
150 };
151 } // namespace imstk
Vec3d m_translationOffset
Translation concatenated to the device translation.
virtual void applyForces()
Apply forces to the haptic device.
While the DeviceClient provides quantities from the device, the control defines what to do with those...
virtual bool updateTrackingData(const double dt)
Update tracking data.
Compound Geometry.
double m_scaling
Scaling factor for physical to virtual translations.
unsigned char m_invertFlags
Invert flags to be masked with DeviceTracker::InvertFlag.
const Vec3d & getAngularVelocity() const
Get/Set the angular velocity.
const Vec3d & getTranslationOffset() const
Get/Set the translation offset.
void setComputeAngularVelocity(const bool computeAngularVelocity)
Set/Get whether to compute the anular velocity from previous and current samples Useful if the device...
Quatd m_effectorRotationOffset
Rotation prefixed to the device rotation.
void setComputeVelocity(const bool computeVelocity)
Set/Get whether to compute the velocity from previous and current samples Useful if a device does not...
bool m_computeAngularVelocity
If true, will use current and previous rotations to produce angular velocity, if off, will ask device for angular velocity.
const Quatd & getOrientation() const
Set/Get the orientation of the tracker.
const Quatd & getRotationOffset()
Get/Set the rotation offset, this rotation is applied to the overall device coordinate system...
Quatd m_rotationOffset
Rotation concatenated to the device rotation.
Base class for all DeviceControls that track something in space (position and orientation) ...
const Vec3d & getPosition() const
Set/Get the position of the tracker.
const Quatd & getEffectorRotationOffset()
Get/Set the roation applied to the end effector, this can be used to register the device in virtual s...
bool m_computeVelocity
If true, will use current and previous positions to produce velocity, if off, will ask device for vel...
const Vec3d & getVelocity() const
Get/Set the linear velocity.
double getTranslationScaling() const
Get/Set the current scaling factor.
unsigned char getInversionFlags()
Get/Set the inversion flags, when set the corresponding axis coordinates or rotation angle will be ne...