How to communicate with Virtual Controller through localhost
in RobotStudio
Is there a way to communicate with a running virtual controller in RobotStudio through localhost? I'm looking for ways to send commands over "ethernet" to a localhost port to a robot in simulation.
More specifically, I'm trying to use this python script to setup the connection. I've tried setting the ip to 'localhost' and '127.0.0.1', and have also tried setting the ports to every single port that's being listened on by the process RobVC.exe, but with no luck. The errors I'm getting are either one of the following:
More specifically, I'm trying to use this python script to setup the connection. I've tried setting the ip to 'localhost' and '127.0.0.1', and have also tried setting the ports to every single port that's being listened on by the process RobVC.exe, but with no luck. The errors I'm getting are either one of the following:
- No connection could be made because the target machine actively refused it
- An existing connection was forcibly closed by the remote host
Tagged:
0
Comments
-
The first error occur when one side is trying to make a connection, but no one accepts the connection...
The second error occur when a connection is made, but one side closes the connection (while the connection is still in use)...
Furthermore it depends on if you are using Python3x or Python2x. For example the type 'string' is not the same....
I created an example with python 3.4.4 and RobotStudio 6.03import socket sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.connect(('127.0.0.1', 55555)) sock.send(bytes("Hoi", 'UTF-8')) print(sock.recv(4096).decode('UTF-8')) # Wait till user press 'Enter' to exit input("Press Enter to continue...")
MODULE Module1 PROC main() VAR socketdev server_socket; VAR socketdev client_socket; VAR string receive_string; VAR string client_ip; SocketCreate server_socket; SocketBind server_socket, "127.0.0.1", 55555; SocketListen server_socket; ! Waiting for a connection request WHILE TRUE DO SocketAccept server_socket, client_socket\ClientAddress:=client_ip\Time:=WAIT_MAX; SocketReceive client_socket \Str := receive_string; SocketSend client_socket \Str := "Hello client with ip-addres " +client_ip; SocketClose client_socket; ENDWHILE ERROR RETRY; UNDO SocketClose server_socket; SocketClose client_socket; ENDPROC ENDMODULE
This will give me the following output:Hello client with ip-addres 127.0.0.1 Press Enter to continue...
3
Categories
- All Categories
- 5.5K RobotStudio
- 394 UpFeed
- 18 Tutorials
- 13 RobotApps
- 297 PowerPacs
- 405 RobotStudio S4
- 1.8K Developer Tools
- 249 ScreenMaker
- 2.7K Robot Controller
- 309 IRC5
- 59 OmniCore
- 7 RCS (Realistic Controller Simulation)
- 783 RAPID Programming
- AppStudio
- 3 RobotStudio AR Viewer
- 18 Wizard Easy Programming
- 105 Collaborative Robots
- 4 Job listings