For more content, please click on the above ABB robot combat skills to follow
You can also click on the classics below the official account to browse more content
Please leave a message in the background before reprinting . Everyone supports the original work and promotes the use and development of robots.
This official account provides technical support for various ABB robot applications, simulations, and graduation projects, and provides detailed background messages .
This official account sincerely hopes to cooperate with various robot training institutions and robot use units, provide technical support, and leave a detailed background message
Click to read the original text at the end of the article to get the complete python code and robot workstation code
def motors_on(self):
"""Turns the robot's motors on.
Operation mode has to be AUTO.
"""
payload = {'ctrl-state': 'motoron'}
resp = self.session.post(self.base_url + "/rw/panel/ctrlstate?action=setctrlstate", data=payload)
if resp.status_code == 204:
print("Robot motors turned on")
else:
print("Could not turn on motors. The controller might be in manual mode")
def set_rapid_variable(self, var, value):
"""Sets the value of any RAPID variable.
Unless the variable is of type 'num', 'value' has to be a string.
"""
payload = {'value': value}
resp = self.session.post(self.base_url + '/rw/rapid/symbol/data/RAPID/T_ROB1/' + var + '?action=set',
data=payload)
return resp
6. Organize the above code into classes and reference them in python to control the robot
import PYRWS as RWS
class robtarget:
trans=[0,0,0]
rot = [1,0,0,0]
robot = RWS.RWS(base_url='http://127.0.0.1', username='Default User', password='robotics')
robot.reset_pp()
robot.motors_on()
robot.start_RAPID()
p1 = robtarget()
while True:
robot.wait_for_rapid1('state', '0')
p1.trans, p1.rot = robot.get_robot_position()
#获取当前位置
print('当前位置',p1.trans)
numbers = input('输入相对坐标x,y,z, 例如 100,20,300\n')
numbers = list(map(float, numbers.split(',')))
robot.set_robtarget_translation('ptmp', numbers)
robot.set_rapid_variable('state',1)
Click to read the original text to get the complete python code and robot workstation code