44 #include <visp3/core/vpConfig.h>
46 #ifdef VISP_HAVE_FLIR_PTU_SDK
48 #include <visp3/robot/vpRobotFlirPtu.h>
50 int main(
int argc,
char **argv)
52 std::string opt_portname;
53 int opt_baudrate = 9600;
54 bool opt_network =
false;
55 bool opt_reset =
false;
58 std::cout <<
"To see how to use this test, run: " << argv[0] <<
" --help" << std::endl;
62 for (
int i = 1; i < argc; i++) {
63 if ((std::string(argv[i]) ==
"--portname" || std::string(argv[i]) ==
"-p") && (i + 1 < argc)) {
64 opt_portname = std::string(argv[i + 1]);
66 else if ((std::string(argv[i]) ==
"--baudrate" || std::string(argv[i]) ==
"-b") && (i + 1 < argc)) {
67 opt_baudrate = std::atoi(argv[i + 1]);
69 else if ((std::string(argv[i]) ==
"--network" || std::string(argv[i]) ==
"-n")) {
72 else if ((std::string(argv[i]) ==
"--reset" || std::string(argv[i]) ==
"-r")) {
75 else if (std::string(argv[i]) ==
"--help" || std::string(argv[i]) ==
"-h") {
76 std::cout <<
"SYNOPSIS" << std::endl
77 <<
" " << argv[0] <<
" [--portname <portname>] [--baudrate <rate>] [--network] [--reset] [--help] [-h]"
80 <<
"DESCRIPTION" << std::endl
81 <<
" --portname, -p <portname>" << std::endl
82 <<
" Set serial or tcp port name." << std::endl
84 <<
" --baudrate, -b <rate>" << std::endl
85 <<
" Set serial communication baud rate. Default: " << opt_baudrate <<
"." << std::endl
87 <<
" --network, -n" << std::endl
88 <<
" Get PTU network information (Hostname, IP, Gateway) and exit. " << std::endl
90 <<
" --reset, -r" << std::endl
91 <<
" Reset PTU axis and exit. " << std::endl
93 <<
" --help, -h" << std::endl
94 <<
" Print this helper message. " << std::endl
96 <<
"EXAMPLE" << std::endl
97 <<
" - How to get network IP" << std::endl
99 <<
" $ " << argv[0] <<
" -p /dev/ttyUSB0 --network" << std::endl
101 <<
" $ " << argv[0] <<
" --portname COM1 --network" << std::endl
103 <<
" Try to connect FLIR PTU to port: /dev/ttyUSB0 with baudrate: 9600" << std::endl
104 <<
" PTU HostName: PTU-5" << std::endl
105 <<
" PTU IP : 169.254.110.254" << std::endl
106 <<
" PTU Gateway : 0.0.0.0" << std::endl
107 <<
" - How to run this binary using serial communication" << std::endl
109 <<
" $ " << argv[0] <<
" --portname COM1" << std::endl
111 <<
" $ " << argv[0] <<
" --portname /dev/ttyUSB0" << std::endl
113 <<
" - How to run this binary using network communication" << std::endl
114 <<
" $ " << argv[0] <<
" --portname tcp:169.254.110.254" << std::endl;
120 if (opt_portname.empty()) {
121 std::cout <<
"Error, portname unspecified. Run " << argv[0] <<
" --help" << std::endl;
131 std::cout <<
"Try to connect FLIR PTU to port: " << opt_portname <<
" with baudrate: " << opt_baudrate << std::endl;
132 robot.connect(opt_portname, opt_baudrate);
135 std::cout <<
"PTU HostName: " << robot.getNetworkHostName() << std::endl;
136 std::cout <<
"PTU IP : " << robot.getNetworkIP() << std::endl;
137 std::cout <<
"PTU Gateway : " << robot.getNetworkGateway() << std::endl;
142 std::cout <<
"Reset PTU axis" << std::endl;
148 std::cout <<
"** Test limits getter" << std::endl;
150 std::cout <<
"Pan pos min/max [deg]: " <<
vpMath::deg(robot.getPanPosLimits()[0]) <<
" "
151 <<
vpMath::deg(robot.getPanPosLimits()[1]) << std::endl;
152 std::cout <<
"Tilt pos min/max [deg]: " <<
vpMath::deg(robot.getTiltPosLimits()[0]) <<
" "
153 <<
vpMath::deg(robot.getTiltPosLimits()[1]) << std::endl;
154 std::cout <<
"Pan/tilt vel max [deg/s]: " <<
vpMath::deg(robot.getPanTiltVelMax()[0]) <<
" "
155 <<
vpMath::deg(robot.getPanTiltVelMax()[1]) << std::endl
160 std::cout <<
"** Test limits setter" << std::endl;
168 robot.setPanPosLimits(pan_pos_limits);
169 robot.setTiltPosLimits(tilt_pos_limits);
171 std::cout <<
"Modified user min/max limits: " << std::endl;
172 std::cout <<
"Pan pos min/max [deg]: " <<
vpMath::deg(robot.getPanPosLimits()[0]) <<
" "
173 <<
vpMath::deg(robot.getPanPosLimits()[1]) << std::endl;
174 std::cout <<
"Tilt pos min/max [deg]: " <<
vpMath::deg(robot.getTiltPosLimits()[0]) <<
" "
175 <<
vpMath::deg(robot.getTiltPosLimits()[1]) << std::endl;
176 std::cout <<
"Pan/tilt vel max [deg/s]: " <<
vpMath::deg(robot.getPanTiltVelMax()[0]) <<
" "
177 <<
vpMath::deg(robot.getPanTiltVelMax()[1]) << std::endl
182 std::cout <<
"** Test position getter" << std::endl;
184 std::cout <<
"Current position [deg]: " <<
vpMath::deg(q_mes[0]) <<
" " <<
vpMath::deg(q_mes[1]) << std::endl;
186 std::cout <<
"Initialisation done." << std::endl << std::endl;
190 std::cout <<
"** Test joint positioning" << std::endl;
197 std::cout <<
"Enter a caracter to apply" << std::endl;
198 scanf(
"%d", &answer);
200 robot.setPositioningVelocity(50);
204 std::cout <<
"Position reached [deg]: " <<
vpMath::deg(q_mes[0]) <<
" " <<
vpMath::deg(q_mes[1]) << std::endl
209 std::cout <<
"** Test joint positioning" << std::endl;
213 std::cout <<
"Set joint position: " <<
vpMath::deg(q[0]) <<
" " <<
vpMath::deg(q[1]) <<
"[deg]" << std::endl;
214 std::cout <<
"Enter a caracter to apply" << std::endl;
215 scanf(
"%d", &answer);
220 std::cout <<
"Position reached [deg]: " <<
vpMath::deg(q_mes[0]) <<
" " <<
vpMath::deg(q_mes[1]) << std::endl
225 std::cout <<
"** Test joint velocity" << std::endl;
233 std::cout <<
"Enter a caracter to apply" << std::endl;
234 scanf(
"%d", &answer);
252 std::cout <<
"** Test cartesian velocity with robot Jacobien eJe" << std::endl;
258 std::cout <<
"Set cartesian velocity in end-effector frame for 4s: " << v_e[0] <<
" " << v_e[1] <<
" " << v_e[2]
260 <<
" [deg/s]" << std::endl;
261 std::cout <<
"Enter a caracter to apply" << std::endl;
262 scanf(
"%d", &answer);
280 std::cout <<
"** The end" << std::endl;
283 std::cout <<
"Catch Flir Ptu signal exception: " << e.
getMessage() << std::endl;
287 std::cout <<
"Catch Flir Ptu exception: " << e.
getMessage() << std::endl;
295 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.
const char * getMessage() const
static double rad(double deg)
static double deg(double rad)
Error that can be emitted by the vpRobot class and its derivatives.
void get_eJe(vpMatrix &eJe) vp_override
void setVelocity(const vpRobot::vpControlFrameType frame, const vpColVector &vel) vp_override
@ 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()