FeatureDepth¶
- class FeatureDepth(self)¶
Bases:
BasicFeature
Class that defines a 3D point visual feature \(s\) which is composed by one parameters that is \(log( \frac{Z}{Z^*})\) that defines the current depth relative to the desired depth. Here \(Z\) represents the current depth and \(Z^*\) the desired depth.
In this class \(x\) and \(y\) are the 2D coordinates in the camera frame and are given in meter. \(x\) , \(y\) and \(Z\) are needed during the computation of the interaction matrix \(L\) .
The visual features can be set easily thanks to the build() method.
As the visual feature \(s\) represents the current depth relative to the desired depth, the desired visual feature \(s^*\) is set to zero. Once the value of the visual feature is set, the interaction() method allows to compute the interaction matrix \(L\) associated to the visual feature, while the error() method computes the error vector \((s - s^*)\) between the current visual feature and the desired one which is here set to zero.
The code below shows how to create a eye-in hand visual servoing task using a 3D depth feature \(log( \frac{Z}{Z^*})\) that corresponds to the current depth relative to the desired depth. To control six degrees of freedom, at least five other features must be considered. First we create a current ( \(s\) ) 3D depth feature. Then we set the task to use the interaction matrix associated to the current feature \(L_s\) . And finally we compute the camera velocity \(v=-\lambda \; L_s^+ \; (s-s^*)\) . The current feature \(s\) is updated in the while() loop.
#include <visp3/visual_features/vpFeatureDepth.h> #include <visp3/vs/vpServo.h> #ifdef ENABLE_VISP_NAMESPACE using namespace VISP_NAMESPACE_NAME; #endif int main() { vpServo task; // Visual servoing task vpFeatureDepth s; //The current point feature. //Set the current parameters x, y, Z and the desired depth Zs double x; // You have to compute the value of x. double y; // You have to compute the value of y. double Z; // You have to compute the value of Z. double Zs; // You have to define the desired depth Zs. //Set the point feature thanks to the current parameters. s.buildFrom(x, y, Z, log(Z/Zs)); // 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 desired visual features sd task.setInteractionMatrixType(vpServo::CURRENT); // Add the 3D depth feature to the task task.addFeature(s); // s* is here considered as zero // Control loop for ( ; ; ) { // The new parameters x, y and Z must be computed here. // Update the current point visual feature s.buildFrom(x, y, Z, log(Z/Zs)); // compute the control law vpColVector v = task.computeControlLaw(); // camera velocity } return 0; }
If you want to build your own control law, this other example shows how to create a current ( \(s\) ) and desired ( \(s^*\) ) 2D point visual feature, compute the corresponding error vector \((s-s^*)\) and finally build the interaction matrix \(L_s\) .
#include <visp3/core/vpColVector.h> #include <visp3/core/vpMatrix.h> #include <visp3/visual_features/vpFeatureDepth.h> #ifdef ENABLE_VISP_NAMESPACE using namespace VISP_NAMESPACE_NAME; #endif int main() { vpFeatureDepth s; //The current point feature. //Set the current parameters x, y, Z and the desired depth Zs double x; // You have to compute the value of x. double y; // You have to compute the value of y. double Z; // You have to compute the value of Z. double Zs; // You have to define the desired depth Zs. //Set the point feature thanks to the current parameters. s.buildFrom(x, y, Z, log(Z/Zs)); // Compute the interaction matrix L_s for the current point feature vpMatrix L = s.interaction(); // Compute the error vector (s-s*) for the point feature with s* considered as 0. vpColVector s_star(1); // The dimension is 1. s_star(1) = 0; // The value of s* is 0. s.error(s_star); }
Default constructor that build a visual feature.
Methods
Default constructor that build a visual feature.
Build a 3D depth visual feature from the point coordinates \(x\) and \(y\) given in the camera frame, \(Z\) which describes the depth and \(log(\frac{Z}{Z^*})\) which represents the logarithm of the current depth relative to the desired depth.
Overloaded function.
Overloaded function.
Get the value of \(log(\frac{Z}{Z^*})\) which represents the logarithm of the current depth relative to the desired depth.
Get the value of \(Z\) which represents the depth in the 3D camera frame.
Get the value of \(x\) which represents the x coordinate of the point in the camera frame.
Get the value of \(y\) which represents the y coordinate of the point in the camera frame.
Initialize the memory space requested for 3D depth visual feature.
Compute and return the interaction matrix \(L\) .
Print to stdout the values of the current visual feature \(s\) .
Set the value of \(log(\frac{Z}{Z^*})\) which represents the logarithm of the current depth relative to the desired depth.
Set the value of \(Z\) which represents the depth in the 3D camera frame.
Set the value of \(x\) which represents the x coordinate of the point in the camera frame.
Set the value of \(x\) , \(y\) , \(Z\) and \(log(\frac{Z}{Z^*})\) .
Set the value of \(y\) which represents the y coordinate of the point in the camera frame.
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__
Default constructor that build a visual feature.
__module__
Attributes
FEATURE_ALL
__annotations__
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
- __init__(self)¶
Default constructor that build a visual feature.
- buildFrom(self, x: float, y: float, Z: float, LogZoverZstar: float) visp._visp.visual_features.FeatureDepth ¶
Build a 3D depth visual feature from the point coordinates \(x\) and \(y\) given in the camera frame, \(Z\) which describes the depth and \(log(\frac{Z}{Z^*})\) which represents the logarithm of the current depth relative to the desired depth.
- display(*args, **kwargs)¶
Overloaded function.
display(self: visp._visp.visual_features.FeatureDepth, 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.FeatureDepth, 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.FeatureDepth, 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.
Since this visual feature \(s\) represent the current depth relative to the desired depth, the desired visual feature \(s^*\) should be zero. Thus, the error is here equal to the current visual feature \(s\) .
The code below shows how to use this method:
// Creation of the current feature s vpFeatureDepth s; // Creation of the desired feature s^*. By default this feature is // initialized to zero vpFeatureDepth s_star; s_star.setLogZoverZstar(0) // Compute the interaction matrix for the ThetaU_z feature vpMatrix L_z = s.interaction(); // Compute the error vector (s-s*) for the ThetaU_z feature s.error(s_star);
- Parameters:
- s_star
Desired visual visual feature that should be equal to zero.
- select
unuseful in the case of vpFeatureDepth . Always set to FEATURE_ALL.
- 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 ¶
- get_LogZoverZstar(self) float ¶
Get the value of \(log(\frac{Z}{Z^*})\) which represents the logarithm of the current depth relative to the desired depth.
- Returns:
The value of \(log(\frac{Z}{Z^*})\) .
- get_Z(self) float ¶
Get the value of \(Z\) which represents the depth in the 3D camera frame.
- Returns:
The value of \(Z\) .
- get_s(self, select: int = FEATURE_ALL) visp._visp.core.ColVector ¶
Get the feature vector \(\bf s\) .
- get_x(self) float ¶
Get the value of \(x\) which represents the x coordinate of the point in the camera frame.
- Returns:
The value of \(x\) .
- get_y(self) float ¶
Get the value of \(y\) which represents the y coordinate of the point in the camera frame.
- Returns:
The value of \(y\) .
- interaction(self, select: int = FEATURE_ALL) visp._visp.core.Matrix ¶
Compute and return the interaction matrix \(L\) . The computation is made thanks to the values of the point coordinates \(x\) and \(y\) and the depth \(Z\) .
\[L = \left[\begin{array}{cccccc} 0 & 0 & -1/Z & -y & x & 0 \end{array}\right]\]The code below shows how to compute the interaction matrix associated to the visual feature \(s = log(\frac{Z}{Z^*})\) .
// Creation of the current feature s vpFeatureDepth s; s.buildFrom(0, 0, 5, log(5/1)); // The current depth is 5 meters and the desired is 1 meter. vpMatrix L_x = s.interaction();
- print(self, select: int = FEATURE_ALL) None ¶
Print to stdout the values of the current visual feature \(s\) .
vpFeatureDepth s; // Current visual feature s // Creation of the current feature s s.buildFrom(0, 0, 5, log(5/1)); s.print(); // print all the 2 components of the feature
- setDeallocate(self, d: visp._visp.visual_features.BasicFeature.BasicFeatureDeallocatorType) None ¶
- setFlags(self) None ¶
Set feature flags to true to prevent warning when re-computing the interaction matrix without having updated the feature.
- set_LogZoverZstar(self, LogZoverZstar: float) None ¶
Set the value of \(log(\frac{Z}{Z^*})\) which represents the logarithm of the current depth relative to the desired depth.
- set_Z(self, Z: float) None ¶
Set the value of \(Z\) which represents the depth in the 3D camera frame.
- set_x(self, x: float) None ¶
Set the value of \(x\) which represents the x coordinate of the point in the camera frame.
- set_xyZLogZoverZstar(self, x: float, y: float, Z: float, logZZs: float) None ¶
Set the value of \(x\) , \(y\) , \(Z\) and \(log(\frac{Z}{Z^*})\) . \(x\) and \(y\) represent the coordinates of the point in the camera frame. \(Z\) is the 3D coordinate representing the depth. \(log(\frac{Z}{Z^*})\) represents the logarithm of the current depth relative to the desired depth.