I am making a python program to control robotic arms that basically reads a machine file previously generated and sends instructions to the robot via TCP/IP in a for loop reading lines and a basic switch structure.
I am declaring some parameters at the beginning of python like:
speed_normal = 5 # mm/s
acc_normal = 1 # mm/s2
wait_time = 1000 # ms
Then I open and read the instruction file:
for index,filename in enumerate(glob.glob(os.path.join(directory, '*.moi')))
with open(filename) as f:
cmd_list = f.read().splitlines()
for cmd_line in cmd_list:
bits = cmd_line.split(';')
One of the switch cases changes the speed of the robot:
elif bits[0] == 'sp':
print('Speed Instruction',bits[1])
if bits[1] == 0:
robot.setSpeed(speed_linear=speed_normal)
So my question is, how could I change the variable speed_normal during the execution of the program, let's say from an external file that works as a sort of "control panel"? So if, without stopping the program, I would like to change it to 20 mm/s?