FeatureTranslation¶
- class FeatureTranslation(*args, **kwargs)¶
Bases:
BasicFeature
Class that defines the translation visual feature \(s=(t_x,t_y,t_z)\) .
It is convenient to consider two coordinate frames noted here \({\cal{F}}_1\) and \({\cal{F}}_{2}\) .
Let \(^{{\cal{F}}_2}M_{{\cal{F}}_1}\) be the homogeneous matrix that gives the orientation and the translation of the frame \({\cal{F}}_1\) with respect to the frame \({\cal{F}}_2\) .
\[\begin{split}^{{\cal{F}}_2}M_{{\cal{F}}_1} = \left(\begin{array}{cc} ^{{\cal{F}}_2}R_{{\cal{F}}_1} & ^{{\cal{F}}_2}t_{{\cal{F}}_1} \\{\bf 0}_{1\times 3} & 1 \end{array} \right) \end{split}\]with \(^{{\cal{F}}_2}R_{{\cal{F}}_1}\) the rotation matrix that gives the orientation of the frame \({\cal{F}}_1\) relative to the frame \({\cal{F}}_2\) and \(^{{\cal{F}}_2}t_{{\cal{F}}_1}\) the translation vector that gives the position of the frame \({\cal{F}}_1\) relative to the frame \({\cal{F}}_2\) . To know more about homogeneous matrices see vpHomogeneousMatrix documentation.
This class can be used to manipulate three kind of visual features:
This class can be used to manipulate the translation visual feature \(s= ^{c^*}t_c\) which gives the position of the current camera frame relative to the desired camera frame. It is composed by the three components \((t_x,t_y,t_z)\) . The desired visual feature \(s^*\) is equal to zero. The corresponding error is than equal to \(e=(s-s^*) = ^{c^*}t_c\) . In this case, the interaction matrix related to \(s\) is given by
\[L = [ ^{c^*}R_c \;\; 0_3] \]This class can also be used to manipulate the translation visual feature \(s= ^{c}t_{c^*}\) which gives the position of the desired camera frame relative to the current camera frame. It is composed by the three components \((t_x,t_y,t_z)\) . The desired visual feature \(s^*\) is equal to zero. The corresponding error is than equal to \(e=(s-s^*) = ^{c}t_{c^*}\) . In this case, the interaction matrix related to \(s\) is given by
\[L = [ -I_3 \;\; [^{c}t_{c^*}]_\times] \]Actually, this class can also be used to manipulate the translation visual feature \(s= ^{c}t_o\) which gives the position of the object frame relative to the current camera frame. It is composed by the three components \((t_x,t_y,t_z)\) too. The desired visual feature \(s^*\) is the translation visual feature \(s^*= ^{c^*}t_o\) which gives the position of the object frame relative to the desired camera frame. The corresponding error is than equal to \(e=(s-s^*) = ^{c}t_o - ^{c^*}t_o\) . In this case, the interaction matrix related to \(s\) is given by
\[L = [ -I_3 \;\; [^{c}t_o]_\times] \]
To initialize the feature \((t_x, t_y, t_z)\) you may use member functions like set_Tx() , set_Ty() , set_Tz() , or also build() functions.
The interaction() method allows to compute the interaction matrix \(L\) associated to the translation visual feature, while the error() method computes the error vector \((s - s^*)\) between the current visual feature and the desired one.
The code below shows how to create a eye-in hand visual servoing task using a 3D translation feature \((t_x,t_y,t_z)\) that correspond to the 3D translation between the desired camera frame and the current camera frame. To control six degrees of freedom, at least three other features must be considered like vpFeatureThetaU visual features. First we create a current ( \(s\) ) and desired ( \(s^*\) ) 3D translation feature, set the task to use the interaction matrix associated to the current feature \(L_s\) and than compute the camera velocity \(v=-\lambda \; L_s^+ \; (s-s^*)\) . The current feature \(s\) is updated in the while() loop while \(s^*\) is set to zero.
#include <visp3/core/vpHomogeneousMatrix.h> #include <visp3/visual_features/vpFeatureTranslation.h> #include <visp3/vs/vpServo.h> #ifdef ENABLE_VISP_NAMESPACE using namespace VISP_NAMESPACE_NAME; #endif int main() { vpServo task; // Visual servoing task vpHomogeneousMatrix cdMc; // ... cdMc need here to be initialized from for example a pose estimation. // Creation of the current visual feature s vpFeatureTranslation s(vpFeatureTranslation::cdMc); s.buildFrom(cdMc); // Initialization of the current feature s=(tx,ty,tz) // Set eye-in-hand control law. // The computed velocities will be expressed in the camera frame task.setServo(vpServo::EYEINHAND_CAMERA); // Interaction matrix is computed with the current visual features s task.setInteractionMatrixType(vpServo::CURRENT); // Set the constant gain double lambda = 0.8; task.setLambda(lambda); // Add the 3D translation feature to the task task.addFeature(s); // s* is here considered as zero // Control loop for ( ; ; ) { // ... cdMc need here to be initialized from for example a pose estimation. // Update the current 3D translation visual feature s.buildFrom(cdMc); // compute the control law vpColVector v = task.computeControlLaw(); // camera velocity } }
If you want to deal only with the \((t_x,t_y)\) subset feature from the 3D translation, you have just to modify the addFeature() call in the previous example by the following line. In that case, the dimension of \(s\) is two.
// Add the (tx,ty) subset features from 3D translation to the task task.addFeature(s, vpFeatureTranslation::selectTx() | vpFeatureTranslation::selectTy());
If you want to build your own control law, this other example shows how to create a current ( \(s\) ) and desired ( \(s^*\) ) 3D translation visual feature, compute the corresponding error vector \((s-s^*)\) and finally build the interaction matrix \(L_s\) .
#include <visp3/core/vpHomogeneousMatrix.h> #include <visp3/core/vpMatrix.h> #include <visp3/visual_features/vpFeatureTranslation.h> #ifdef ENABLE_VISP_NAMESPACE using namespace VISP_NAMESPACE_NAME; #endif int main() { vpHomogeneousMatrix cdMc; // ... cdMc need here to be initialized from for example a pose estimation. // Creation of the current feature s vpFeatureTranslation s(vpFeatureTranslation::cdMc); s.buildFrom(cdMc); // Initialization of the feature // Creation of the desired feature s*. By default this feature is // initialized to zero vpFeatureTranslation s_star(vpFeatureTranslation::cdMc); // Compute the interaction matrix for the translation feature vpMatrix L = s.interaction(); // Compute the error vector (s-s*) for the translation feature vpColVector e = s.error(s_star); // e = (s-s*) }
The code below shows how to create an eye-in hand visual servoing task using a 3D translation feature \((t_x,t_y,t_z)\) that correspond to the 3D translation between the current camera frame and the object frame. Like with the previous examples, to control six degrees of freedom, at least three other features must be considered like vpFeatureThetaU visual features. The way to initialize the visual features is quite the same as before. The difference is that the cMo method must be precised and the desired feature is note necessary equal to zero.
#include <visp3/core/vpHomogeneousMatrix.h> #include <visp3/visual_features/vpFeatureTranslation.h> #include <visp3/vs/vpServo.h> #ifdef ENABLE_VISP_NAMESPACE using namespace VISP_NAMESPACE_NAME; #endif int main() { vpServo task; // Visual servoing task vpHomogeneousMatrix cdMo; // ... cdMo need here to be initialized from for example a pose estimation. // Creation of the desired visual feature s* vpFeatureTranslation s_star(vpFeatureTranslation::cMo); s_star.buildFrom(cdMo); // Initialization of the desired feature s*=(tx*,ty*,tz*) vpHomogeneousMatrix cMo; // ... cMo need here to be computed. // Creation of the current visual feature s vpFeatureTranslation s(vpFeatureTranslation::cMo); s.buildFrom(cMo); // Initialization of the current feature s=(tx,ty,tz) // Set eye-in-hand control law. // The computed velocities will be expressed in the camera frame task.setServo(vpServo::EYEINHAND_CAMERA); // Interaction matrix is computed with the current visual features s task.setInteractionMatrixType(vpServo::CURRENT); // Set the constant gain double lambda = 0.8; task.setLambda(lambda); // Add the 3D translation feature to the task task.addFeature(s, s_star); // s* is here considered as zero // Control loop for ( ; ; ) { // ... cMo need here to be computed from for example a pose estimation. // Update the current 3D translation visual feature s.buildFrom(cMo); // compute the control law vpColVector v = task.computeControlLaw(); // camera velocity } }
Overloaded function.
__init__(self: visp._visp.visual_features.FeatureTranslation) -> None
Default constructor that builds a visual feature and initialize it to zero. The type of the translation feature will be vpFeatureTranslation::cdMc by default. Use the function setFeatureTranslationType() to set the desired type of feature.
__init__(self: visp._visp.visual_features.FeatureTranslation, r: visp._visp.visual_features.FeatureTranslation.FeatureTranslationRepresentationType) -> None
__init__(self: visp._visp.visual_features.FeatureTranslation, f2Mf1: visp._visp.core.HomogeneousMatrix, r: visp._visp.visual_features.FeatureTranslation.FeatureTranslationRepresentationType) -> None
Constructor that builds a 3D visual feature from an homogeneous matrix \(^{{\cal{F}}_2}M_{{\cal{F}}_1}\) that represent the 3D transformation between two frames \({\cal{F}}_1\) and \({\cal{F}}_2\) .
- Parameters:
- r
type of feature. It can be vpFeature::cdMc or vpFeature::cMo.
Methods
Overloaded function.
Build a 3D translation visual feature from an homogeneous matrix \(^{{\cal{F}}_2}M_{{\cal{F}}_1}\) that represent the 3D transformation between two frames \({\cal{F}}_1\) and \({\cal{F}}_2\) .
Overloaded function.
Overloaded function.
Get the type of translation feature.
Return the \(t_x\) subset value of the visual feature \(s\) .
Return the \(t_y\) subset value of the visual feature \(s\) .
Return the \(t_z\) subset value of the visual feature \(s\) .
Initialise the memory space requested for 3D translation visual feature.
Compute and return the interaction matrix \(L\) from a subset \((t_x, t_y, t_z)\) of the possible translation features that represent the 3D transformation \(^{{\cal{F}}_2}M_{{\cal{F}}_1}\) .
Print to stdout the values of the current visual feature \(s\) .
Function used to select the \(t_x\) subset of the translation visual feature.
Function used to select the \(t_y\) subset of the translation visual feature.
Function used to select the \(t_z\) subset of the translation visual feature.
Initialise the \(t_x\) subset value of the 3D visual feature \(s\) .
Initialise the \(t_y\) subset value of the 3D visual feature \(s\) .
Initialise the \(t_z\) subset value of the 3D visual feature \(s\) .
Inherited Methods
vpServo
Indicates who should deallocate the feature.
deallocate
Return the dimension of the feature vector \(\bf s\) .
s
user
nbParameters
Indicates who should deallocate the feature.
Select all the features.
dim_s
Get the feature vector \(\bf s\) .
FEATURE_ALL
Set feature flags to true to prevent warning when re-computing the interaction matrix without having updated the feature.
Get the feature vector dimension.
Operators
__doc__
Overloaded function.
__module__
Attributes
FEATURE_ALL
__annotations__
cMcd
cMo
cdMc
deallocate
dim_s
nbParameters
s
user
vpServo
- class BasicFeatureDeallocatorType(self, value: int)¶
Bases:
pybind11_object
Indicates who should deallocate the feature.
Values:
user
vpServo
- class BasicFeatureSelect(self, value: int)¶
Bases:
pybind11_object
Indicates who should deallocate the feature.
Values:
user
vpServo
- class FeatureTranslationRepresentationType(self, value: int)¶
Bases:
pybind11_object
Kind of implemented 3D translation feature.
Values:
cdMc: Selector used to manipulate the visual feature \(s= ^{c^*}t_c\) which gives the position of the current camera frame relative to the desired camera frame.
cMcd: Selector used to manipulate the visual feature \(s= ^{c}t_{c^*}\) which gives the position of the desired camera frame relative to the current camera frame.
cMo: Selector used to manipulate the visual feature \(s= ^{c}t_o\) which gives the position of the object frame relative to the current camera frame.
- __init__(*args, **kwargs)¶
Overloaded function.
__init__(self: visp._visp.visual_features.FeatureTranslation) -> None
Default constructor that builds a visual feature and initialize it to zero. The type of the translation feature will be vpFeatureTranslation::cdMc by default. Use the function setFeatureTranslationType() to set the desired type of feature.
__init__(self: visp._visp.visual_features.FeatureTranslation, r: visp._visp.visual_features.FeatureTranslation.FeatureTranslationRepresentationType) -> None
__init__(self: visp._visp.visual_features.FeatureTranslation, f2Mf1: visp._visp.core.HomogeneousMatrix, r: visp._visp.visual_features.FeatureTranslation.FeatureTranslationRepresentationType) -> None
Constructor that builds a 3D visual feature from an homogeneous matrix \(^{{\cal{F}}_2}M_{{\cal{F}}_1}\) that represent the 3D transformation between two frames \({\cal{F}}_1\) and \({\cal{F}}_2\) .
- Parameters:
- r
type of feature. It can be vpFeature::cdMc or vpFeature::cMo.
- buildFrom(self, f2Mf1: visp._visp.core.HomogeneousMatrix) visp._visp.visual_features.FeatureTranslation ¶
Build a 3D translation visual feature from an homogeneous matrix \(^{{\cal{F}}_2}M_{{\cal{F}}_1}\) that represent the 3D transformation between two frames \({\cal{F}}_1\) and \({\cal{F}}_2\) .
- display(*args, **kwargs)¶
Overloaded function.
display(self: visp._visp.visual_features.FeatureTranslation, cam: visp._visp.core.CameraParameters, I: visp._visp.core.ImageGray, color: visp._visp.core.Color = vpColor::green, thickness: int = 1) -> None
Not implemented.
display(self: visp._visp.visual_features.FeatureTranslation, cam: visp._visp.core.CameraParameters, I: visp._visp.core.ImageRGBa, color: visp._visp.core.Color = vpColor::green, thickness: int = 1) -> None
Not implemented.
- error(*args, **kwargs)¶
Overloaded function.
error(self: visp._visp.visual_features.FeatureTranslation, s_star: visp._visp.visual_features.BasicFeature, select: int = FEATURE_ALL) -> visp._visp.core.ColVector
Compute the error \((s-s^*)\) between the current and the desired visual features from a subset of the possible features.
With the feature type cdMc: Since this visual feature \(s\) represent the 3D translation from the desired camera frame to the current one \(^{c^*}t_{c}\) , the desired visual feature \(s^*\) should be zero. Thus, the error is here equal to the current visual feature \(s\) .
With the feature type cMo: In this case the desired feature is not necessary equal to zero. Thus, the error is here equal to \(s-s^*\) .
The code below shows how to use this method to manipulate the \(t_z\) subset in the case of the cdMc feature type. It can be used also with the cMo feature type. In that case just change vpFeatureTranslation::cdMc by vpFeatureTranslation::cMo during the declaration of the two vpFeatureTranslation features.
// Creation of the current feature s vpFeatureTranslation s(vpFeatureTranslation::cdMc); s.set_TUz(0.3); // Initialization of the feature // Creation of the desired feature s*. By default this feature is // initialized to zero vpFeatureTranslation s_star(vpFeatureTranslation::cdMc); // Compute the interaction matrix for the t_z translation feature vpMatrix L_z = s.interaction( vpFeatureTranslation::selectTz() ); // Compute the error vector (s-s*) for the t_z feature s.error(s_star, vpFeatureTranslation::selectTz());
To manipulate the subset features \(s=(t_y, t_z)\) , the code becomes:
// Compute the interaction matrix for the t_y, t_z features vpMatrix L_yz = s.interaction( vpFeatureTranslation::selectTy() | vpFeatureTranslation::selectTz() ); // Compute the error vector e = (s-s*) for the t_y, t_z feature vpColVector e = s.error(s_star, vpFeatureTranslation::selectTy() | vpFeatureTranslation::selectTz());
- Parameters:
- s_star
Desired visual feature.
- select
The error can be computed for a selection of a subset of the possible translation features.
To compute the error for all the three translation vector coordinates use vpBasicFeature::FEATURE_ALL . In that case the error vector is a 3 dimension column vector.
To compute the error for only one of the translation vector coordinate feature \((t_x, t_y, t_z)\) use one of the corresponding function selectTx() , selectTy() or selectTz() . In that case the error vector is a 1 dimension column vector.
- Returns:
The error \((s-s^*)\) between the current and the desired visual feature.
error(self: visp._visp.visual_features.BasicFeature, s_star: visp._visp.visual_features.BasicFeature, select: int = FEATURE_ALL) -> visp._visp.core.ColVector
Compute the error between two visual features from a subset of the possible features.
- getDeallocate(self) visp._visp.visual_features.BasicFeature.BasicFeatureDeallocatorType ¶
- getFeatureTranslationType(self) visp._visp.visual_features.FeatureTranslation.FeatureTranslationRepresentationType ¶
Get the type of translation feature.
Note
See setFeatureTranslationType()
- Returns:
Type of translation feature. It can be vpFeatureTranslation::cdMc , vpFeatureTranslation::cMcd or vpFeatureTranslation::cMo .
- get_s(self, select: int = FEATURE_ALL) visp._visp.core.ColVector ¶
Get the feature vector \(\bf s\) .
- interaction(self, select: int = FEATURE_ALL) visp._visp.core.Matrix ¶
Compute and return the interaction matrix \(L\) from a subset \((t_x, t_y, t_z)\) of the possible translation features that represent the 3D transformation \(^{{\cal{F}}_2}M_{{\cal{F}}_1}\) .
As it exists three different features, the computation of the interaction matrix is diferent for each one.
With the feature type cdMc:
\[L = [ ^{c^*}R_c \;\; 0_3] \]
where \(^{c^*}R_c\) is the rotation the camera has to achieve to move from the desired camera frame to the current camera frame.
With the feature type cMcd:
\[L = [ -I_3 \;\; [^{c}t_{c^*}]_\times] \]
where \(^{c}R_{c^*}\) is the rotation the camera has to achieve to move from the current camera frame to the desired camera frame.
With the feature type cMo:
\[L = [ -I_3 \;\; [^{c}t_o]_\times] \]
where \(^{c}t_o\) is the position of the object frame relative to the current camera frame.
The code below shows how to compute the interaction matrix associated to the visual feature \(s = t_x\) using the cdMc feature type.
vpHomogeneousMatrix cdMc; ... // Creation of the current feature s vpFeatureTranslation s(vpFeatureTranslation::cdMc); s.buildFrom(cdMc); vpMatrix L_x = s.interaction( vpFeatureTranslation::selectTx() );
The code below shows how to compute the interaction matrix associated to the \(s = (t_x, t_y)\) subset visual feature:
vpMatrix L_xy = s.interaction( vpFeatureTranslation::selectTx() | vpFeatureTranslation::selectTy() );
L_xy is here now a 2 by 6 matrix. The first line corresponds to the \(t_x\) visual feature while the second one to the \(t_y\) visual feature.
It is also possible to build the interaction matrix from all the translation components by:
vpMatrix L_xyz = s.interaction( vpBasicFeature::FEATURE_ALL );
In that case, L_xyz is a 3 by 6 interaction matrix where the last line corresponds to the \(t_z\) visual feature.
- Parameters:
- select: int = FEATURE_ALL¶
Selection of a subset of the possible translation features.
To compute the interaction matrix for all the three translation subset features \((t_x,t_y,t_y)\) use vpBasicFeature::FEATURE_ALL . In that case the dimension of the interaction matrix is \([3 \times 6]\)
To compute the interaction matrix for only one of the translation subset ( \(t_x, t_y, t_z\) ) use one of the corresponding function selectTx() , selectTy() or selectTz() . In that case the returned interaction matrix is \([1 \times 6]\) dimension.
- Returns:
The interaction matrix computed from the translation features.
- print(self, select: int = FEATURE_ALL) None ¶
Print to stdout the values of the current visual feature \(s\) .
vpHomogeneousMatrix cdMc; // Homogeneous transformation between the desired camera frame and the current camera frame. // Creation of the current feature s vpFeatureTranslation s(vpFeatureTranslation::cdMc); s.buildFrom(cdMc); s.print(); // print all the 3 components of the translation feature s.print(vpBasicFeature::FEATURE_ALL); // same behavior then previous line s.print(vpFeatureTranslation::selectTz()); // print only the t_z component
- Parameters:
- select: int = FEATURE_ALL¶
Selection of a subset of the possible translation features.
To print all the three translation vector coordinates used as features use vpBasicFeature::FEATURE_ALL .
To print only one of the translation coordinate feature \((t_x, t_y, t_z)\) use one of the corresponding function selectTx() , selectTy() or selectTz() .
- static selectTx() int ¶
Function used to select the \(t_x\) subset of the translation visual feature.
This function is to use in conjunction with interaction() in order to compute the interaction matrix associated to \(t_x\) .
See the interaction() method for an usage example.
This function is also useful in the vpServo class to indicate that a subset of the visual feature is to use in the control law:
With the feature type cdMc:
vpFeatureTranslation t(vpFeatureTranslation::cdMc); vpServo task; ... // Add the (tx,ty) subset features from 3D translation to the task task.addFeature(t, vpFeatureTranslation::selectTx() | vpFeatureTranslation::selectTy());
With the feature type cMcd:
vpFeatureTranslation t(vpFeatureTranslation::cMcd); vpServo task; ... // Add the (tx,ty) subset features from 3D translation to the task task.addFeature(t, vpFeatureTranslation::selectTx() | vpFeatureTranslation::selectTy());
With the feature type cMo:
vpFeatureTranslation t(vpFeatureTranslation::cMo); vpFeatureTranslation t_star(vpFeatureTranslation::cMo); vpServo task; ... // Add the (tx,ty) subset features from 3D translation to the task task.addFeature(t, t_star, vpFeatureTranslation::selectTx() | vpFeatureTranslation::selectTy());
Note
See selectTy() , selectTz()
- static selectTy() int ¶
Function used to select the \(t_y\) subset of the translation visual feature.
This function is to use in conjunction with interaction() in order to compute the interaction matrix associated to \(t_y\) .
See the interaction() method for an usage example.
This function is also useful in the vpServo class to indicate that a subset of the visual feature is to use in the control law:
With the feature type cdMc:
vpFeatureTranslation t(vpFeatureTranslation::cdMc); vpServo task; ... // Add the (tx,ty) subset features from 3D translation to the task task.addFeature(t, vpFeatureTranslation::selectTx() | vpFeatureTranslation::selectTy());
With the feature type cMcd:
vpFeatureTranslation t(vpFeatureTranslation::cMcd); vpServo task; ... // Add the (tx,ty) subset features from 3D translation to the task task.addFeature(t, vpFeatureTranslation::selectTx() | vpFeatureTranslation::selectTy());
With the feature type cMo:
vpFeatureTranslation t(vpFeatureTranslation::cMo); vpFeatureTranslation t_star(vpFeatureTranslation::cMo); vpServo task; ... // Add the (tx,ty) subset features from 3D translation to the task task.addFeature(t, t_star, vpFeatureTranslation::selectTx() | vpFeatureTranslation::selectTy());
Note
See selectTx() , selectTz()
- static selectTz() int ¶
Function used to select the \(t_z\) subset of the translation visual feature.
This function is to use in conjunction with interaction() in order to compute the interaction matrix associated to \(t_z\) .
See the interaction() method for an usage example.
This function is also useful in the vpServo class to indicate that a subset of the visual feature is to use in the control law:
With the feature type cdMc:
vpFeatureTranslation t(vpFeatureTranslation::cdMc); vpServo task; ... // Add the (tz) subset feature from 3D translation to the task task.addFeature(t, vpFeatureTranslation::selectTz());
With the feature type cMcd:
vpFeatureTranslation t(vpFeatureTranslation::cMcd); vpServo task; ... // Add the (tz) subset feature from 3D translation to the task task.addFeature(t, vpFeatureTranslation::selectTz());
With the feature type cMo:
vpFeatureTranslation t(vpFeatureTranslation::cMo); vpFeatureTranslation t_star(vpFeatureTranslation::cMo); vpServo task; ... // Add the (tz) subset feature from 3D translation to the task task.addFeature(t, t_star, vpFeatureTranslation::selectTz());
Note
See selectTx() , selectTy()
- setDeallocate(self, d: visp._visp.visual_features.BasicFeature.BasicFeatureDeallocatorType) None ¶
- setFeatureTranslationType(self, r: visp._visp.visual_features.FeatureTranslation.FeatureTranslationRepresentationType) None ¶
- setFlags(self) None ¶
Set feature flags to true to prevent warning when re-computing the interaction matrix without having updated the feature.
- set_Tx(self, t_x: float) None ¶
Initialise the \(t_x\) subset value of the 3D visual feature \(s\) .
Note
See get_Tx()