47 #include <visp3/core/vpConfig.h> 49 #ifdef VISP_HAVE_FLIR_PTU_SDK 51 #include <visp3/robot/vpRobotFlirPtu.h> 53 int 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);
132 std::cout <<
"PTU IP : " << robot.
getNetworkIP() <<std::endl;
138 std::cout <<
"Reset PTU axis" <<std::endl;
144 std::cout <<
"** Test limits getter" << std::endl;
152 std::cout <<
"** Test limits setter" << std::endl;
163 std::cout <<
"Modified user min/max limits: " << 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);
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;
void setTiltPosLimits(const vpColVector &tilt_limits)
Error that can be emited by the vpRobot class and its derivates.
void setPanPosLimits(const vpColVector &pan_limits)
vpColVector getTiltPosLimits()
std::string getNetworkHostName()
void setPositioningVelocity(double velocity)
Initialize the position controller.
error that can be emited by ViSP classes.
VISP_EXPORT double measureTimeMs()
void setMaxRotationVelocity(double maxVr)
vpColVector getPanPosLimits()
std::string getNetworkGateway()
Initialize the velocity controller.
vpRobot::vpRobotStateType setRobotState(vpRobot::vpRobotStateType newState)
vpColVector getPanTiltVelMax()
VISP_EXPORT void sleepMs(double t)
void get_eJe(vpMatrix &eJe)
void getPosition(const vpRobot::vpControlFrameType frame, vpColVector &q)
static double rad(double deg)
Stops robot motion especially in velocity and acceleration control.
const char * getMessage(void) const
void setPosition(const vpRobot::vpControlFrameType frame, const vpColVector &q)
void connect(const std::string &portname, int baudrate=9600)
static double deg(double rad)
std::string getNetworkIP()
Implementation of column vector and the associated operations.
void setVelocity(const vpRobot::vpControlFrameType frame, const vpColVector &vel)