cisst-saw
Loading...
Searching...
No Matches
mtsVFCylinder.h
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/* ex: set filetype=cpp softtabstop=4 shiftwidth=4 tabstop=4 cindent expandtab: */
3
4/*
5 Author(s): Max Zhaoshuo Li
6
7 (C) Copyright 2020 Johns Hopkins University (JHU), All Rights Reserved.
8
9 --- begin cisst license - do not edit ---
10
11 This software is provided "as is" under an open source license, with
12 no warranty. The complete license can be found in license.txt and
13 http://www.cisst.org/cisst/license.txt.
14
15 --- end cisst license ---
16 */
17
18#ifndef MTSVFCYLINDER_H
19#define MTSVFCYLINDER_H
20
28#include <sawConstraintController/mtsVFDataCylinder.h>
30
32
34{
35public:
36 mtsVFCylinder(const std::string & name, mtsVFDataBase * data);
37 void FillInTableauRefs(const mtsVFBase::CONTROLLERMODE mode, const double tickTime);
38
39protected:
40 prmKinematicsState * CurrentKinematics;
41 void ConvertRefs(const mtsVFBase::CONTROLLERMODE mode, const double tickTime);
42
44 {
45 vctDoubleVec xcl;
46 xcl.SetSize(3);
47 double normD = lineD(0) * lineD(0) + lineD(1) * lineD(1) + lineD(2) * lineD(2);
48 if (normD > 1e-6) {
49 double sqrtNorm = sqrt(normD);
50 lineD(0) /= sqrtNorm;
51 lineD(1) /= sqrtNorm;
52 lineD(2) /= sqrtNorm;
53 } else {
54 CMN_LOG_CLASS_RUN_ERROR << "FAILURE: " << lineD << std::endl;
55 }
56 double bx = givenPt(0) - linePoint(0);
57 double by = givenPt(1) - linePoint(1);
58 double bz = givenPt(2) - linePoint(2);
59 double d = bx*lineD(0) + by*lineD(1)+bz*lineD(2);
60 if (!CMN_ISFINITE(d)) {
61 CMN_LOG_CLASS_RUN_ERROR << "FAILURE: " << lineD << " " << d << std::endl;
62 }
63 xcl(0) = linePoint(0) + lineD(0)*d;
64 xcl(1) = linePoint(1) + lineD(1)*d;
65 xcl(2) = linePoint(2) + lineD(2)*d;
66 return xcl;
67 }
68};
69
70#endif // MTSVFCYLINDER_H
CONTROLLERMODE
Definition mtsVFBase.h:39
mtsVFBase()
Definition mtsVFBase.h:91
mtsVFCylinder(const std::string &name, mtsVFDataBase *data)
void FillInTableauRefs(const mtsVFBase::CONTROLLERMODE mode, const double tickTime)
Updates co with virtual fixture data.
prmKinematicsState * CurrentKinematics
Definition mtsVFCylinder.h:40
vctDoubleVec ClosestLinePoint(vctDoubleVec givenPt, vctDoubleVec linePoint, vctDoubleVec lineD)
Definition mtsVFCylinder.h:43
void ConvertRefs(const mtsVFBase::CONTROLLERMODE mode, const double tickTime)
Converts the data in the references if a change in mode is needed.
#define CISST_EXPORT
Definition cmnExportMacros.h:50
Defines cmnGenericObject.
#define CMN_LOG_CLASS_RUN_ERROR
Definition cmnLogger.h:117
#define CMN_ISFINITE(x)
Definition cmnPortability.h:433
Declaration of nmrLSqLin.
Typedef for dynamic matrices.
Typedef for dynamic vectors.
vctDynamicVector< double > vctDoubleVec
Definition vctDynamicVectorTypes.h:37
Typedef for fixed size vectors.