Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Robot synchronization: run one instruction at a time in a robot program
#1
I am using C# but don't mind python solutions. In the RoboDK API, is it possible to run one instruction at a time within a robot problem (such as one created from a point follow project)? The purpose is to synchronize the movements of multiple robotic arms from a robot program generated from two point follow projects. The code looks something like this:

Code:
// Assume this running as a separate thread
void WorkRobots(string robotName)
{
// Create new reference to RDK for the thread
RoboDK _RDK = new RoboDK();

// Get the program "Point"
RoboDK.Item prog = RDK.getItem("Point");

// Get the robot used for the program, set the program to run on this robot
RoboDK.Item robot = _RDK.getItem(robotName);
prog.setRobot(robot);

// Loop through all instructions in the program
for (int ins_id = 0; ins_id < prog.InstructionCount(); ins_id++)
{
// Get the instruction
string insName;
int insType, moveType;
bool isJointTarget;
Mat pose;
double[] joints;
prog.Instruction(ins_id,
                       out insName,
                       out insType,
                       out moveType,
                       out isJointTarget,
                       out pose,
                       out joints);

// Run one instruction
prog.RunInstruction(ins_id, ???); // ??????? What to do here ????????

// Await the other threads to finish before next instruction
SyncWait();
} // end for loop
} // end function
#2
I am also trying to do something similar but using MoveJ function in Matlab. I am getting a timeout error
#3
If you want to move multiple robots at the same time and synchronize the movements using your PC in real time you should make sure you have a new Robolink object for each robot/thread. If you want to synchronize motion. 

This example shows the concept:
https://robodk.com/doc/en/PythonAPI/exam...e-3-robots
Also available as a sample RDK file named "Example-08.c-Weld with 3 Robots (Script).rdk".

You'll notice that the same program (DoWeld) is run on 3 separate threads (one for each robot) and a new Robolink class is created for each thread. You should request the robot item again inside the thread to make sure you perform the movements using the new API connection created.

This could also be achieved without additional threads if you execute the motion commands (MoveJ/MoveL) as non-blocking and check if the robot movements completed (using robot.Busy).

On the other hand, if you simply want to trigger a program on a separate thread you should use the flag INSTRUCTION_START_THREAD instead of INSTRUCTION_CALL_PROGRAM.

Example:
Code:
program.RunInstruction('Program1', INSTRUCTION_CALL_PROGRAM)  

More information here:
https://robodk.com/doc/en/PythonAPI/robo...nstruction
  




Users browsing this thread:
1 Guest(s)