45 #include <visp3/core/vpConfig.h>
47 #if defined(VISP_HAVE_MODULE_ROBOT) && \
48 (defined(VISP_HAVE_LAPACK) || defined(VISP_HAVE_EIGEN3) || defined(VISP_HAVE_OPENCV))
50 #include <visp3/core/vpCameraParameters.h>
51 #include <visp3/core/vpDisplay.h>
52 #include <visp3/core/vpHomogeneousMatrix.h>
53 #include <visp3/core/vpImage.h>
54 #include <visp3/core/vpMath.h>
55 #include <visp3/core/vpPoint.h>
56 #include <visp3/gui/vpDisplayGDI.h>
57 #include <visp3/gui/vpDisplayX.h>
58 #include <visp3/gui/vpPlot.h>
59 #include <visp3/io/vpParseArgv.h>
60 #include <visp3/robot/vpSimulatorCamera.h>
61 #include <visp3/visual_features/vpFeatureBuilder.h>
62 #include <visp3/visual_features/vpFeatureSegment.h>
63 #include <visp3/vs/vpServo.h>
65 int main(
int argc,
const char **argv)
67 #ifdef ENABLE_VISP_NAMESPACE
71 #if (defined(VISP_HAVE_X11) || defined(VISP_HAVE_GDI))
72 int opt_no_display = 0;
75 int opt_normalized = 1;
78 vpParseArgv::vpArgvInfo argTable[] = {
79 #if (defined(VISP_HAVE_X11) || defined(VISP_HAVE_GDI))
83 "1 to use normalized features, 0 for non normalized."},
95 std::cout <<
"Used options: " << std::endl;
96 #if (defined(VISP_HAVE_X11) || defined(VISP_HAVE_GDI))
97 opt_curves = (opt_no_display == 0) ? 1 : 0;
98 std::cout <<
" - no display: " << opt_no_display << std::endl;
99 std::cout <<
" - curves : " << opt_curves << std::endl;
101 std::cout <<
" - normalized: " << opt_normalized << std::endl;
105 #if defined(VISP_HAVE_X11) || defined(VISP_HAVE_GDI)
107 if (!opt_no_display) {
108 #if defined(VISP_HAVE_X11)
109 display =
new vpDisplayX;
110 #elif defined(VISP_HAVE_GDI)
117 #if (defined(VISP_HAVE_X11) || defined(VISP_HAVE_GDI))
134 for (
int i = 0; i < 4; i++) {
139 for (
int i = 0; i < 4; i++) {
145 for (
int i = 0; i < 2; i++) {
146 if (opt_normalized) {
166 for (
int i = 0; i < 2; i++)
169 #if (defined(VISP_HAVE_X11) || defined(VISP_HAVE_GDI))
170 if (!opt_no_display) {
172 for (
int i = 0; i < 2; i++) {
180 #if (defined(VISP_HAVE_X11) || defined(VISP_HAVE_GDI))
184 graph =
new vpPlot(2, 500, 500, 700, 10,
"Curves...");
197 float sampling_time = 0.02f;
198 robot.setSamplingTime(sampling_time);
202 robot.setPosition(wMc);
207 wMc = robot.getPosition();
209 for (
int i = 0; i < 4; i++)
212 for (
int i = 0; i < 2; i++)
215 #if (defined(VISP_HAVE_X11) || defined(VISP_HAVE_GDI))
216 if (!opt_no_display) {
218 for (
int i = 0; i < 2; i++) {
229 #if (defined(VISP_HAVE_X11) || defined(VISP_HAVE_GDI))
231 graph->
plot(0, iter, v);
239 }
while ((task.
getError()).sumSquare() > 0.0005);
241 #if (defined(VISP_HAVE_X11) || defined(VISP_HAVE_GDI))
242 if (graph !=
nullptr)
245 #if (defined(VISP_HAVE_X11) || defined(VISP_HAVE_GDI))
246 if (!opt_no_display && display !=
nullptr)
250 std::cout <<
"final error=" << (task.
getError()).sumSquare() << std::endl;
254 std::cout <<
"Catch an exception: " << e << std::endl;
259 #elif !(defined(VISP_HAVE_LAPACK) || defined(VISP_HAVE_EIGEN3) || defined(VISP_HAVE_OPENCV))
262 std::cout <<
"Cannot run this example: install Lapack, Eigen3 or OpenCV" << std::endl;
268 std::cout <<
"Test empty since visp_robot module is not available.\n" << std::endl;
Generic class defining intrinsic camera parameters.
Implementation of column vector and the associated operations.
static const vpColor green
Display for windows using GDI (available on any windows 32 platform).
Class that defines generic functionalities for display.
static void display(const vpImage< unsigned char > &I)
static void flush(const vpImage< unsigned char > &I)
error that can be emitted by ViSP classes.
static void create(vpFeaturePoint &s, const vpCameraParameters &cam, const vpImagePoint &t)
Class that defines a 2D segment visual features. This class allow to consider two sets of visual feat...
void display(const vpCameraParameters &cam, const vpImage< unsigned char > &I, const vpColor &color=vpColor::green, unsigned int thickness=1) const VP_OVERRIDE
void print(unsigned int select=FEATURE_ALL) const VP_OVERRIDE
void setNormalized(bool normalized)
Implementation of an homogeneous matrix and operations on such kind of matrices.
vpHomogeneousMatrix inverse() const
static double rad(double deg)
static bool parse(int *argcPtr, const char **argv, vpArgvInfo *argTable, int flags)
@ ARGV_NO_DEFAULTS
No default options like -help.
@ ARGV_NO_LEFTOVERS
Print an error message if an option is not in the argument list.
@ ARGV_INT
Argument is associated to an int.
@ ARGV_CONSTANT_INT
Stand alone argument associated to an int var that is set to 1.
@ ARGV_END
End of the argument list.
@ ARGV_HELP
Argument is for help displaying.
This class enables real time drawing of 2D or 3D graphics. An instance of the class open a window whi...
void initGraph(unsigned int graphNum, unsigned int curveNbr)
void plot(unsigned int graphNum, unsigned int curveNum, double x, double y)
Class that defines a 3D point in the object frame and allows forward projection of a 3D point in the ...
void setWorldCoordinates(double oX, double oY, double oZ)
void setVelocity(const vpRobot::vpControlFrameType frame, const vpColVector &vel) VP_OVERRIDE
void setMaxRotationVelocity(double maxVr)
void setMaxTranslationVelocity(double maxVt)
void setInteractionMatrixType(const vpServoIteractionMatrixType &interactionMatrixType, const vpServoInversionType &interactionMatrixInversion=PSEUDO_INVERSE)
void addFeature(vpBasicFeature &s_cur, vpBasicFeature &s_star, unsigned int select=vpBasicFeature::FEATURE_ALL)
void setServo(const vpServoType &servo_type)
vpColVector getError() const
vpColVector computeControlLaw()
Class that defines the simplest robot: a free flying camera.
VISP_EXPORT int wait(double t0, double t)
VISP_EXPORT double measureTimeMs()