Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5

UR5e - Realtime monitoring physical Input/Output

#1
Hi RoboDK,

Currently I want to monitor the input/output status of UR5e robot in real time through RobotDK. Is there any way to do this?
I see in the library there is python codeUR_Monitoring_CSV.pywhich mentions this but I don't see the value change when I change the input/output value on UR5e.

Please advise, thank you so much!

Code:
UR_GET_INPUTS = (86-32)*8 + 252
UR_GET_OUTPUTS = (131-32)*8 + 252

def on_packet(packet, packet_id):

global ROBOT_JOINTS
# Retrieve desired information from a packet
rob_joints_RAD = packet_value(packet, UR_GET_JOINT_POSITIONS)
ROBOT_JOINTS = [ji * 180.0/pi for ji in rob_joints_RAD]
ROBOT_TCP_XYZUVW = packet_value(packet, UR_GET_TCP_POSITION)
ROBOT_TCP_SPEED = packet_value(packet, UR_GET_TCP_SPEED)
ROBOT_INPUTS = packet_value_bin(packet, UR_GET_INPUTS)
ROBOT_OUTPUTS = packet_value_bin(packet, UR_GET_OUTPUTS)
#print("Output:")
#print(ROBOT_OUTPUTS)

#ROBOT_SPEED = packet_value(packet, UR_GET_JOINT_SPEEDS)
#ROBOT_CURRENT = packet_value(packet, UR_GET_JOINT_CURRENTS)
#print(ROBOT_JOINTS)

# Monitor thread to retrieve information from the robot
def UR_Monitor():
while True:
print("Connecting to robot %s -> %s:%i" % (robotname, ROBOT_IP, ROBOT_PORT))
rt_socket = socket.create_connection((ROBOT_IP, ROBOT_PORT))
print("Connected")
buf = b''
packet_count = 0
packet_time_last = time.time()
while True:
more = rt_socket.recv(4096)
if more:
buf = buf + more
if packet_check(buf):
packet_len = packet_size(buf)
packet, buf = buf[:packet_len], buf[packet_len:]
on_packet(packet, packet_count)
packet_count += 1
if packet_count % 250 == 0:
t_now = time.time()
msg = "Monitoring %s at %.1f packets per second" % (robotname, packet_count/(t_now-packet_time_last))
print(msg)
RDK。ShowMessage(味精、假)
packet_count = 0
packet_time_last = t_now

rt_socket.close()


Attached Files Thumbnail(s)



Messages In This Thread
UR5e - Realtime monitoring physical Input/Output - byhieuvoquoc- 09-10-2021, 11:08 PM



Users browsing this thread:
1 Guest(s)