Visual Servoing Platform
version 3.7.0
Toggle main menu visibility
Loading...
Searching...
No Matches
UniversalRobotsSavePosition.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
* Universal Robots robot tool.
32
*/
33
38
39
#include <iostream>
40
41
#include <visp3/core/vpConfig.h>
42
43
#if defined(VISP_HAVE_UR_RTDE)
44
45
#include <visp3/robot/vpRobotUniversalRobots.h>
46
47
int
main(
int
argc,
char
**argv)
48
{
49
#ifdef ENABLE_VISP_NAMESPACE
50
using namespace
VISP_NAMESPACE_NAME
;
51
#endif
52
53
std::string opt_robot_ip =
"192.168.0.100"
;
54
std::string opt_position_filename =
"position.pos"
;
55
56
for
(
int
i = 1;
i
< argc;
i
++) {
57
if
(std::string(argv[i]) ==
"--ip"
&& i + 1 < argc) {
58
opt_robot_ip = std::string(argv[i + 1]);
59
}
60
else
if
(std::string(argv[i]) ==
"--save"
&& i + 1 < argc) {
61
opt_position_filename = std::string(argv[i + 1]);
62
}
63
else
if
(std::string(argv[i]) ==
"--help"
|| std::string(argv[i]) ==
"-h"
) {
64
std::cout <<
"Save UR robot position in a file."
<< std::endl;
65
std::cout <<
"Usage:\n"
<< std::endl;
66
std::cout << argv[0] <<
" [--ip <default "
<< opt_robot_ip <<
">] [--save <position file name>] [--help] [-h]\n"
67
<< std::endl;
68
std::cout <<
"Example:\n"
<< argv[0] <<
" --ip 192.168.0.100 --save position.pos\n"
<< std::endl;
69
70
return
EXIT_SUCCESS;
71
}
72
}
73
74
vpRobotUniversalRobots
robot;
75
76
try
{
77
robot.connect(opt_robot_ip);
78
79
vpColVector
q;
80
robot.getPosition(
vpRobot::JOINT_STATE
, q);
81
robot.savePosFile(opt_position_filename, q);
82
83
std::cout <<
"Robot position saved in \""
<< opt_position_filename <<
"\""
<< std::endl;
84
}
85
catch
(
const
vpException
&e) {
86
std::cout <<
"ViSP exception: "
<<
e
.what() << std::endl;
87
std::cout <<
"Stop the robot "
<< std::endl;
88
robot.setRobotState(
vpRobot::STATE_STOP
);
89
return
EXIT_FAILURE;
90
}
91
catch
(
const
std::exception &e) {
92
std::cout <<
"ur_rtde exception: "
<<
e
.what() << std::endl;
93
return
EXIT_FAILURE;
94
}
95
96
return
EXIT_SUCCESS;
97
}
98
#else
99
int
main()
100
{
101
#if !defined(VISP_HAVE_UR_RTDE)
102
std::cout <<
"ViSP is not build with libur_rtde 3rd party used to control a robot from Universal Robots..."
103
<< std::endl;
104
#endif
105
return
EXIT_SUCCESS;
106
}
107
#endif
vpColVector
Implementation of column vector and the associated operations.
Definition
vpColVector.h:191
vpException
error that can be emitted by ViSP classes.
Definition
vpException.h:60
vpRobotUniversalRobots
Definition
vpRobotUniversalRobots.h:65
vpRobot::JOINT_STATE
@ JOINT_STATE
Definition
vpRobot.h:79
vpRobot::STATE_STOP
@ STATE_STOP
Stops robot motion especially in velocity and acceleration control.
Definition
vpRobot.h:63
VISP_NAMESPACE_NAME
Definition
vpEigenConversion.h:44
ibvs-four-points.e
e
Definition
ibvs-four-points.py:272
yolo-centering-task-afma6.i
i
Definition
yolo-centering-task-afma6.py:329
example
servo-universal-robots
UniversalRobotsSavePosition.cpp
Generated by
1.17.0