Visual Servoing Platform
version 3.7.0
Toggle main menu visibility
Loading...
Searching...
No Matches
frankaSavePosition.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
* Franka robot tool.
32
*/
33
38
39
#include <iostream>
40
41
#include <visp3/core/vpConfig.h>
42
#include <visp3/robot/vpRobotFranka.h>
43
44
#if defined(VISP_HAVE_FRANKA)
45
46
int
main(
int
argc,
char
**argv)
47
{
48
#ifdef ENABLE_VISP_NAMESPACE
49
using namespace
VISP_NAMESPACE_NAME
;
50
#endif
51
std::string opt_robot_ip =
"192.168.1.1"
;
52
std::string opt_position_filename =
"position.pos"
;
53
54
for
(
int
i = 1;
i
< argc;
i
++) {
55
if
(std::string(argv[i]) ==
"--ip"
&& i + 1 < argc) {
56
opt_robot_ip = std::string(argv[i + 1]);
57
}
58
else
if
(std::string(argv[i]) ==
"--save"
&& i + 1 < argc) {
59
opt_position_filename = std::string(argv[i + 1]);
60
}
61
else
if
(std::string(argv[i]) ==
"--help"
|| std::string(argv[i]) ==
"-h"
) {
62
std::cout <<
"Save Panda robot position in a file."
<< std::endl;
63
std::cout <<
"Usage:\n"
<< std::endl;
64
std::cout << argv[0] <<
" [--ip <default "
<< opt_robot_ip <<
">] [--save <position file name>] [--help] [-h]\n"
65
<< std::endl;
66
std::cout <<
"Example:\n"
<< argv[0] <<
" --ip 192.168.100.1 --save position.pos\n"
<< std::endl;
67
68
return
EXIT_SUCCESS;
69
}
70
}
71
72
vpRobotFranka
robot;
73
74
try
{
75
robot.connect(opt_robot_ip);
76
77
vpColVector
q;
78
robot.getPosition(
vpRobot::JOINT_STATE
, q);
79
robot.savePosFile(opt_position_filename, q);
80
81
std::cout <<
"Robot position saved in \""
<< opt_position_filename <<
"\""
<< std::endl;
82
}
83
catch
(
const
vpException
&e) {
84
std::cout <<
"ViSP exception: "
<<
e
.what() << std::endl;
85
std::cout <<
"Stop the robot "
<< std::endl;
86
robot.setRobotState(
vpRobot::STATE_STOP
);
87
return
EXIT_FAILURE;
88
}
89
catch
(
const
franka::NetworkException &e) {
90
std::cout <<
"Franka network exception: "
<<
e
.what() << std::endl;
91
std::cout <<
"Check if you are connected to the Franka robot"
92
<<
" or if you specified the right IP using --ip command line option set by default to 192.168.1.1. "
93
<< std::endl;
94
return
EXIT_FAILURE;
95
}
96
catch
(
const
std::exception &e) {
97
std::cout <<
"Franka exception: "
<<
e
.what() << std::endl;
98
return
EXIT_FAILURE;
99
}
100
101
return
EXIT_SUCCESS;
102
}
103
#else
104
int
main()
105
{
106
#if !defined(VISP_HAVE_FRANKA)
107
std::cout <<
"Install libfranka."
<< std::endl;
108
#endif
109
return
EXIT_SUCCESS;
110
}
111
#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
vpRobotFranka
Definition
vpRobotFranka.h:227
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-franka
frankaSavePosition.cpp
Generated by
1.17.0