cisst-saw
Toggle main menu visibility
Loading...
Searching...
No Matches
tmp
cisst-saw
sawConstraintController
components
include
sawConstraintController
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
21
#include <
cisstCommon/cmnGenericObject.h
>
22
#include <
cisstVector/vctDynamicVectorTypes.h
>
23
#include <
cisstVector/vctFixedSizeVectorTypes.h
>
24
#include <
cisstVector/vctDynamicMatrixTypes.h
>
25
#include <
cisstVector/vctFixedSizeVectorTypes.h
>
26
#include <
cisstNumerical/nmrLSqLin.h
>
27
#include <
sawConstraintController/mtsVFJointPos.h
>
28
#include <sawConstraintController/mtsVFDataCylinder.h>
29
#include <
sawConstraintController/mtsVFBase.h
>
30
31
#include <
sawConstraintController/sawConstraintControllerExport.h
>
32
33
class
CISST_EXPORT
mtsVFCylinder
:
public
mtsVFBase
34
{
35
public
:
36
mtsVFCylinder
(
const
std::string & name, mtsVFDataBase * data);
37
void
FillInTableauRefs
(
const
mtsVFBase::CONTROLLERMODE
mode,
const
double
tickTime);
38
39
protected
:
40
prmKinematicsState *
CurrentKinematics
;
41
void
ConvertRefs
(
const
mtsVFBase::CONTROLLERMODE
mode,
const
double
tickTime);
42
43
vctDoubleVec
ClosestLinePoint
(
vctDoubleVec
givenPt,
vctDoubleVec
linePoint,
vctDoubleVec
lineD)
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
mtsVFBase::CONTROLLERMODE
CONTROLLERMODE
Definition
mtsVFBase.h:39
mtsVFBase::mtsVFBase
mtsVFBase()
Definition
mtsVFBase.h:91
mtsVFCylinder::mtsVFCylinder
mtsVFCylinder(const std::string &name, mtsVFDataBase *data)
mtsVFCylinder::FillInTableauRefs
void FillInTableauRefs(const mtsVFBase::CONTROLLERMODE mode, const double tickTime)
Updates co with virtual fixture data.
mtsVFCylinder::CurrentKinematics
prmKinematicsState * CurrentKinematics
Definition
mtsVFCylinder.h:40
mtsVFCylinder::ClosestLinePoint
vctDoubleVec ClosestLinePoint(vctDoubleVec givenPt, vctDoubleVec linePoint, vctDoubleVec lineD)
Definition
mtsVFCylinder.h:43
mtsVFCylinder::ConvertRefs
void ConvertRefs(const mtsVFBase::CONTROLLERMODE mode, const double tickTime)
Converts the data in the references if a change in mode is needed.
CISST_EXPORT
#define CISST_EXPORT
Definition
cmnExportMacros.h:50
cmnGenericObject.h
Defines cmnGenericObject.
CMN_LOG_CLASS_RUN_ERROR
#define CMN_LOG_CLASS_RUN_ERROR
Definition
cmnLogger.h:117
CMN_ISFINITE
#define CMN_ISFINITE(x)
Definition
cmnPortability.h:433
mtsVFBase.h
mtsVFJointPos.h
nmrLSqLin.h
Declaration of nmrLSqLin.
sawConstraintControllerExport.h
vctDynamicMatrixTypes.h
Typedef for dynamic matrices.
vctDynamicVectorTypes.h
Typedef for dynamic vectors.
vctDoubleVec
vctDynamicVector< double > vctDoubleVec
Definition
vctDynamicVectorTypes.h:37
vctFixedSizeVectorTypes.h
Typedef for fixed size vectors.
Generated by
1.18.0