42 #include <visp3/core/vpConfig.h>
44 #if defined(VISP_HAVE_FRANKA)
46 #include <visp3/robot/vpRobotFranka.h>
48 int main(
int argc,
char **argv)
50 #ifdef ENABLE_VISP_NAMESPACE
53 std::string robot_ip =
"192.168.1.1";
55 for (
int i = 1; i < argc; i++) {
56 if (std::string(argv[i]) ==
"--ip" && i + 1 < argc) {
57 robot_ip = std::string(argv[i + 1]);
59 else if (std::string(argv[i]) ==
"--help" || std::string(argv[i]) ==
"-h") {
60 std::cout << argv[0] <<
" [--ip 192.168.1.1] [--help] [-h]"
67 std::cout <<
"-- Start test 1/4" << std::endl;
69 robot.connect(robot_ip);
73 for (
unsigned i = 0; i < 10; i++) {
75 std::cout <<
"Joint position: " << q.
t() << std::endl;
81 std::cout <<
"fMe pose vector: " << fPe.
t() << std::endl;
85 std::cout <<
"ViSP exception: " << e.
what() << std::endl;
88 catch (
const franka::NetworkException &e) {
89 std::cout <<
"Franka network exception: " << e.what() << std::endl;
90 std::cout <<
"Check if you are connected to the Franka robot"
91 <<
" or if you specified the right IP using --ip command"
92 <<
" line option set by default to 192.168.1.1. " << std::endl;
95 catch (
const std::exception &e) {
96 std::cout <<
"Franka exception: " << e.what() << std::endl;
101 std::cout <<
"-- Start test 2/4" << std::endl;
104 franka::Robot *handler = robot.getHandler();
107 std::array<double, 16> pose = handler->readOnce().O_T_EE;
109 for (
unsigned int i = 0; i < 4; i++) {
110 for (
unsigned int j = 0; j < 4; j++) {
111 oMee[i][j] = pose[j * 4 + i];
114 std::cout <<
"oMee: \n" << oMee << std::endl;
117 pose = handler->readOnce().F_T_EE;
119 for (
unsigned int i = 0; i < 4; i++) {
120 for (
unsigned int j = 0; j < 4; j++) {
121 fMee[i][j] = pose[j * 4 + i];
124 std::cout <<
"fMee: \n" << fMee << std::endl;
127 pose = handler->readOnce().EE_T_K;
129 for (
unsigned int i = 0; i < 4; i++) {
130 for (
unsigned int j = 0; j < 4; j++) {
131 eeMk[i][j] = pose[j * 4 + i];
134 std::cout <<
"eeMk: \n" << eeMk << std::endl;
137 std::cout <<
"ViSP exception: " << e.
what() << std::endl;
140 catch (
const franka::NetworkException &e) {
141 std::cout <<
"Franka network exception: " << e.what() << std::endl;
142 std::cout <<
"Check if you are connected to the Franka robot"
143 <<
" or if you specified the right IP using --ip command line option set by default to 192.168.1.1. "
147 catch (
const std::exception &e) {
148 std::cout <<
"Franka exception: " << e.what() << std::endl;
153 std::cout <<
"-- Start test 3/4" << std::endl;
155 robot.connect(robot_ip);
159 std::cout <<
"Mass matrix:\n" << mass << std::endl;
162 robot.getGravity(gravity);
163 std::cout <<
"Gravity vector: " << gravity.
t() << std::endl;
166 robot.getCoriolis(coriolis);
167 std::cout <<
"Coriolis vector: " << coriolis.
t() << std::endl;
170 std::cout <<
"ViSP exception: " << e.
what() << std::endl;
173 catch (
const franka::NetworkException &e) {
174 std::cout <<
"Franka network exception: " << e.what() << std::endl;
175 std::cout <<
"Check if you are connected to the Franka robot"
176 <<
" or if you specified the right IP using --ip command line option set by default to 192.168.1.1. "
180 catch (
const std::exception &e) {
181 std::cout <<
"Franka exception: " << e.what() << std::endl;
186 std::cout <<
"-- Start test 4/4" << std::endl;
188 robot.connect(robot_ip);
192 std::cout <<
"Joint position: " << q.
t() << std::endl;
196 std::cout <<
"Jacobian fJe:\n" << fJe << std::endl;
198 robot.get_fJe(q, fJe);
199 std::cout <<
"Jacobian fJe:\n" << fJe << std::endl;
203 std::cout <<
"Jacobian eJe:\n" << eJe << std::endl;
206 std::cout <<
"Jacobian eJe:\n" << eJe << std::endl;
209 std::cout <<
"ViSP exception: " << e.
what() << std::endl;
212 catch (
const franka::NetworkException &e) {
213 std::cout <<
"Franka network exception: " << e.what() << std::endl;
214 std::cout <<
"Check if you are connected to the Franka robot"
215 <<
" or if you specified the right IP using --ip command line option set by default to 192.168.1.1. "
219 catch (
const std::exception &e) {
220 std::cout <<
"Franka exception: " << e.what() << std::endl;
224 std::cout <<
"The end" << std::endl;
229 int main() { std::cout <<
"ViSP is not build with libfranka..." << std::endl; }
Implementation of column vector and the associated operations.
error that can be emitted by ViSP classes.
const char * what() const
Implementation of an homogeneous matrix and operations on such kind of matrices.
Implementation of a matrix and operations on matrices.
Implementation of a pose vector and operations on poses.
void get_eJe(vpMatrix &eJe) VP_OVERRIDE
VISP_EXPORT int wait(double t0, double t)