This section shows how to connect to a real robot arm from RoboDK using robot drivers and perform some simple operations.
1.Right click a robot
2.SelectConnect to robot…
3.Enter the IP of the robot
4.SelectConnect
A green message displayingReadywill appear if the connection was successful, as shown in the following image.
A robot program that has been created using the Graphical User Interface (GUI) can be executed on the robot following these steps.
1.Right click aprogram
2.Check theRun on robotoption
3.Double click the program to start it
The program should start on the real robot and the simulator will follow the robot movements. The Connection status will displayWorking…in yellow when the robot is busy.
It is possible to control the movement of a robot from the罗依boDK API, for example, to program a robot from a Python program or a C# application.
The Run on robot option is managed automatically when a Python program is run from RoboDK. Follow these steps to run a Python program on the robot:
1.Right click aPython program
2.SelectRun on robot
The program should start running on the robot and the robot connection status will be updated accordingly.
If the program is executed outside the RoboDK’s GUI (for debugging purposes, or if we are using the RoboDK API for C# for example), we can set theRunModeusingRDK.setRunMode运行MODE_RUN_ROBOT. This will force the program to run on the robot. It is also possible to establish the connection usingrobot.Connect().
The following code shows a brief example to establish a connection with the robot directly from the API:
# Start the RoboDK API
RDK=罗依bolink()
robot=RDK.Item('',ITEM_TYPE_ROBOT)
# Connect to the robot using default connetion parameters
success=robot.Connect()
status,status_msg=robot.ConnectedState()
ifstatus!=ROBOTCOM_READY:
# Stop if the connection did not succeed
raiseException("Failed to connect: "+status_msg)
# Set to run the robot commands on the robot
RDK.setRunMode(RUNMODE_RUN_ROBOT)
# Note: This is set automatically if we use
# robot.Connect() through the API
# Move the robot:
robot.MoveJ([10,20,30,40,50,60])
prog=RDK.Item(“MainProgram”,ITEM_TYPE_PROGRAM)
prog.setRunType(PROGRAM_RUN_ON_ROBOT)# Set the run on robot option
# Set to PROGRAM_RUN_ON_SIMULATOR to run on the simulator only
prog.RunProgram()
whileprog.Busy()==1:
pause(0.1)
print("Program done")