I'm using a Mitsubishi robot controlled via the RoboDK Python API. I am trying to turn on the servo from the python script and after cycle operation I want to turn off the servo. But cannot achieve this. Please find the attached image that contains my script code and the setup. I am also attaching the script code here. Kindly advise on my wrong steps.
Code:
# This macro shows an example to draw a polygon of radius R and n_sides vertices using the RoboDK API for Python
# More information about the RoboDK API here:
# https://robodk.com/doc/en/RoboDK-API.html
from robolink import * # API to communicate with RoboDK
from robodk import * # robodk robotics toolbox
# Connect to the RoboDK API
RDK = Robolink()
robot=RDK.Item('Mitsubishi RV-7FR' )
robot.Connect("192.168.0.25") # connect to the robot.
#Use double inverted comma for ip address
#robot.RunInstruction("Servo On",INSTRUCTION_INSERT_CODE)
robot.RunInstruction(" c 1;1;SRVON",INSTRUCTION_INSERT_CODE)
# Retrieve all items and print their names
list_items = RDK.ItemList()
for item in list_items:
print(item.Name())
home_position = RDK.Item('Home')
Target_position = RDK.Item('Target')
Target_position3 = RDK.Item('Target 3')
loop_count = mbox("enter the loop number",entry = "")
for i in range(int(loop_count)):
# Set the speed of the
# robot (for example, 50 mm/s and 20 deg/s)
robot.MoveJ(home_position)
robot.MoveJ(Target_position3)
robot.MoveJ(Target_position)
robot.MoveJ(home_position)
robot.RunInstruction(" c 1;1;SRVOFF",INSTRUCTION_INSERT_CODE)