CGenericTool.h
Go to the documentation of this file.
1 //==============================================================================
2 /*
3  Software License Agreement (BSD License)
4  Copyright (c) 2003-2016, CHAI3D.
5  (www.chai3d.org)
6 
7  All rights reserved.
8 
9  Redistribution and use in source and binary forms, with or without
10  modification, are permitted provided that the following conditions
11  are met:
12 
13  * Redistributions of source code must retain the above copyright
14  notice, this list of conditions and the following disclaimer.
15 
16  * Redistributions in binary form must reproduce the above
17  copyright notice, this list of conditions and the following
18  disclaimer in the documentation and/or other materials provided
19  with the distribution.
20 
21  * Neither the name of CHAI3D nor the names of its contributors may
22  be used to endorse or promote products derived from this software
23  without specific prior written permission.
24 
25  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
28  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
29  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
30  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
31  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
32  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
33  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
35  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36  POSSIBILITY OF SUCH DAMAGE.
37 
38  \author <http://www.chai3d.org>
39  \author Francois Conti
40  \version 3.1.1 $Rev: 1869 $
41 */
42 //==============================================================================
43 
44 //------------------------------------------------------------------------------
45 #ifndef CGenericToolH
46 #define CGenericToolH
47 //------------------------------------------------------------------------------
53 #include "tools/CHapticPoint.h"
54 #include "world/CGenericObject.h"
55 #include "world/CWorld.h"
56 //------------------------------------------------------------------------------
57 
58 //------------------------------------------------------------------------------
59 namespace chai3d {
60 //------------------------------------------------------------------------------
61 
62 //==============================================================================
69 //==============================================================================
70 
71 //==============================================================================
84 //==============================================================================
86 {
87  //--------------------------------------------------------------------------
88  // CONSTRUCTOR & DESTRUCTOR:
89  //--------------------------------------------------------------------------
90 
91 public:
92 
94  cGenericTool(cWorld* a_parentWorld);
95 
97  virtual ~cGenericTool() {};
98 
99 
100  //--------------------------------------------------------------------------
101  // PUBLIC METHODS - HAPTIC DEVICE
102  //--------------------------------------------------------------------------
103 
104 public:
105 
107  void setHapticDevice(cGenericHapticDevicePtr a_hapticDevice) { if (a_hapticDevice != nullptr) { m_hapticDevice = a_hapticDevice; } }
108 
111 
113  virtual bool start();
114 
116  virtual bool stop();
117 
118 
119  //--------------------------------------------------------------------------
120  // PUBLIC METHODS - FORCE CONTROL
121  //--------------------------------------------------------------------------
122 
123 public:
124 
126  virtual void initialize();
127 
129  virtual void updateFromDevice();
130 
132  virtual void computeInteractionForces();
133 
135  virtual bool applyToDevice();
136 
138  virtual bool setForcesON();
139 
141  virtual bool setForcesOFF();
142 
143 
144  //--------------------------------------------------------------------------
145  // PUBLIC METHODS - STARTUP MODES
146  //--------------------------------------------------------------------------
147 
148 public:
149 
151  inline void setWaitForSmallForce(const bool a_value) { m_useWaitForSmallForce = a_value; }
152 
154  inline bool getWaitForSmallForce() { return (m_useWaitForSmallForce); }
155 
157  void setSmallForceThresh(const double a_smallForceThresh) { m_smallForceThresh = fabs(a_smallForceThresh); }
158 
161 
163  void setUseForceRise(const bool a_value) { m_useForceRise = a_value; if (a_value) m_forceEngaged = true; }
164 
166  bool getUseForceRise() { return (m_useForceRise); }
167 
169  void setRiseTime(const double a_riseTime) { m_forceRiseTime = fabs(a_riseTime); }
170 
172  double getRiseTime() { return (m_forceRiseTime); }
173 
174 
175  //--------------------------------------------------------------------------
176  // PUBLIC METHODS - USER SWITCH DATA
177  //--------------------------------------------------------------------------
178 
179 public:
180 
182  virtual bool getUserSwitch(const unsigned int a_switchIndex) const { return (cCheckBit(m_userSwitches, a_switchIndex)); }
183 
185  virtual void setUserSwitch(const unsigned int a_switchIndex, const bool a_value);
186 
188  virtual unsigned int getUserSwitches() const { return (m_userSwitches); }
189 
191  virtual void setUserSwitches(const unsigned int a_userSwitches);
192 
193 
194  //--------------------------------------------------------------------------
195  // PUBLIC METHODS - GRIPPER ANGLE POSITION AND ANGULAR VELOCITY
196  //--------------------------------------------------------------------------
197 
198 public:
199 
201  virtual double getGripperAngleRad() const { return (m_gripperAngle); }
202 
204  virtual void setGripperAngleRad(const double& a_gripperAngleRad);
205 
207  virtual double getGripperAngleDeg() const { return (cRadToDeg(m_gripperAngle)); }
208 
210  virtual void setGripperAngleDeg(const double& a_gripperAngleDeg);
211 
213  virtual double getGripperAngVel() const { return (m_gripperAngVel); }
214 
216  virtual void setGripperAngVel(const double& a_gripperAngVel);
217 
218 
219  //--------------------------------------------------------------------------
220  // PUBLIC METHODS - DEVICE POSITION AND VELOCITY
221  //--------------------------------------------------------------------------
222 
223 public:
224 
226  virtual cVector3d getDeviceLocalPos() const { return (m_deviceLocalPos); }
227 
229  virtual void setDeviceLocalPos(const cVector3d& a_localPos);
230 
232  void setDeviceLocalPos(const double& a_x, const double& a_y, const double& a_z) { setDeviceLocalPos(cVector3d(a_x, a_y, a_z)); }
233 
235  virtual cVector3d getDeviceGlobalPos() const { return (m_deviceGlobalPos); }
236 
238  virtual void setDeviceGlobalPos(const cVector3d& a_globalPos);
239 
241  void setDeviceGlobalPos(const double& a_x, const double& a_y, const double& a_z) { setDeviceGlobalPos(cVector3d(a_x, a_y, a_z)); }
242 
244  virtual cVector3d getDeviceLocalLinVel() const { return (m_deviceLocalLinVel); }
245 
247  virtual void setDeviceLocalLinVel(const cVector3d& a_localLinVel);
248 
250  void setDeviceLocalLinVel(const double& a_x, const double& a_y, const double& a_z) { setDeviceLocalLinVel(cVector3d(a_x, a_y, a_z)); }
251 
254 
256  virtual void setDeviceGlobalLinVel(const cVector3d& a_globalLinVel);
257 
259  void setDeviceGlobalLinVel(const double& a_x, const double& a_y, const double& a_z) { setDeviceGlobalLinVel(cVector3d(a_x, a_y, a_z)); }
260 
261 
262  //--------------------------------------------------------------------------
263  // PUBLIC METHODS - DEVICE ROTATION AND ANGULAR VELOCITY
264  //--------------------------------------------------------------------------
265 
266 public:
267 
269  virtual cMatrix3d getDeviceLocalRot() const { return (m_deviceLocalRot); }
270 
272  virtual void setDeviceLocalRot(const cMatrix3d& a_localRot);
273 
275  virtual void setDeviceGlobalRot(const cMatrix3d& a_globalRot);
276 
278  virtual cMatrix3d getDeviceGlobalRot() const { return (m_deviceGlobalRot); }
279 
281  virtual cVector3d getDeviceLocalAngVel() const { return (m_deviceLocalAngVel); }
282 
284  virtual void setDeviceLocalAngVel(const cVector3d& a_localAngVel);
285 
287  void setDeviceLocalAngVel(const double& a_x, const double& a_y, const double& a_z) { setDeviceLocalAngVel(cVector3d(a_x, a_y, a_z)); }
288 
291 
293  virtual void setDeviceGlobalAngVel(const cVector3d& a_globalAngVel);
294 
296  void setDeviceGlobalAngVel(const double& a_x, const double& a_y, const double& a_z) { setDeviceGlobalAngVel(cVector3d(a_x, a_y, a_z)); }
297 
298 
299  //--------------------------------------------------------------------------
300  // PUBLIC METHODS - DEVICE POSITION AND ROTATION TRANSFORM
301  //--------------------------------------------------------------------------
302 
303 public:
304 
307 
309  virtual void setDeviceLocalTransform(const cTransform& a_localTransform);
310 
313 
315  virtual void setDeviceGlobalTransform(const cTransform& a_globalTransform);
316 
317 
318  //--------------------------------------------------------------------------
319  // PUBLIC METHODS - GRIPPER FORCE
320  //--------------------------------------------------------------------------
321 
322 public:
323 
325  virtual double getGripperForce() const { return (m_gripperForce); }
326 
328  virtual void setGripperForce(const double& a_gripperForce);
329 
331  virtual void addGripperForce(const double& a_gripperForce);
332 
333 
334  //--------------------------------------------------------------------------
335  // PUBLIC METHODS - DEVICE FORCE
336  //--------------------------------------------------------------------------
337 
338 public:
339 
341  virtual cVector3d getDeviceLocalForce() const { return (m_deviceLocalForce); }
342 
344  virtual void setDeviceLocalForce(const cVector3d& a_localForce);
345 
347  void setDeviceLocalForce(const double& a_x, const double& a_y, const double& a_z) { setDeviceLocalForce(cVector3d(a_x, a_y, a_z)); }
348 
350  virtual void addDeviceLocalForce(const cVector3d& a_localForce);
351 
353  void addDeviceLocalForce(const double& a_x, const double& a_y, const double& a_z) { addDeviceLocalForce(cVector3d(a_x, a_y, a_z)); }
354 
356  virtual cVector3d getDeviceGlobalForce() const { return (m_deviceGlobalForce); }
357 
359  virtual void setDeviceGlobalForce(const cVector3d& a_globalForce);
360 
362  void setDeviceGlobalForce(const double& a_x, const double& a_y, const double& a_z) { setDeviceGlobalForce(cVector3d(a_x, a_y, a_z)); }
363 
365  virtual void addDeviceGlobalForce(const cVector3d& a_globalForce);
366 
368  void addDeviceGlobalForce(const double& a_x, const double& a_y, const double& a_z) { addDeviceGlobalForce(cVector3d(a_x, a_y, a_z)); }
369 
370 
371  //--------------------------------------------------------------------------
372  // PUBLIC METHODS - DEVICE TORQUE
373  //--------------------------------------------------------------------------
374 
375 public:
376 
378  virtual cVector3d getDeviceLocalTorque() const { return (m_deviceLocalTorque); }
379 
381  virtual void setDeviceLocalTorque(const cVector3d& a_localTorque);
382 
384  void setDeviceLocalTorque(const double& a_x, const double& a_y, const double& a_z) { setDeviceLocalTorque(cVector3d(a_x, a_y, a_z)); }
385 
387  virtual void addDeviceLocalTorque(const cVector3d& a_localTorque);
388 
390  void addDeviceLocalTorque(const double& a_x, const double& a_y, const double& a_z) { addDeviceLocalTorque(cVector3d(a_x, a_y, a_z)); }
391 
394 
396  virtual void setDeviceGlobalTorque(const cVector3d& a_globalTorque);
397 
399  void setDeviceGlobalTorque(const double& a_x, const double& a_y, const double& a_z) { setDeviceGlobalTorque(cVector3d(a_x, a_y, a_z)); }
400 
402  virtual void addDeviceGlobalTorque(const cVector3d& a_globalTorque);
403 
405  void addDeviceGlobalTorque(const double& a_x, const double& a_y, const double& a_z) { addDeviceGlobalTorque(cVector3d(a_x, a_y, a_z)); }
406 
407 
408  //--------------------------------------------------------------------------
409  // PUBLIC METHODS - WORKSPACE SETTINGS
410  //--------------------------------------------------------------------------
411 
412 public:
413 
415  bool setWorkspaceRadius(const double& a_workspaceRadius);
416 
418  double getWorkspaceRadius() { return(m_workspaceRadius); }
419 
421  bool setWorkspaceScaleFactor(const double& a_workspaceScaleFactor);
422 
425 
426 
427  //--------------------------------------------------------------------------
428  // PUBLIC METHODS - HAPTIC POINTS
429  //--------------------------------------------------------------------------
430 
431 public:
432 
434  virtual bool isInContact(cGenericObject* a_object);
435 
437  int getNumHapticPoints() { return (int)(m_hapticPoints.size()); }
438 
440  cHapticPoint* getHapticPoint(int a_index) { return (m_hapticPoints[a_index]); }
441 
443  virtual void setRadius(double a_radius);
444 
446  virtual void setRadius(double a_radiusDisplay, double a_radiusContact);
447 
449  virtual void setRadiusContact(double a_radiusContact);
450 
452  virtual void setRadiusDisplay(double a_radiusDisplay);
453 
455  virtual void setShowContactPoints(bool a_showProxy = true,
456  bool a_showGoal = false,
457  cColorf a_colorLine = cColorf(0.5, 0.5, 0.5));
458 
459 
460  //--------------------------------------------------------------------------
461  // PUBLIC METHODS - WORLD
462  //--------------------------------------------------------------------------
463 
464 public:
465 
468 
470  virtual void enableDynamicObjects(bool a_enabled);
471 
472 
473  //--------------------------------------------------------------------------
474  // PUBLIC METHODS - AUDIO
475  //--------------------------------------------------------------------------
476 
477 public:
478 
480  bool createAudioSource(cAudioDevice* a_audioDevice);
481 
482 
483  //--------------------------------------------------------------------------
484  // PUBLIC METHODS - GRAPHIC REPRESENTATION
485  //--------------------------------------------------------------------------
486 
487 public:
488 
490  virtual void render(cRenderOptions& a_options) {};
491 
492 
493  //--------------------------------------------------------------------------
494  // PUBLIC MEMBERS
495  //--------------------------------------------------------------------------
496 
497 public:
498 
501 
502 
503  //--------------------------------------------------------------------------
504  // PROTECTED MEMBERS - HAPTIC POINTS
505  //--------------------------------------------------------------------------
506 
507 protected:
508 
510  std::vector <cHapticPoint*> m_hapticPoints;
511 
512 
513  //--------------------------------------------------------------------------
514  // PROTECTED MEMBERS - HAPTIC DEVICE
515  //--------------------------------------------------------------------------
516 
517 protected:
518 
521 
523  unsigned int m_userSwitches;
524 
526  bool m_enabled;
527 
528 
529  //--------------------------------------------------------------------------
530  // PROTECTED MEMBERS - FORCE DATA
531  //--------------------------------------------------------------------------
532 
533 protected:
534 
537 
540 
543 
546 
549 
550 
551  //--------------------------------------------------------------------------
552  // PROTECTED MEMBERS - TOOL POSE AND WORKSPACE SETTINGS
553  //--------------------------------------------------------------------------
554 
555 protected:
556 
559 
562 
565 
568 
571 
574 
577 
580 
583 
586 
589 
592 
593 
594  //--------------------------------------------------------------------------
595  // PROTECTED MEMBERS - INTERNAL
596  //--------------------------------------------------------------------------
597 
598 protected:
599 
602 
604  bool m_forceOn;
605 
608 
611 
614 
617 
620 
623 
626 
629 
632 
635 
638 
639 
640  //--------------------------------------------------------------------------
641  // PROTECTED METHODS:
642  //--------------------------------------------------------------------------
643 
644 protected:
645 
646 
648  virtual void updateToolImagePosition();
649 
651  virtual void updateGlobalPositions(const bool a_frameOnly);
652 };
653 
654 //------------------------------------------------------------------------------
655 } // namespace chai3d
656 //------------------------------------------------------------------------------
657 
658 //------------------------------------------------------------------------------
659 #endif
660 //------------------------------------------------------------------------------
This class implements a 3D vector.
Definition: CVector3d.h:88
double getWorkspaceScaleFactor()
This method returns the current workspace scale factor between the haptic device and the tool...
Definition: CGenericTool.h:424
double cRadToDeg(const double &a_angleRad)
This function converts an angle from radians to degrees.
Definition: CMaths.h:651
This structures provide a containers for storing rendering options that are passed through the sceneg...
Definition: CRenderOptions.h:82
virtual bool applyToDevice()
This method sends the latest computed interaction force, torque, and gripper force to the haptic devi...
Definition: CGenericTool.cpp:869
bool getUseForceRise()
This method returns the status about force rising mode.
Definition: CGenericTool.h:166
virtual void addDeviceLocalTorque(const cVector3d &a_localTorque)
This method adds a torque to the currently computed torque expressed in device local coordinates...
Definition: CGenericTool.cpp:572
virtual void setDeviceLocalTorque(const cVector3d &a_localTorque)
This method overrides the current torque expressed in device local coordinates.
Definition: CGenericTool.cpp:557
This class implements a haptic point on a tool.
Definition: CHapticPoint.h:97
virtual cVector3d getDeviceLocalLinVel() const
This method returns the linear velocity of the device expressed in device local coordinates.
Definition: CGenericTool.h:244
virtual void addDeviceGlobalTorque(const cVector3d &a_globalTorque)
This method adds a torque to the currently computed torque expressed in world coordinates.
Definition: CGenericTool.cpp:601
virtual void render(cRenderOptions &a_options)
This method renders the tool graphically using OpenGL.
Definition: CGenericTool.h:490
virtual void updateToolImagePosition()
This method updates the position and orientation of the tool image.
Definition: CGenericTool.cpp:808
virtual double getGripperAngVel() const
This method returns the angular velocity in radians per second of the gripper.
Definition: CGenericTool.h:213
virtual cVector3d getDeviceGlobalTorque() const
This method returns the currently computed torque expressed in world coordinates. ...
Definition: CGenericTool.h:393
virtual bool setForcesON()
This method enables forces to the haptic device.
Definition: CGenericTool.cpp:1003
virtual bool stop()
This method stops communication with the haptic device.
Definition: CGenericTool.cpp:663
virtual void setGripperAngleRad(const double &a_gripperAngleRad)
This method overrides the angle in radians of the gripper.
Definition: CGenericTool.cpp:271
cMatrix3d m_deviceGlobalRot
Orientation of the haptic device in world global coordinates.
Definition: CGenericTool.h:573
virtual ~cGenericTool()
Destructor of cGenericTool.
Definition: CGenericTool.h:97
int m_smallForceCounter
Counter which waits for up to several cycles of "small forces" before enabling force.
Definition: CGenericTool.h:613
virtual bool start()
This method starts communication with the haptic device and initializes the tool. ...
Definition: CGenericTool.cpp:617
cPrecisionClock m_forceRiseClock
Clock to measure force rise.
Definition: CGenericTool.h:625
void setDeviceLocalForce(const double &a_x, const double &a_y, const double &a_z)
This method overrides the current force expressed in device or tool local coordinates.
Definition: CGenericTool.h:347
void setDeviceGlobalPos(const double &a_x, const double &a_y, const double &a_z)
This method overrides the position of the haptic device expressed in world global coordinates...
Definition: CGenericTool.h:241
double m_gripperAngVel
Gripper angular velocity in radians per second.
Definition: CGenericTool.h:591
void setDeviceLocalTorque(const double &a_x, const double &a_y, const double &a_z)
This method overrides the current torque expressed in device local coordinates.
Definition: CGenericTool.h:384
This class implements a high precision clock.
Definition: CPrecisionClock.h:85
bool setWorkspaceRadius(const double &a_workspaceRadius)
This method set the translational virtual workspace dimensions in which tool will be working...
Definition: CGenericTool.cpp:1086
double m_workspaceScaleFactor
Scale factor applied between the workspaces of the haptic device and the tool.
Definition: CGenericTool.h:561
double getWorkspaceRadius()
This method returns the radius of the workspace of the tool.
Definition: CGenericTool.h:418
void setHapticDevice(cGenericHapticDevicePtr a_hapticDevice)
This method define a haptic device that will control this tool.
Definition: CGenericTool.h:107
cFrequencyCounter m_freqRead
Frequency counter to measure how often data is read from haptic device.
Definition: CGenericTool.h:634
bool m_enabled
If true then the tool has been started and is enabled. false otherwise.
Definition: CGenericTool.h:526
virtual void setShowContactPoints(bool a_showProxy=true, bool a_showGoal=false, cColorf a_colorLine=cColorf(0.5, 0.5, 0.5))
This method sets the display properties of all haptic points.
Definition: CGenericTool.cpp:201
virtual cVector3d getDeviceGlobalForce() const
This method returns the currently computed force expressed in world coordinates.
Definition: CGenericTool.h:356
virtual double getGripperAngleDeg() const
This method returns the angle in degrees of the gripper.
Definition: CGenericTool.h:207
virtual void addDeviceLocalForce(const cVector3d &a_localForce)
This method adds a force to the currently computed force expressed in device or tool local coordinate...
Definition: CGenericTool.cpp:514
void addDeviceGlobalTorque(const double &a_x, const double &a_y, const double &a_z)
This method adds a torque to the curently computed torque expressed in world coordinates.
Definition: CGenericTool.h:405
cWorld * getParentWorld()
This method returns the parent world of this tool.
Definition: CGenericTool.h:467
cVector3d m_deviceGlobalPos
Position of the haptic device in world global coordinates.
Definition: CGenericTool.h:567
virtual cVector3d getDeviceLocalPos() const
This method returns the position of the haptic device expressed in device local coordinates.
Definition: CGenericTool.h:226
virtual void setRadiusContact(double a_radiusContact)
This method sets the radius size of the of the physical proxy used in all haptic points.
Definition: CGenericTool.cpp:165
virtual void computeInteractionForces()
This method computes all interaction forces between the tool's haptic points and the virtual environm...
Definition: CGenericTool.cpp:825
virtual void setRadius(double a_radius)
This method sets the radius size of all haptic points.
Definition: CGenericTool.cpp:124
This class implements a base class for modeling haptic tools.
Definition: CGenericTool.h:85
cGenericTool(cWorld *a_parentWorld)
Constructor of cGenericTool.
Definition: CGenericTool.cpp:60
cWorld * m_parentWorld
Parent world of tool.
Definition: CGenericTool.h:601
virtual void setDeviceLocalForce(const cVector3d &a_localForce)
This method overrides the current force expressed in device or tool local coordinates.
Definition: CGenericTool.cpp:499
void setDeviceGlobalForce(const double &a_x, const double &a_y, const double &a_z)
This method overrides the current force expressed in world coordinates.
Definition: CGenericTool.h:362
This class implements a virtual world.
Definition: CWorld.h:92
void setDeviceGlobalAngVel(const double &a_x, const double &a_y, const double &a_z)
This method overrides the angular velocity of the device expressed in world global coordinates...
Definition: CGenericTool.h:296
Implements a base class for haptic devices.
This class implements a frequency counter.
Definition: CFrequencyCounter.h:85
bool m_useWaitForSmallForce
The flag indicates if the device should wait for a small commanded force before engaging forces...
Definition: CGenericTool.h:610
virtual void setDeviceGlobalForce(const cVector3d &a_globalForce)
This method overrides the current force expressed in world coordinates.
Definition: CGenericTool.cpp:528
cVector3d m_deviceGlobalAngVel
Angular velocity of the haptic device in world global coordinates.
Definition: CGenericTool.h:585
Implements a base class for programming collision detectors that identify intersections between segme...
This class implements a base class for all 2D or 3D objects in CHAI3D.
Definition: CGenericObject.h:112
virtual void setDeviceGlobalPos(const cVector3d &a_globalPos)
This method overrides the position of the haptic device expressed in world global coordinates...
Definition: CGenericTool.cpp:327
This class implements a 3D matrix.
Definition: CMatrix3d.h:97
cVector3d m_deviceLocalPos
Position of the haptic device in device local coordinates.
Definition: CGenericTool.h:564
cVector3d m_deviceLocalForce
Currently computed interaction force [N] in device or tool local coordinates.
Definition: CGenericTool.h:536
This class implements a 4D transformation matrix encoded as column-major.
Definition: CTransform.h:75
Implementation of a virtual world.
virtual void setUserSwitch(const unsigned int a_switchIndex, const bool a_value)
This method overrides the status of a selected user switch.
Definition: CGenericTool.cpp:245
double m_gripperAngle
Gripper angle in radians.
Definition: CGenericTool.h:588
bool getWaitForSmallForce()
This method returns the status about waiting for small small forces to appear before sending them to ...
Definition: CGenericTool.h:154
std::shared_ptr< cGenericHapticDevice > cGenericHapticDevicePtr
Definition: CGenericHapticDevice.h:258
virtual bool setForcesOFF()
This method disables forces to the haptic device.
Definition: CGenericTool.cpp:1033
void setSmallForceThresh(const double a_smallForceThresh)
This method sets the force threshold required to engage forces when setWaitForSmallForce() is enabled...
Definition: CGenericTool.h:157
std::vector< cHapticPoint * > m_hapticPoints
Haptic points that describe the tool.
Definition: CGenericTool.h:510
Implements a finger-proxy force rendering algorithm.
void addDeviceLocalForce(const double &a_x, const double &a_y, const double &a_z)
This method adds a force to the currently computed force expressed in device or tool local coordinate...
Definition: CGenericTool.h:353
bool m_forceEngaged
This flag is used to avoid initial bumps in force (has the user sent a small force yet...
Definition: CGenericTool.h:607
double m_forceRiseTime
Force rising time in seconds.
Definition: CGenericTool.h:622
virtual cVector3d getDeviceGlobalPos() const
This method returns the position of the haptic device expressed in world global coordinates.
Definition: CGenericTool.h:235
void addDeviceLocalTorque(const double &a_x, const double &a_y, const double &a_z)
This method adds a torque to the currently computed torque expressed in device local coordinates...
Definition: CGenericTool.h:390
cGenericHapticDevicePtr getHapticDevice()
This method returns a pointer to the haptic device that is controlling this tool. ...
Definition: CGenericTool.h:110
virtual void setGripperAngVel(const double &a_gripperAngVel)
This method overrides the angular velocity of the gripper in radians per second.
Definition: CGenericTool.cpp:298
Implements a base class for all objects.
Implements a haptic point on a tool.
virtual cMatrix3d getDeviceLocalRot() const
This method returns the orientation of the haptic device expressed in device local coordinates...
Definition: CGenericTool.h:269
void setDeviceLocalAngVel(const double &a_x, const double &a_y, const double &a_z)
This method overrides the angular velocity of the device expressed in device local coordinates...
Definition: CGenericTool.h:287
virtual void setDeviceGlobalLinVel(const cVector3d &a_globalLinVel)
This method overrides the linear velocity of the device expressed in world global coordinates...
Definition: CGenericTool.cpp:391
cFrequencyCounter m_freqWrite
Frequency counter to measure how often data is writing to haptic device.
Definition: CGenericTool.h:637
virtual cVector3d getDeviceGlobalLinVel() const
This method returns the linear velocity of the device expressed in world global coordinates.
Definition: CGenericTool.h:253
cVector3d m_deviceLocalTorque
Currently computed interaction torque [N*m] in device or tool local coordinates.
Definition: CGenericTool.h:542
double m_smallForceThresh
Force threshold that determines when forces are engaged if m_useWaitForSmallForce is enabled...
Definition: CGenericTool.h:616
void setWaitForSmallForce(const bool a_value)
This method enables the tool to wait for the simulation to compute a small force before sending it to...
Definition: CGenericTool.h:151
bool createAudioSource(cAudioDevice *a_audioDevice)
This method creates an audio source for each haptic point of this tool.
Definition: CGenericTool.cpp:1158
double m_gripperForce
Currently computed interaction gripper force [N].
Definition: CGenericTool.h:548
virtual void setDeviceLocalLinVel(const cVector3d &a_localLinVel)
This method overrides the linear velocity of the device expressed in device local coordinates...
Definition: CGenericTool.cpp:377
virtual void addGripperForce(const double &a_gripperForce)
This method adds a force to the currently computed gripper force.
Definition: CGenericTool.cpp:486
bool cCheckBit(const unsigned int &a_value, const unsigned int &a_bitPosition)
This function checks if a given bit is enabled.
Definition: CMaths.h:92
virtual cTransform getDeviceLocalTransform() const
This method returns a transformation matrix which expresses the position and orientation of the hapti...
Definition: CGenericTool.h:306
virtual void setDeviceGlobalRot(const cMatrix3d &a_globalRot)
This method overrides the orientation of the haptic device expressed in world global coordinates...
Definition: CGenericTool.cpp:361
void setDeviceLocalPos(const double &a_x, const double &a_y, const double &a_z)
This method overrides the position of the haptic device expressed in device local coordinates...
Definition: CGenericTool.h:232
virtual unsigned int getUserSwitches() const
This method returns the status of all user switches on the device.
Definition: CGenericTool.h:188
virtual void updateGlobalPositions(const bool a_frameOnly)
This method updates the global position of this tool in the world.
Definition: CGenericTool.cpp:791
bool m_forceOn
This flag indicates whether the forces are enabled or disabled on the hapitc device.
Definition: CGenericTool.h:604
This class defines a color using a GLfloat representation for each component.
Definition: CColor.h:138
void setRiseTime(const double a_riseTime)
This method sets the time required to rise the forces from 0% to 100%.
Definition: CGenericTool.h:169
double m_workspaceRadius
Radius of the workspace which can be accessed by the tool.
Definition: CGenericTool.h:558
virtual void setDeviceLocalTransform(const cTransform &a_localTransform)
This method overrides the transformation matrix which expresses the position and orientation of the h...
Definition: CGenericTool.cpp:434
This class implements an audio device context.
Definition: CAudioDevice.h:81
virtual void setRadiusDisplay(double a_radiusDisplay)
This method sets the radius size of the spheres used to display the proxies and goals positions...
Definition: CGenericTool.cpp:182
cGenericObject * m_image
Generic image model that can be used to display any a representation of the tool. ...
Definition: CGenericTool.h:490
bool setWorkspaceScaleFactor(const double &a_workspaceScaleFactor)
This method sets the scale factor between the workspaces of the haptic device and the virtual tool...
Definition: CGenericTool.cpp:1125
virtual void enableDynamicObjects(bool a_enabled)
This method enables or disables the dynamic proxy algorithm to support environments where mesh object...
Definition: CGenericTool.cpp:228
virtual cVector3d getDeviceGlobalAngVel() const
This method returns the angular velocity of the device expressed in world global coordinates.
Definition: CGenericTool.h:290
cHapticPoint * getHapticPoint(int a_index)
This method returns a pointer to a haptic point by passing its index number.
Definition: CGenericTool.h:440
cVector3d m_deviceGlobalTorque
Currently computed interaction torque [N*m] in world global coordinates.
Definition: CGenericTool.h:545
double getSmallForceThresh()
This method returns the force threshold required to engage forces when setWaitForSmallForce() is enab...
Definition: CGenericTool.h:160
cVector3d m_deviceGlobalLinVel
Linear velocity of the haptic device in world global coordinates.
Definition: CGenericTool.h:579
virtual void addDeviceGlobalForce(const cVector3d &a_globalForce)
This method adds a force to the currently computed force expressed in world coordinates.
Definition: CGenericTool.cpp:543
bool m_flagForceRiseFirstTime
Flag that indicates when force ramping is called for the first time.
Definition: CGenericTool.h:628
unsigned int m_userSwitches
Status of the user switches of the device attached to the tool.
Definition: CGenericTool.h:523
virtual void setDeviceLocalAngVel(const cVector3d &a_localAngVel)
This method overrides the angular velocity of the device expressed in device local coordinates...
Definition: CGenericTool.cpp:405
virtual void setGripperAngleDeg(const double &a_gripperAngleDeg)
This method overrides the angle in degrees of the gripper.
Definition: CGenericTool.cpp:284
virtual bool getUserSwitch(const unsigned int a_switchIndex) const
This method returns the status of a user switch from the device.
Definition: CGenericTool.h:182
cMatrix3d m_deviceLocalRot
Orientation of the haptic device in device local coordinates.
Definition: CGenericTool.h:570
virtual cVector3d getDeviceLocalForce() const
This method returns the currently computed force expressed in device or tool local coordinates...
Definition: CGenericTool.h:341
Definition: CAudioBuffer.cpp:56
void setDeviceGlobalLinVel(const double &a_x, const double &a_y, const double &a_z)
This method overrides the linear velocity of the device expressed in world global coordinates...
Definition: CGenericTool.h:259
cGenericHapticDevicePtr m_hapticDevice
Handle to the haptic device.
Definition: CGenericTool.h:520
virtual void setDeviceGlobalAngVel(const cVector3d &a_globalAngVel)
This method overrides the angular velocity of the device expressed in world global coordinates...
Definition: CGenericTool.cpp:419
bool m_flagForceRiseActivated
Flag that indicates if forces are currently rising.
Definition: CGenericTool.h:631
virtual cMatrix3d getDeviceGlobalRot() const
This method returns the orientation of the haptic device expressed in world global coordinates...
Definition: CGenericTool.h:278
virtual void setDeviceLocalRot(const cMatrix3d &a_localRot)
This method overrides the orientation of the haptic device expressed in device local coordinates...
Definition: CGenericTool.cpp:344
virtual void setUserSwitches(const unsigned int a_userSwitches)
This method overrides the status of all user switches on the device.
Definition: CGenericTool.cpp:258
virtual cTransform getDeviceGlobalTransform() const
This method returns a transformation matrix which expresses the position and orientation of the hapti...
Definition: CGenericTool.h:312
virtual void updateFromDevice()
This method updates the position, orientation, velocity and other degree of freedoms of the tool by r...
Definition: CGenericTool.cpp:698
virtual double getGripperAngleRad() const
This method returns the angle in radians of the gripper.
Definition: CGenericTool.h:201
Implements a force algorithm for modeling haptic effects.
void setDeviceLocalLinVel(const double &a_x, const double &a_y, const double &a_z)
This method overrides the linear velocity of the device expressed in device local coordinates...
Definition: CGenericTool.h:250
virtual void setDeviceGlobalTorque(const cVector3d &a_globalTorque)
This method overrides the current torque expressed in world coordinates.
Definition: CGenericTool.cpp:586
cVector3d m_deviceLocalAngVel
Angular velocity of the haptic device in device local coordinates.
Definition: CGenericTool.h:582
double getRiseTime()
This method returns the force rise time.
Definition: CGenericTool.h:172
virtual void setDeviceLocalPos(const cVector3d &a_localPos)
This method overrides the position of the haptic device expressed in device local coordinates...
Definition: CGenericTool.cpp:311
int getNumHapticPoints()
This method returns the number of haptic points that describe this tool.
Definition: CGenericTool.h:437
virtual double getGripperForce() const
This method returns the currently computed gripper force.
Definition: CGenericTool.h:325
virtual cVector3d getDeviceLocalTorque() const
This method returns the currently computed torque expressed in device or tool local coordinates...
Definition: CGenericTool.h:378
cVector3d m_deviceLocalLinVel
Linear velocity of the haptic device in device local coordinates.
Definition: CGenericTool.h:576
virtual void setGripperForce(const double &a_gripperForce)
This method overrides the current gripper force.
Definition: CGenericTool.cpp:473
Implements a frequency counter.
virtual void setDeviceGlobalTransform(const cTransform &a_globalTransform)
This method overrides the transformation matrix which expresses the position and orientation of the h...
Definition: CGenericTool.cpp:454
virtual cVector3d getDeviceLocalAngVel() const
This method returns the angular velocity of the device expressed in device local coordinates.
Definition: CGenericTool.h:281
cVector3d m_deviceGlobalForce
Currently computed interaction force [N] in world global coordinates.
Definition: CGenericTool.h:539
void setDeviceGlobalTorque(const double &a_x, const double &a_y, const double &a_z)
This method overrides the current torque expressed in world coordinates.
Definition: CGenericTool.h:399
virtual void initialize()
This method resets the contact force models and sets the tool at the position of the haptic device...
Definition: CGenericTool.cpp:679
void addDeviceGlobalForce(const double &a_x, const double &a_y, const double &a_z)
This method adds a force to the currently computed force expressed in world coordinates.
Definition: CGenericTool.h:368
void setUseForceRise(const bool a_value)
This method enables or disables the tool to gradually rise forces at startup.
Definition: CGenericTool.h:163
virtual bool isInContact(cGenericObject *a_object)
This method checks if the tool is touching a particular object.
Definition: CGenericTool.cpp:1064
bool m_useForceRise
The flag indicates if the force rising mode is enabled or disabled.
Definition: CGenericTool.h:619