more renaming, fixed tabing

This commit is contained in:
Olivier R-D 2013-04-03 10:21:46 +02:00
parent a6ae969769
commit c9c1becc69
3 changed files with 23 additions and 30 deletions

View File

@ -18,22 +18,22 @@ class Tracker(Process):
self._stop = Event() self._stop = Event()
self._finished = Event() self._finished = Event()
self._data = [] self._data = []
if MATH3D: if MATH3D:
self.calibration = Transform() self.calibration = math3d.Transform()
self.inverse = self.calibration.inverse() self.inverse = self.calibration.inverse()
def _log(self, *args): def _log(self, *args):
print(self.__class__.__name__, ": ".join([str(i) for i in args])) print(self.__class__.__name__, ": ".join([str(i) for i in args]))
def set_calibration_matrix(self, cal): def set_calibration_matrix(self, cal):
if MATH3D: if MATH3D:
self.calibration = cal self.calibration = cal
self.inverse = self.calibration.inverse() self.inverse = self.calibration.inverse()
def _save_data(self): def _save_data(self):
if MATH3D: if MATH3D:
for data in self._data: for data in self._data:
data["transform"] = self.inverse * Transform(data["tcp"]) data["transform"] = self.inverse * math3d.Transform(data["tcp"])
self._queue.put(self._data) self._queue.put(self._data)

View File

@ -206,7 +206,7 @@ class SecondaryMonitor(Thread):
self.start() self.start()
self.wait()# make sure we got some data before someone calls us self.wait()# make sure we got some data before someone calls us
def sendProgram(self, prog): def send_program(self, prog):
""" """
send program to robot in URRobot format send program to robot in URRobot format
If another program is send while a program is running the first program is aborded. If another program is send while a program is running the first program is aborded.
@ -279,7 +279,7 @@ class SecondaryMonitor(Thread):
with self._dataEvent: with self._dataEvent:
self._dataEvent.wait() self._dataEvent.wait()
def getCartesianInfo(self, wait=False): def get_cartesian_info(self, wait=False):
if wait: if wait:
self.wait() self.wait()
with self._dictLock: with self._dictLock:
@ -288,7 +288,7 @@ class SecondaryMonitor(Thread):
else: else:
return None return None
def getAllData(self, wait=False): def get_all_data(self, wait=False):
""" """
return last data obtained from robot in dictionnary format return last data obtained from robot in dictionnary format
""" """
@ -297,7 +297,7 @@ class SecondaryMonitor(Thread):
with self._dictLock: with self._dictLock:
return self._dict.copy() return self._dict.copy()
def getJointData(self, wait=False): def get_joint_data(self, wait=False):
if wait: if wait:
self.wait() self.wait()
with self._dictLock: with self._dictLock:
@ -306,7 +306,7 @@ class SecondaryMonitor(Thread):
else: else:
return None return None
def isProgramRunning(self, wait=False): def is_program_running(self, wait=False):
""" """
return True if robot is executing a program return True if robot is executing a program
Rmq: The refresh rate is only 10Hz so the information may be outdated Rmq: The refresh rate is only 10Hz so the information may be outdated

View File

@ -65,12 +65,11 @@ class URRobot(object):
if useRTInterface: if useRTInterface:
self.rtmon.start() self.rtmon.start()
self.start_pose = [1.57, -1.77, 1.57, -1.8, -1.57, -1.57]
self.secmon.wait() # make sure we get data to not suprise clients self.secmon.wait() # make sure we get data to not suprise clients
def __repr__(self): def __repr__(self):
return "Robot Object (IP=%s, state=%s)" % (self.host, self.secmon.getAllData()["RobotModeData"]) return "Robot Object (IP=%s, state=%s)" % (self.host, self.secmon.get_all_data()["RobotModeData"])
def __str__(self): def __str__(self):
return self.__repr__() return self.__repr__()
@ -102,12 +101,6 @@ class URRobot(object):
force += i**2 force += i**2
return force**0.5 return force**0.5
def moveToStartPose(self):
"""
move to pos defined in self.start_pose attribute
"""
self.movej(self.start_pose)
def set_tcp(self, x=0, y=0, z=0, a=0, b=0, c=0): def set_tcp(self, x=0, y=0, z=0, a=0, b=0, c=0):
""" """
""" """
@ -156,7 +149,7 @@ class URRobot(object):
""" """
get analog input get analog input
""" """
data = self.secmon.getAllData() data = self.secmon.get_all_data()
return data["MasterBoardData"]["analogInput0"], data["MasterBoardData"]["analogInput1"] return data["MasterBoardData"]["analogInput0"], data["MasterBoardData"]["analogInput1"]
@ -164,21 +157,21 @@ class URRobot(object):
""" """
get analog input get analog input
""" """
data = self.secmon.getAllData() data = self.secmon.get_all_data()
return data["MasterBoardData"]["analogInput" + str(nb)] return data["MasterBoardData"]["analogInput" + str(nb)]
def get_digital_inBits(self): def get_digital_in_bits(self):
""" """
get digital output get digital output
""" """
data = self.secmon.getAllData() data = self.secmon.get_all_data()
return data["MasterBoardData"]["digitalInputBits"] return data["MasterBoardData"]["digitalInputBits"]
def get_digital_in(self, nb): def get_digital_in(self, nb):
""" """
get digital output get digital output
""" """
data = self.secmon.getAllData() data = self.secmon.get_all_data()
val = data["MasterBoardData"]["digitalInputBits"] val = data["MasterBoardData"]["digitalInputBits"]
mask = 1 << nb mask = 1 << nb
if (val & mask): if (val & mask):
@ -186,11 +179,11 @@ class URRobot(object):
else: else:
return 0 return 0
def getDigitalOutput(self, val): def get_digital_out(self, val):
""" """
get digital output get digital output
""" """
data = self.secmon.getAllData() data = self.secmon.get_all_data()
output = data["MasterBoardData"]["digitalOutputBits"] output = data["MasterBoardData"]["digitalOutputBits"]
mask = 1 << val mask = 1 << val
if (output & mask): if (output & mask):
@ -198,14 +191,14 @@ class URRobot(object):
else: else:
return 0 return 0
def setAnalogOut(self, output, val): def set_analog_out(self, output, val):
""" """
set analog output, val is a float set analog output, val is a float
""" """
prog = "set_analog_output(%s, %s)" % (output, val) prog = "set_analog_output(%s, %s)" % (output, val)
self.secmon.send_program(prog) self.secmon.send_program(prog)
def setToolVoltage(self, val): def set_tool_voltage(self, val):
""" """
set voltage to be delivered to the tool, val is 0, 12 or 24 set voltage to be delivered to the tool, val is 0, 12 or 24
""" """
@ -232,7 +225,7 @@ class URRobot(object):
while True: while True:
if not self.is_running(): if not self.is_running():
raise RobotException("Robot stopped") raise RobotException("Robot stopped")
jts = self.secmon.getJointData(wait=True) jts = self.secmon.get_joint_data(wait=True)
finished = True finished = True
for i in range(0, 6): for i in range(0, 6):
if abs(jts["q_actual%s"%i] - jts["q_targets%s"%i]) > self.radialEpsilon: if abs(jts["q_actual%s"%i] - jts["q_targets%s"%i]) > self.radialEpsilon:
@ -245,7 +238,7 @@ class URRobot(object):
""" """
get joints position get joints position
""" """
jts = self.secmon.getJointData(wait) jts = self.secmon.get_joint_data(wait)
return [jts["q_actual0"], jts["q_actual1"], jts["q_actual2"], jts["q_actual3"], jts["q_actual4"], jts["q_actual5"]] return [jts["q_actual0"], jts["q_actual1"], jts["q_actual2"], jts["q_actual3"], jts["q_actual4"], jts["q_actual5"]]
def movel(self, tpose, acc=0.01, vel=0.01, wait=True, relative=False): def movel(self, tpose, acc=0.01, vel=0.01, wait=True, relative=False):
@ -268,7 +261,7 @@ class URRobot(object):
""" """
get TCP position get TCP position
""" """
pose = self.secmon.getCartesianInfo(wait) pose = self.secmon.get_cartesian_info(wait)
if pose: if pose:
pose = [pose["X"], pose["Y"], pose["Z"], pose["Rx"], pose["Ry"], pose["Rz"]] pose = [pose["X"], pose["Y"], pose["Z"], pose["Rx"], pose["Ry"], pose["Rz"]]
self.logger.debug("Current pose from robot: " + str(pose)) self.logger.debug("Current pose from robot: " + str(pose))