47#include <visp3/core/vpConfig.h>
49#ifdef VISP_HAVE_FLIR_PTU_SDK
51#include <visp3/robot/vpRobotFlirPtu.h>
53int main(
int argc,
char **argv)
55 std::string opt_portname;
56 int opt_baudrate = 9600;
57 bool opt_network =
false;
58 bool opt_reset =
false;
61 std::cout <<
"To see how to use this test, run: " << argv[0] <<
" --help" << std::endl;
65 for (
int i = 1; i < argc; i++) {
66 if ((std::string(argv[i]) ==
"--portname" || std::string(argv[i]) ==
"-p") && (i + 1 < argc)) {
67 opt_portname = std::string(argv[i + 1]);
69 else if ((std::string(argv[i]) ==
"--baudrate" || std::string(argv[i]) ==
"-b") && (i + 1 < argc)) {
70 opt_baudrate = std::atoi(argv[i + 1]);
72 else if ((std::string(argv[i]) ==
"--network" || std::string(argv[i]) ==
"-n")) {
75 else if ((std::string(argv[i]) ==
"--reset" || std::string(argv[i]) ==
"-r")) {
78 else if (std::string(argv[i]) ==
"--help" || std::string(argv[i]) ==
"-h") {
79 std::cout <<
"SYNOPSIS" << std::endl
80 <<
" " << argv[0] <<
" [--portname <portname>] [--baudrate <rate>] [--network] [--reset] [--help] [-h]" << std::endl << std::endl
81 <<
"DESCRIPTION" << std::endl
82 <<
" --portname, -p <portname>" << std::endl
83 <<
" Set serial or tcp port name." << std::endl << std::endl
84 <<
" --baudrate, -b <rate>" << std::endl
85 <<
" Set serial communication baud rate. Default: " << opt_baudrate <<
"." << std::endl << std::endl
86 <<
" --network, -n" << std::endl
87 <<
" Get PTU network information (Hostname, IP, Gateway) and exit. " << std::endl << std::endl
88 <<
" --reset, -r" << std::endl
89 <<
" Reset PTU axis and exit. " << std::endl << std::endl
90 <<
" --help, -h" << std::endl
91 <<
" Print this helper message. " << std::endl << std::endl
92 <<
"EXAMPLE" << std::endl
93 <<
" - How to get network IP" << std::endl
95 <<
" $ " << argv[0] <<
" -p /dev/ttyUSB0 --network" << std::endl
97 <<
" $ " << argv[0] <<
" --portname COM1 --network" << std::endl
99 <<
" Try to connect FLIR PTU to port: /dev/ttyUSB0 with baudrate: 9600" << std::endl
100 <<
" PTU HostName: PTU-5" << std::endl
101 <<
" PTU IP : 169.254.110.254" << std::endl
102 <<
" PTU Gateway : 0.0.0.0" << std::endl
103 <<
" - How to run this binary using serial communication" << std::endl
105 <<
" $ " << argv[0] <<
" --portname COM1" << std::endl
107 <<
" $ " << argv[0] <<
" --portname /dev/ttyUSB0" << std::endl
109 <<
" - How to run this binary using network communication" << std::endl
110 <<
" $ " << argv[0] <<
" --portname tcp:169.254.110.254" << std::endl;
116 if (opt_portname.empty()) {
117 std::cout <<
"Error, portname unspecified. Run " << argv[0] <<
" --help" << std::endl;
127 std::cout <<
"Try to connect FLIR PTU to port: " << opt_portname <<
" with baudrate: " << opt_baudrate << std::endl;
128 robot.connect(opt_portname, opt_baudrate);
131 std::cout <<
"PTU HostName: " << robot.getNetworkHostName() <<std::endl;
132 std::cout <<
"PTU IP : " << robot.getNetworkIP() <<std::endl;
133 std::cout <<
"PTU Gateway : " << robot.getNetworkGateway() <<std::endl;
138 std::cout <<
"Reset PTU axis" <<std::endl;
144 std::cout <<
"** Test limits getter" << std::endl;
146 std::cout <<
"Pan pos min/max [deg]: " <<
vpMath::deg(robot.getPanPosLimits()[0]) <<
" " <<
vpMath::deg(robot.getPanPosLimits()[1]) << std::endl;
147 std::cout <<
"Tilt pos min/max [deg]: " <<
vpMath::deg(robot.getTiltPosLimits()[0]) <<
" " <<
vpMath::deg(robot.getTiltPosLimits()[1]) << std::endl;
148 std::cout <<
"Pan/tilt vel max [deg/s]: " <<
vpMath::deg(robot.getPanTiltVelMax()[0]) <<
" " <<
vpMath::deg(robot.getPanTiltVelMax()[1]) << std::endl << std::endl;
152 std::cout <<
"** Test limits setter" << std::endl;
160 robot.setPanPosLimits(pan_pos_limits);
161 robot.setTiltPosLimits(tilt_pos_limits);
163 std::cout <<
"Modified user min/max limits: " << std::endl;
164 std::cout <<
"Pan pos min/max [deg]: " <<
vpMath::deg(robot.getPanPosLimits()[0]) <<
" " <<
vpMath::deg(robot.getPanPosLimits()[1]) << std::endl;
165 std::cout <<
"Tilt pos min/max [deg]: " <<
vpMath::deg(robot.getTiltPosLimits()[0]) <<
" " <<
vpMath::deg(robot.getTiltPosLimits()[1]) << std::endl;
166 std::cout <<
"Pan/tilt vel max [deg/s]: " <<
vpMath::deg(robot.getPanTiltVelMax()[0]) <<
" " <<
vpMath::deg(robot.getPanTiltVelMax()[1]) << std::endl << std::endl;
170 std::cout <<
"** Test position getter" << std::endl;
172 std::cout <<
"Current position [deg]: " <<
vpMath::deg(q_mes[0]) <<
" " <<
vpMath::deg(q_mes[1]) << std::endl;
174 std::cout <<
"Initialisation done." << std::endl << std::endl;
178 std::cout <<
"** Test joint positioning" << std::endl;
184 std::cout <<
"Enter a caracter to apply" << std::endl;
185 scanf(
"%d", &answer);
187 robot.setPositioningVelocity(50);
191 std::cout <<
"Position reached [deg]: " <<
vpMath::deg(q_mes[0]) <<
" " <<
vpMath::deg(q_mes[1]) << std::endl << std::endl;
195 std::cout <<
"** Test joint positioning" << std::endl;
199 std::cout <<
"Set joint position: " <<
vpMath::deg(q[0]) <<
" " <<
vpMath::deg(q[1]) <<
"[deg]" << std::endl;
200 std::cout <<
"Enter a caracter to apply" << std::endl;
201 scanf(
"%d", &answer);
206 std::cout <<
"Position reached [deg]: " <<
vpMath::deg(q_mes[0]) <<
" " <<
vpMath::deg(q_mes[1]) << std::endl << std::endl;
210 std::cout <<
"** Test joint velocity" << std::endl;
216 std::cout <<
"Set velocity for 4s: " <<
vpMath::deg(qdot[0]) <<
" " <<
vpMath::deg(qdot[1]) <<
" [deg/s]" << std::endl;
217 std::cout <<
"Enter a caracter to apply" << std::endl;
218 scanf(
"%d", &answer);
230 std::cout <<
"Position reached: " <<
vpMath::deg(q_mes[0]) <<
" " <<
vpMath::deg(q_mes[1]) <<
" [deg]" << std::endl << std::endl;
234 std::cout <<
"** Test cartesian velocity with robot Jacobien eJe" << std::endl;
240 std::cout <<
"Set cartesian velocity in end-effector frame for 4s: " << v_e[0] <<
" " << v_e[1] <<
" " << v_e[2] <<
" [m/s] "
242 std::cout <<
"Enter a caracter to apply" << std::endl;
243 scanf(
"%d", &answer);
256 std::cout <<
"Position reached: " <<
vpMath::deg(q_mes[0]) <<
" " <<
vpMath::deg(q_mes[1]) <<
" [deg]" << std::endl << std::endl;
259 std::cout <<
"** The end" << std::endl;
261 std::cout <<
"Catch Flir Ptu signal exception: " << e.
getMessage() << std::endl;
264 std::cout <<
"Catch Flir Ptu exception: " << e.
getMessage() << std::endl;
272 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 emited by ViSP classes.
const char * getMessage() const
static double rad(double deg)
static double deg(double rad)
Error that can be emited by the vpRobot class and its derivates.
void setVelocity(const vpRobot::vpControlFrameType frame, const vpColVector &vel)
void get_eJe(vpMatrix &eJe)
@ 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.
virtual vpRobotStateType setRobotState(const vpRobot::vpRobotStateType newState)
void setMaxRotationVelocity(double maxVr)
VISP_EXPORT void sleepMs(double t)
VISP_EXPORT double measureTimeMs()