Visual Servoing Platform version 3.7.0
Loading...
Searching...
No Matches
vpRobotKinova.h
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 * Interface for Kinova Jaco robot.
32 */
33
41
42#ifndef vpRobotKinova_h
43#define vpRobotKinova_h
44
45#include <visp3/core/vpConfig.h>
46
47#ifdef VISP_HAVE_JACOSDK
48
49#include <KinovaTypes.h>
50
51#ifdef __linux__
52#include <Kinova.API.CommLayerUbuntu.h>
53#include <Kinova.API.UsbCommandLayerUbuntu.h>
54#include <dlfcn.h>
55#include <stdio.h>
56#include <unistd.h>
57#include <vector>
58#elif _WIN32
59#include <CommandLayer.h>
60#include <CommunicationLayer.h>
61
62#if defined(__clang__)
63// Mute warning : non-portable path to file '<WinSock2.h>'; specified path differs in case from file name on disk [-Wnonportable-system-include-path]
64# pragma clang diagnostic push
65# pragma clang diagnostic ignored "-Wnonportable-system-include-path"
66#endif
67
68#include <winsock2.h>
69
70#if defined(__clang__)
71# pragma clang diagnostic pop
72#endif
73
74// Mute warning with clang-cl
75// warning : non-portable path to file '<Windows.h>'; specified path differs in case from file name on disk [-Wnonportable-system-include-path]
76#if defined(__clang__)
77# pragma clang diagnostic push
78# pragma clang diagnostic ignored "-Wnonportable-system-include-path"
79#endif
80
81#include <windows.h>
82
83#if defined(__clang__)
84# pragma clang diagnostic pop
85#endif
86
87#include <conio.h>
88#include <iostream>
89#endif
90
91#include <visp3/core/vpHomogeneousMatrix.h>
92#include <visp3/robot/vpRobot.h>
93
112class VISP_EXPORT vpRobotKinova : public vpRobot
113{
114public:
115 typedef enum { CMD_LAYER_USB, CMD_LAYER_ETHERNET, CMD_LAYER_UNSET } CommandLayer;
116
118 virtual ~vpRobotKinova() VP_OVERRIDE;
119
120 int connect();
121
122 void get_eJe(vpMatrix &eJe) VP_OVERRIDE;
123 void get_fJe(vpMatrix &fJe) VP_OVERRIDE;
124
130
131 int getActiveDevice() const { return m_active_device; }
132 int getNumDevices() const { return m_devices_count; }
133 void getDisplacement(const vpRobot::vpControlFrameType frame, vpColVector &q) VP_OVERRIDE;
134 void getPosition(const vpRobot::vpControlFrameType frame, vpColVector &position) VP_OVERRIDE;
136
137 void homing();
138
143 void set_eMc(vpHomogeneousMatrix &eMc) { m_eMc = eMc; }
144 void setActiveDevice(int device);
149 void setCommandLayer(CommandLayer command_layer) { m_command_layer = command_layer; }
150 void setDoF(unsigned int dof);
151 void setPosition(const vpRobot::vpControlFrameType frame, const vpColVector &q) VP_OVERRIDE;
158 void setPluginLocation(const std::string &plugin_location) { m_plugin_location = plugin_location; }
159 void setVelocity(const vpRobot::vpControlFrameType frame, const vpColVector &vel) VP_OVERRIDE;
165 void setVerbose(bool verbose) { m_verbose = verbose; }
166
167protected:
168 void closePlugin();
169 void getJointPosition(vpColVector &q);
170 void init();
171 void loadPlugin();
172 void setCartVelocity(const vpRobot::vpControlFrameType frame, const vpColVector &v);
173 void setJointVelocity(const vpColVector &qdot);
174
175protected:
177 std::string m_plugin_location;
181 KinovaDevice *m_devices_list;
184
185#ifdef __linux__
186 void *m_command_layer_handle;
187#elif _WIN32
188 HINSTANCE m_command_layer_handle;
189#endif
190
191private:
192 int (*KinovaCloseAPI)();
193 int (*KinovaGetAngularCommand)(AngularPosition &);
194 int (*KinovaGetCartesianCommand)(CartesianPosition &);
195 int (*KinovaGetDevices)(KinovaDevice devices[MAX_KINOVA_DEVICE], int &result);
196 int (*KinovaInitFingers)();
197 int (*KinovaInitAPI)();
198 int (*KinovaMoveHome)();
199 int (*KinovaSendBasicTrajectory)(TrajectoryPoint command);
200 int (*KinovaSetActiveDevice)(KinovaDevice device);
201 int (*KinovaSetAngularControl)();
202 int (*KinovaSetCartesianControl)();
203};
204END_VISP_NAMESPACE
205#endif
206#endif
Implementation of column vector and the associated operations.
Implementation of an homogeneous matrix and operations on such kind of matrices.
Implementation of a matrix and operations on matrices.
Definition vpMatrix.h:175
Implementation of a pose vector and operations on poses.
void set_eMc(vpHomogeneousMatrix &eMc)
void setCommandLayer(CommandLayer command_layer)
KinovaDevice * m_devices_list
int getNumDevices() const
std::string m_plugin_location
vpHomogeneousMatrix m_eMc
Constant transformation between end-effector and tool (or camera) frame.
CommandLayer m_command_layer
vpHomogeneousMatrix get_eMc() const
void setVerbose(bool verbose)
void setPluginLocation(const std::string &plugin_location)
int getActiveDevice() const
vpControlFrameType
Definition vpRobot.h:74
virtual void setVelocity(const vpRobot::vpControlFrameType frame, const vpColVector &vel)=0
virtual void getPosition(const vpRobot::vpControlFrameType frame, vpColVector &position)=0
Get the robot position (frame has to be specified).
virtual void init()=0
virtual void getDisplacement(const vpRobot::vpControlFrameType frame, vpColVector &q)=0
vpRobot(void)
Definition vpRobot.cpp:49
virtual void setPosition(const vpRobot::vpControlFrameType frame, const vpColVector &q)=0
Set a displacement (frame has to be specified) in position control.