Visual Servoing Platform version 3.7.0
Loading...
Searching...
No Matches
movePtu46.cpp
1/*
2 * ViSP, open source Visual Servoing Platform software.
3 * Copyright (C) 2005 - 2025 by Inria. All rights reserved.
4 *
5 * This software is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 * See the file LICENSE.txt at the root directory of this source
10 * distribution for additional information about the GNU GPL.
11 *
12 * For using ViSP with software that can not be combined with the GNU
13 * GPL, please contact Inria about acquiring a ViSP Professional
14 * Edition License.
15 *
16 * See https://visp.inria.fr for more information.
17 *
18 * This software was developed at:
19 * Inria Rennes - Bretagne Atlantique
20 * Campus Universitaire de Beaulieu
21 * 35042 Rennes Cedex
22 * France
23 *
24 * If you have questions regarding the use of this file, please contact
25 * Inria at visp@inria.fr
26 *
27 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
28 * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
29 *
30 * Description:
31 * Tests the control law
32 */
40
48#include <visp3/core/vpConfig.h>
49#include <visp3/core/vpDebug.h>
50#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX
51#include <unistd.h>
52#endif
53
54#ifdef VISP_HAVE_PTU46
55
56#include <visp3/robot/vpRobotPtu46.h>
57
58int main()
59{
60#ifdef ENABLE_VISP_NAMESPACE
61 using namespace VISP_NAMESPACE_NAME;
62#endif
63
64 try {
65 vpRobotPtu46 robot;
66 vpColVector q(2);
67
68 vpERROR_TRACE(" ");
69
70 robot.setRobotState(vpRobot::STATE_POSITION_CONTROL);
71
72 q = 0;
73 vpCTRACE << "Set position in the articular frame: " << q.t();
74 robot.setPosition(vpRobot::ARTICULAR_FRAME, q);
75
76 q[0] = vpMath::rad(10);
77 q[1] = vpMath::rad(20);
78 vpCTRACE << "Set position in the articular frame: " << q.t();
79 robot.setPosition(vpRobot::ARTICULAR_FRAME, q);
80
81 vpColVector qm(2);
82 robot.getPosition(vpRobot::ARTICULAR_FRAME, qm);
83 vpCTRACE << "Position in the articular frame " << qm.t();
84
85 vpColVector qdot(2);
86 robot.setRobotState(vpRobot::STATE_VELOCITY_CONTROL);
87#if 0
88 qdot = 0;
89 qdot[0] = vpMath::rad(10);
90 qdot[1] = vpMath::rad(10);
91 vpCTRACE << "Set camera frame velocity " << qdot.t();
92
93 robot.setVelocity(vpRobot::CAMERA_FRAME, qdot);
94 sleep(2);
95
96 qdot = 0;
97 qdot[0] = vpMath::rad(-10);
98 qdot[1] = vpMath::rad(-10);
99
100 vpCTRACE << "Set camera frame velocity " << qdot.t();
101 robot.setVelocity(vpRobot::CAMERA_FRAME, qdot);
102 sleep(2);
103#endif
104
105 qdot = 0;
106 // qdot[0] = vpMath::rad(0.1) ;
107 qdot[1] = vpMath::rad(10);
108 vpCTRACE << "Set articular frame velocity " << qdot.t();
109 robot.setVelocity(vpRobot::ARTICULAR_FRAME, qdot);
110 sleep(2);
111
112 qdot = 0;
113 qdot[0] = vpMath::rad(-5);
114 // qdot[1] = vpMath::rad(-5);
115
116 vpCTRACE << "Set articular frame velocity " << qdot.t();
117 robot.setVelocity(vpRobot::ARTICULAR_FRAME, qdot);
118 sleep(2);
119 }
120 catch (const vpException &e) {
121 std::cout << "Sorry PtU46 not available. Got exception: " << e << std::endl;
122 return EXIT_FAILURE
123 }
124 return EXIT_SUCCESS;
125}
126#else
127int main()
128{
129 std::cout << "You do not have an PTU46 PT robot connected to your computer..." << std::endl;
130 return EXIT_SUCCESS;
131}
132
133#endif
Implementation of column vector and the associated operations.
error that can be emitted by ViSP classes.
Definition vpException.h:60
static double rad(double deg)
Definition vpMath.h:129
Interface for the Directed Perception ptu-46 pan, tilt head .
@ ARTICULAR_FRAME
Definition vpRobot.h:77
@ CAMERA_FRAME
Definition vpRobot.h:81
@ STATE_POSITION_CONTROL
Initialize the position controller.
Definition vpRobot.h:65
@ STATE_VELOCITY_CONTROL
Initialize the velocity controller.
Definition vpRobot.h:64
#define vpCTRACE
Definition vpDebug.h:362
#define vpERROR_TRACE
Definition vpDebug.h:423