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

How do I collect the joints that moved when my program runs?

#1
How can I load an rdk file with the RoboDK API and run a program to collect the path data that the robot's tool traveled?

https://github.com/RoboDK/RoboDK-API/tree/master/C%23

I'm developing using the example here and wondering if there is a full reference to the commands used to socket communicate with robodk in the api source.
#2
You can find some examples that use the RoboDK API here:
https://robodk.com/doc/en/PythonAPI/examples.html

To accomplish what you described you can use AddFile to load an existing RoboDK project, you can use RunProgram to run a program and check if it finished using Busy. Also, you can use Joints or Pose to read the current pose of a robot.
#3
Code:
private void btnRun_Program_Click(object sender, EventArgs e)
{
    // Check that there is a link with RoboDK:
    if (!Check_RDK()) { return; }

    string progname = txtRunProgram.Text;

    // Retrieve the program item program
    RoboDK.Item prog = RDK.getItem(progname);

    if (prog.Valid() && (prog.Type() == RoboDK.ITEM_TYPE_PROGRAM_PYTHON || prog.Type() == RoboDK.ITEM_TYPE_PROGRAM))
    {
        prog.RunProgram();
        while (ROBOT.Busy())
        {                   
            Console.WriteLine($"Program running...{ROBOT.Pose().ToString()}");
            if (!ROBOT.Busy())
            {
                Console.WriteLine("Program end");
                break;
            }
        }       
       
    }
    else
    {
        notifybar.Text = "The program " + txtRunProgram.Text + " does not exist.";
        //MessageBox.Show("The program does not exist.");
    }
}

Thanks for the advice
As shown above, when I click the program execution button, if I check Busy, it outputs joints data, but this ends faster than the actual robot's behavior, and I can't synchronize it.
#4
Instead of checking if the robot is busy you should check if the program is Busy. While the program may be running (busy), the robot may not always be busy.

To monitor robot joints while the program moves I recommend you to implement a loop like this in C#.
Code:
while (prog.Busy())
{                 
    Console.WriteLine($"Program running... Robot joints: {ROBOT.Joints().ToString()}");
}

Also, you can control the speed of the simulation by using setSimulationSpeed.
  




Users browsing this thread:
1 Guest(s)