0
Started

Kuka VKRC , integration example.

Дмитрий Мурашов 4 years ago in General Questions updated by Support 4 years ago 5

Kuka VKRC , integration example.

Youtube video

Answer

Answer
Under review

Hi,

nice work. How did you connected to KUKA. 

There seems to be still a cycle time problem. If you would like I could support you, if you support me for getting it into the Professional version ;-)

Best regards

Thomas

Answer
Under review

Hi,

nice work. How did you connected to KUKA. 

There seems to be still a cycle time problem. If you would like I could support you, if you support me for getting it into the Professional version ;-)

Best regards

Thomas

cycle problem only appear during video recoding of screen. I use https://github.com/ImtsSrl/KUKAVARPROXY (https://robodk.com/doc/en/RoboDK-Doc-EN-Robots-KUKA.pdf) on office lite VKRC. And from Unity side Python integration https://github.com/linuxsand/py_openshowvar and IronPython . May be possible to get some discount for Professional version?

this is C# code


using System.Collections;
using System.Collections.Generic;
using System;
using UnityEngine;
using Sharp7;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using IronPython.Hosting;
using System.Globalization;
using System.Text;

namespace game4automation
{
public class Kuka_var : InterfaceThreadedBaseClass
{

[ReadOnly] public string notifybar;
[ReadOnly] public string txtJoints;


public Drive Axis1;
public Drive Axis2;
public Drive Axis3;
public Drive Axis4;
public Drive Axis5;
public Drive Axis6;



private dynamic Kuka;




public string Values_2_String(double[] dvalues)
{
if (dvalues == null || dvalues.Length < 1)
{
return "Invalid values";
}
// Not supported on .NET Framework 2.0:
//string strvalues = String.Join(" , ", dvalues.Select(p => p.ToString("0.0")).ToArray());
string strvalues = dvalues[0].ToString();
for (int i = 1; i < dvalues.Length; i++)
{
strvalues += " , " + dvalues[i].ToString();
}

return strvalues;
//return "";
}

public double[] String_2_Values(string ACT_MES)
{
char[] delimiterChars = {':', ' ', ',', ' ', ',', ' ', ',', ' ', ',', ' ', ',', ' ', ',', ' ', ',', ',', ',', ',', ',','}'};
string[] words = ACT_MES.Split(delimiterChars);

double[] joints = new double[12];

for (int i = 1; i < 6; i++)
{
joints[i] = 0;
}
NumberFormatInfo provider = new NumberFormatInfo();
provider.NumberDecimalSeparator = ".";
provider.NumberGroupSeparator = ",";

joints[0] = Convert.ToDouble(words[3],provider);
joints[1] = Convert.ToDouble(words[6], provider);
joints[2] = Convert.ToDouble(words[9], provider);
joints[3] = Convert.ToDouble(words[12], provider);
joints[4] = Convert.ToDouble(words[15], provider);
joints[5] = Convert.ToDouble(words[18], provider);



return joints;
//return "";
}

public bool Check_ROBOT(bool ignore_busy_status = false)
{
return Kuka.CheckConnect();
}

//! Updates all signals in the parallel communication thread
protected override void CommunicationThreadUpdate()
{
double[] joints = new double[12];

if (!Check_ROBOT(true)) { return; }


joints = String_2_Values(Kuka.GetActPos());


Axis1.CurrentPosition = (float)joints[0];
Axis2.CurrentPosition = (float)joints[1] + 90;
Axis3.CurrentPosition = (float)joints[2] - 90;
Axis4.CurrentPosition = (float)joints[3];
Axis5.CurrentPosition = (float)joints[4];
Axis6.CurrentPosition = (float)joints[5];

string strjoints = Values_2_String(joints);
txtJoints = strjoints;

}


public override void OpenInterface()
{
var engine = Python.CreateEngine();

ICollection searchPaths = engine.GetSearchPaths();

//Path to the folder of greeter.py
searchPaths.Add(@"D:\Users\Dmitriy_Murashov\Conv1\Assets");
//Path to the Python standard library
searchPaths.Add(@"D:\Users\Dmitriy_Murashov\Conv1\Assets\Plugins\Lib\");
engine.SetSearchPaths(searchPaths);

dynamic py = engine.ExecuteFile(@"D:\Users\Dmitriy_Murashov\Conv1\Assets\kuka.py");
Kuka = py.Kuka();

Kuka.Connect();
base.OpenInterface();
}


public override void CloseInterface()
{

Kuka.DisConnect();

base.CloseInterface();
}

private void FixedUpdate()
{
}
private void Update()
{




}
}
}

and python code

from py_openshowvar import openshowvar
class Kuka():
def __init__(self):
return 1

def Connect(self):
self.client = openshowvar('192.168.216.128', 7000)
return self.client.can_connect

def GetActPos(self):
return self.client.read('$AXIS_ACT_MEAS', debug=False)

def DisConnect(self):
self.client.close()

def CheckConnect(self):
return self.client.can_connect

def __del__(self):
self.client.close()

yes Voucherwill be greate, for sure i will give you a positiove rating.