Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5

Map a mechanism to a python script

#1
I have setup a motor (1 rotative axis mechanism) along with a robot. I want the motor shaft to rotate by the required amount whenever the 'Extrude' function is called (length of filament extruded is the argument it passes).
#2
You can control any number of mechanism axes using a python script. I attached an example to control a conveyor in a roboDK station. You can apply the same logic to a rotative axis


Attached Files
.rdk   script_conveyor.rdk (Size: 115.07 KB / Downloads: 126)
#3

.rdk   RDK_StartThreadQuery.rdk (Size: 1.89 MB / Downloads: 116)
(11-09-2023, 12:44 PM)Alex Wrote: You can take a look at the following example with a conveyor. You can apply the same logic to a rotative axis

Thank you! I was able to make the mechanism work when the script is simply called. However, when I try to run the script as thread, it says Python script interrupted. I have included the RDK file. Please let me know what has to be corrected to make it work.
#4
How do you run the script as a thread? It seems to work when you run the 3D printing program.

To have a more realistic simulation I recommend you to adjust the speed of your mechanism to the robot speed and make the movement not blocking. Example:
Code:
mechanism.setSpeed(extrusion_speed, extrusion_speed)
mechanism.MoveJ(new_joints, False)
#5
In the program events, the Extruder is setup as a thread instead of a program call.

When the script is run as a thread, 'python script interrupted' is displayed at the bottom left. The robot nevertheless keeps moving.
#6
OK I understand what you mean. However, you should run Extruder as a program call (default behavior), not as a thread.

If you run it as a thread, the next time that Extruder is called it forces to stop the previous execution. I recommend you to run it as a program call (default behavior) and make the MoveJ movement not blocking.
  




Users browsing this thread:
1 Guest(s)