Home Programming

Discussion

Left ArrowBack to discussions page
WanliWanli Posts: 1 Recruit
edited March 17 in Programming

Hi everyone,I recently noticed a significant delay of about 100ms during data transmission while testing with UR5 and FT300, which is clearly abnormal. For your reference, my system version information is as follows: URcap: 1.8.1, Firmware: FS2-1.6.3, and Driver: DFU-1.2.1.

Here is the code snippet for establishing the connection. I am using a socket to establish the connection, but I am not using data streams. I am not sure why I am unable to read normal data once I start using data streams.

####################################################################################

class ForceSensor:
    def __init__(self, ip='196.168.0.111', port=63351, buffer_size=1024, pattern=re.compile(r'-?\d+\.?\d*')):
        self.ip = ip
        self.port = port
        self.buffer_size = buffer_size
        self.pattern = pattern
        self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        self.sock.connect((self.ip, self.port))
    def get_data(self):
        response = self.sock.recv(self.buffer_size)
        if response and len(response) > 0:
            val = response.split(b'(', 1)[1].split(b')')[0]
            array = [float(x) for x in self.pattern.findall(val.decode())]
            return array
        else:
            return None
####################################################################################
I tried non-blocking mode as well, but it didn't help.

The method for detecting the delay is that I use the 'speedl' function to move the robotic arm for one second while continuously printing the force feedback with get_data(). I keep doing this until the motion is complete, but the difference between the console output and the values on the robot arm panel is quite significant.

The following code is what I wrote based on the data stream section in the manual, but the data I received is not force feedback at all.
####################################################################################
def start_data_stream(sock):
    register_address = 410
    register_value = 0x0200
    sock.send(struct.pack(">HH", register_address, register_value))

def stop_data_stream(sock):
    stop_sequence = b'\xff' * 50
    sock.send(stop_sequence)

def parse_data_packet(data):
    fmt = ">BB6h2B"
    _, _, *raw_data_values, _, _ = struct.unpack(fmt, data)
    data_values = [
        raw_data_values[0] / 100.0,  # Fx (N)
        raw_data_values[1] / 100.0,  # Fy (N)
        raw_data_values[2] / 100.0,  # Fz (N)
        raw_data_values[3] / 1000.0,  # Mx (Nm)
        raw_data_values[4] / 1000.0,  # My (Nm)
        raw_data_values[5] / 1000.0,  # Mz (Nm)
    ]
    return data_values

def read_sensor_data(host="196.168.0.111", port=63351, num_packets=30):
    with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock:
        sock.connect((host, port))

        start_data_stream(sock)
        time.sleep(1)

        received_packets = 0
        while received_packets < num_packets:
            data = sock.recv(16)
            if len(data) == 16:
                force_and_moment = parse_data_packet(data)
                print(f"Data: {force_and_moment}")
                received_packets += 1
        stop_data_stream(sock)
if __name__ == "__main__":
    read_sensor_data()
####################################################################################
Below is the data that I received.


I was wondering if anyone has any suggestions or solutions to offer?

Comments

Sign In or Register to comment.
Left ArrowBack to discussions page