42#include <visp3/core/vpConfig.h>
44#ifdef VISP_HAVE_FLIR_PTU_SDK
46#include <visp3/robot/vpRobotFlirPtu.h>
48int main(
int argc,
char **argv)
50#ifdef ENABLE_VISP_NAMESPACE
53 std::string opt_portname;
54 int opt_baudrate = 9600;
55 bool opt_network =
false;
56 bool opt_reset =
false;
59 std::cout <<
"To see how to use this test, run: " << argv[0] <<
" --help" << std::endl;
63 for (
int i = 1;
i < argc;
i++) {
64 if ((std::string(argv[i]) ==
"--portname" || std::string(argv[i]) ==
"-p") && (i + 1 < argc)) {
65 opt_portname = std::string(argv[i + 1]);
67 else if ((std::string(argv[i]) ==
"--baudrate" || std::string(argv[i]) ==
"-b") && (i + 1 < argc)) {
68 opt_baudrate = std::atoi(argv[i + 1]);
70 else if ((std::string(argv[i]) ==
"--network" || std::string(argv[i]) ==
"-n")) {
73 else if ((std::string(argv[i]) ==
"--reset" || std::string(argv[i]) ==
"-r")) {
76 else if (std::string(argv[i]) ==
"--help" || std::string(argv[i]) ==
"-h") {
77 std::cout <<
"SYNOPSIS" << std::endl
78 <<
" " << argv[0] <<
" [--portname <portname>] [--baudrate <rate>] [--network] [--reset] [--help] [-h]"
81 <<
"DESCRIPTION" << std::endl
82 <<
" --portname, -p <portname>" << std::endl
83 <<
" Set serial or tcp port name." << std::endl
85 <<
" --baudrate, -b <rate>" << std::endl
86 <<
" Set serial communication baud rate. Default: " << opt_baudrate <<
"." << std::endl
88 <<
" --network, -n" << std::endl
89 <<
" Get PTU network information (Hostname, IP, Gateway) and exit. " << std::endl
91 <<
" --reset, -r" << std::endl
92 <<
" Reset PTU axis and exit. " << std::endl
94 <<
" --help, -h" << std::endl
95 <<
" Print this helper message. " << std::endl
97 <<
"EXAMPLE" << std::endl
98 <<
" - How to get network IP" << std::endl
100 <<
" $ " << argv[0] <<
" -p /dev/ttyUSB0 --network" << std::endl
102 <<
" $ " << argv[0] <<
" --portname COM1 --network" << std::endl
104 <<
" Try to connect FLIR PTU to port: /dev/ttyUSB0 with baudrate: 9600" << std::endl
105 <<
" PTU HostName: PTU-5" << std::endl
106 <<
" PTU IP : 169.254.110.254" << std::endl
107 <<
" PTU Gateway : 0.0.0.0" << std::endl
108 <<
" - How to run this binary using serial communication" << std::endl
110 <<
" $ " << argv[0] <<
" --portname COM1" << std::endl
112 <<
" $ " << argv[0] <<
" --portname /dev/ttyUSB0" << std::endl
114 <<
" - How to run this binary using network communication" << std::endl
115 <<
" $ " << argv[0] <<
" --portname tcp:169.254.110.254" << std::endl;
121 if (opt_portname.empty()) {
122 std::cout <<
"Error, portname unspecified. Run " << argv[0] <<
" --help" << std::endl;
132 std::cout <<
"Try to connect FLIR PTU to port: " << opt_portname <<
" with baudrate: " << opt_baudrate << std::endl;
133 robot.connect(opt_portname, opt_baudrate);
136 std::cout <<
"PTU HostName: " << robot.getNetworkHostName() << std::endl;
137 std::cout <<
"PTU IP : " << robot.getNetworkIP() << std::endl;
138 std::cout <<
"PTU Gateway : " << robot.getNetworkGateway() << std::endl;
143 std::cout <<
"Reset PTU axis" << std::endl;
149 std::cout <<
"** Test limits getter" << std::endl;
151 std::cout <<
"Pan pos min/max [deg]: " <<
vpMath::deg(robot.getPanPosLimits()[0]) <<
" "
152 <<
vpMath::deg(robot.getPanPosLimits()[1]) << std::endl;
153 std::cout <<
"Tilt pos min/max [deg]: " <<
vpMath::deg(robot.getTiltPosLimits()[0]) <<
" "
154 <<
vpMath::deg(robot.getTiltPosLimits()[1]) << std::endl;
155 std::cout <<
"Pan/tilt vel max [deg/s]: " <<
vpMath::deg(robot.getPanTiltVelMax()[0]) <<
" "
156 <<
vpMath::deg(robot.getPanTiltVelMax()[1]) << std::endl
161 std::cout <<
"** Test limits setter" << std::endl;
169 robot.setPanPosLimits(pan_pos_limits);
170 robot.setTiltPosLimits(tilt_pos_limits);
172 std::cout <<
"Modified user min/max limits: " << std::endl;
173 std::cout <<
"Pan pos min/max [deg]: " <<
vpMath::deg(robot.getPanPosLimits()[0]) <<
" "
174 <<
vpMath::deg(robot.getPanPosLimits()[1]) << std::endl;
175 std::cout <<
"Tilt pos min/max [deg]: " <<
vpMath::deg(robot.getTiltPosLimits()[0]) <<
" "
176 <<
vpMath::deg(robot.getTiltPosLimits()[1]) << std::endl;
177 std::cout <<
"Pan/tilt vel max [deg/s]: " <<
vpMath::deg(robot.getPanTiltVelMax()[0]) <<
" "
178 <<
vpMath::deg(robot.getPanTiltVelMax()[1]) << std::endl
183 std::cout <<
"** Test position getter" << std::endl;
185 std::cout <<
"Current position [deg]: " <<
vpMath::deg(q_mes[0]) <<
" " <<
vpMath::deg(q_mes[1]) << std::endl;
187 std::cout <<
"Initialisation done." << std::endl << std::endl;
191 std::cout <<
"** Test joint positioning" << std::endl;
193 robot.setMaxRotationVelocity(std::min<double>(robot.getPanTiltVelMax()[0], robot.getPanTiltVelMax()[1]) /
198 std::cout <<
"Enter a caracter to apply" << std::endl;
199 scanf(
"%d", &answer);
201 robot.setPositioningVelocity(50);
205 std::cout <<
"Position reached [deg]: " <<
vpMath::deg(q_mes[0]) <<
" " <<
vpMath::deg(q_mes[1]) << std::endl
210 std::cout <<
"** Test joint positioning" << std::endl;
214 std::cout <<
"Set joint position: " <<
vpMath::deg(q[0]) <<
" " <<
vpMath::deg(q[1]) <<
"[deg]" << std::endl;
215 std::cout <<
"Enter a caracter to apply" << std::endl;
216 scanf(
"%d", &answer);
221 std::cout <<
"Position reached [deg]: " <<
vpMath::deg(q_mes[0]) <<
" " <<
vpMath::deg(q_mes[1]) << std::endl
226 std::cout <<
"** Test joint velocity" << std::endl;
234 std::cout <<
"Enter a caracter to apply" << std::endl;
235 scanf(
"%d", &answer);
253 std::cout <<
"** Test cartesian velocity with robot Jacobien eJe" << std::endl;
259 std::cout <<
"Set cartesian velocity in end-effector frame for 4s: " << v_e[0] <<
" " << v_e[1] <<
" " << v_e[2]
261 <<
" [deg/s]" << std::endl;
262 std::cout <<
"Enter a caracter to apply" << std::endl;
263 scanf(
"%d", &answer);
269 vpColVector qdot = robot.get_eJe().pseudoInverse() * v_e;
281 std::cout <<
"** The end" << std::endl;
284 std::cout <<
"Catch Flir Ptu signal exception: " <<
e.getMessage() << std::endl;
288 std::cout <<
"Catch Flir Ptu exception: " <<
e.getMessage() << std::endl;
296 std::cout <<
"You do not have an Flir Ptu robot connected to your computer..." << std::endl;
Implementation of column vector and the associated operations.
error that can be emitted by ViSP classes.
static double rad(double deg)
static double deg(double rad)
Error that can be emitted by the vpRobot class and its derivatives.
@ STATE_POSITION_CONTROL
Initialize the position controller.
@ STATE_VELOCITY_CONTROL
Initialize the velocity controller.
@ STATE_STOP
Stops robot motion especially in velocity and acceleration control.
VISP_EXPORT double measureTimeMs()
VISP_EXPORT void sleepMs(double t)