Robot Network Settings

Hi,

Does anyone know how to access the robot’s network settings through the URCap API? Having trouble finding it if it is available.

Want to pull the IP address specifically.

Edit: Found it here - How to get Server IP Address and Hostname in Java • Crunchify

1 Like

Hi Roman,

read your post yesterday and did a test this morning on a real robot/sim with same functions.

InetAddress IP = Inet4Address.getLocalHost();
//System.out.println("IP :"+IP.getHostAddress());
txt.setText( IP.getHostAddress() );

got: 127.0.0.1. How did you receive eg 192.168.0.10?
which additional properties did you check, scannig the complete network interface?

Mike

That sounds right in practice on the simulator you’ll get 127.0.0.1 which is the default network loopback. When you install it on a UR and run the same line of code you’ll get your ‘192.168.0.10’ or whatever your network settings are setup too. Since the simulator (linux virtual machine) doesn’t work for UR’s network, I have been running an app called ‘SocketTest’ and I start a server at ‘127.0.0.1’ so I can see my URCap connect to this server and display messages/send messages.

Your code is the same that I used this morning and tested out.

On both systems robot and ursim the response was 127.0.0.1
The network configuration was set on the robot,

I didn’t expect that. I will be doing testing next week on the robot, I just ran it a few minutes ago and got an error. This must be why.

I found 2 workarounds but both did not really convince me.
Thats why I was asking if you got a solution without a workaround.

Have you tried using NetworkInterface.getNetworkInterfaces() as this should return all the network interfaces and then you can just iterate over, there should only be two with the robot, localHost and the ipV4 address. Local Host will always start with 127 so you just ignore that one and use the other one.

Worth a try at least

@mbush:
tried this approach but skiped it seeing the number of IPs on ursim. Just now I took a closer look => you are right there are “only” 2 ip4 addresses.

Reading some more about this topic I would list the available addresses in urcap settings so the user can select the correct one.
Preselected IP: the approach of @mbush - provided that ip4 count > 1

Then you are prepared for warning/error -handling.

edit:
Polyscope should know about user input => could be a feature request

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.