|
a |
|
b/URBasic/robotConnector.py |
|
|
1 |
''' |
|
|
2 |
Python 3.x library to control an UR robot through its TCP/IP interfaces |
|
|
3 |
Copyright (C) 2017 Martin Huus Bjerge, Rope Robotics ApS, Denmark |
|
|
4 |
|
|
|
5 |
Permission is hereby granted, free of charge, to any person obtaining a copy of this software |
|
|
6 |
and associated documentation files (the "Software"), to deal in the Software without restriction, |
|
|
7 |
including without limitation the rights to use, copy, modify, merge, publish, distribute, |
|
|
8 |
sublicense, and/or sell copies of the Software, and to permit persons to whom the Software |
|
|
9 |
is furnished to do so, subject to the following conditions: |
|
|
10 |
|
|
|
11 |
The above copyright notice and this permission notice shall be included in all copies |
|
|
12 |
or substantial portions of the Software. |
|
|
13 |
|
|
|
14 |
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, |
|
|
15 |
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR |
|
|
16 |
PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL "Rope Robotics ApS" BE LIABLE FOR ANY CLAIM, |
|
|
17 |
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
|
|
18 |
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
|
|
19 |
|
|
|
20 |
Except as contained in this notice, the name of "Rope Robotics ApS" shall not be used |
|
|
21 |
in advertising or otherwise to promote the sale, use or other dealings in this Software |
|
|
22 |
without prior written authorization from "Rope Robotics ApS". |
|
|
23 |
''' |
|
|
24 |
__author__ = "Martin Huus Bjerge" |
|
|
25 |
__copyright__ = "Copyright 2017, Rope Robotics ApS, Denmark" |
|
|
26 |
__license__ = "MIT License" |
|
|
27 |
|
|
|
28 |
import URBasic |
|
|
29 |
#import URplus #import if any UPplus modules is needed |
|
|
30 |
|
|
|
31 |
class RobotConnector(object): |
|
|
32 |
''' |
|
|
33 |
Class to hold all connection to the Universal Robot and plus devises |
|
|
34 |
|
|
|
35 |
Input parameters: |
|
|
36 |
|
|
|
37 |
''' |
|
|
38 |
|
|
|
39 |
|
|
|
40 |
def __init__(self, robotModel, host, hasForceTorque=False, conf_filename=None): |
|
|
41 |
''' |
|
|
42 |
Constructor see class description for more info. |
|
|
43 |
''' |
|
|
44 |
if(False): |
|
|
45 |
assert isinstance(robotModel, URBasic.robotModel.RobotModel) ### This line is to get code completion for RobotModel |
|
|
46 |
self.RobotModel = robotModel |
|
|
47 |
self.RobotModel.ipAddress = host |
|
|
48 |
self.RobotModel.hasForceTorqueSensor = hasForceTorque |
|
|
49 |
self.RealTimeClient = URBasic.realTimeClient.RealTimeClient(robotModel) |
|
|
50 |
self.DataLog = URBasic.dataLog.DataLog(robotModel) |
|
|
51 |
self.RTDE = URBasic.rtde.RTDE(robotModel, conf_filename=conf_filename) |
|
|
52 |
self.DashboardClient = URBasic.dashboard.DashBoard(robotModel) |
|
|
53 |
self.ForceTourqe = None |
|
|
54 |
# if hasForceTorque: |
|
|
55 |
# self.ForceTourqe = URplus.forceTorqueSensor.ForceTorqueSensor(robotModel) |
|
|
56 |
|
|
|
57 |
logger = URBasic.dataLogging.DataLogging() |
|
|
58 |
name = logger.AddEventLogging(__name__) |
|
|
59 |
self.__logger = logger.__dict__[name] |
|
|
60 |
self.__logger.info('Init done') |
|
|
61 |
|
|
|
62 |
|
|
|
63 |
def close(self): |
|
|
64 |
self.DataLog.close() |
|
|
65 |
self.RTDE.close() |
|
|
66 |
self.RealTimeClient.Disconnect() |
|
|
67 |
self.DashboardClient.close() |
|
|
68 |
if self.ForceTourqe is not None: |
|
|
69 |
self.ForceTourqe.close() |