0
Answered

RobotDK jitter

Дмитрий Мурашов 3 years ago in General Questions updated by Support 3 years ago 2
Hello, i add RobotDK API to game4automation
Youtube video
if check on video Comm cycle in very long, without moving in RobotDK it's 3-5ms, during movment is is 1500ms, is any possibility to make it smaller and more stable? or it is problem of RobotDK ?


Here is code od RobotDK script.

using System;
using UnityEngine;
using Sharp7;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;

namespace game4automation
{
public class RoboInterfaceDK : InterfaceThreadedBaseClass
{

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

public string Adress = "localhost"; //!< The ip adress of the PLC

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



private RoboDK RDK = null;
private bool starting = true;

// Keep the ROBOT item as a global variable
private RoboDK.Item ROBOT = null;


public bool Check_RDK()
{
// check if the RDK object has been initialised:
if (RDK == null)
{
notifybar = "RoboDK has not been started";
return false;
}

// Check if the RDK API is connected
if (!RDK.Connected())
{
notifybar = "Connecting to RoboDK OK!";
// Attempt to connect to the RDK API

if (!RDK.Connect())
{

notifybar = "Problems using the RoboDK API. The RoboDK API is not available...";
return false;
}


}
return true;
}

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 void SelectRobot()
{
notifybar = "Selecting robot...";
if (!Check_RDK())
{
ROBOT = null;
return;
}
ROBOT = RDK.ItemUserPick("Select a robot", RoboDK.ITEM_TYPE_ROBOT); // select robot among available robots
//ROBOT = RL.getItem("ABB IRB120", ITEM_TYPE_ROBOT); // select by name
//ITEM = RL.ItemUserPick("Select an item"); // Select any item in the station
if (ROBOT.Valid())
{
ROBOT.NewLink(); // This will create a new communication link (another instance of the RoboDK API), this is useful if we are moving 2 robots at the same time.
notifybar = "Using robot: " + ROBOT.Name();
}
else
{
notifybar = "Robot not available. Load a file first";
}
}

public bool Check_ROBOT(bool ignore_busy_status = false)
{
if (!Check_RDK())
{
return false;
}
if (ROBOT == null || !ROBOT.Valid())
{
notifybar = "A robot has not been selected. Load a station or a robot file first.";
SelectRobot();
return false;
}
try
{
notifybar = "Using robot: " + ROBOT.Name();
}
catch (RoboDK.RDKException rdkex)
{
notifybar = "The robot has been deleted: " + rdkex.Message;
return false;
}

// Safe check: If we are doing non blocking movements, we can check if the robot is doing other movements with the Busy command
/*if (!MOVE_BLOCKING && (!ignore_busy_status && ROBOT.Busy()))
{
notifybar = "The robot is busy!! Try later...";
return false;
}*/
return true;
}

//! Updates all signals in the parallel communication thread
protected override void CommunicationThreadUpdate()
{
if (!Check_ROBOT(true)) { return; }

double[] joints = ROBOT.Joints();
//Mat pose = ROBOT.Pose();

// update the joints
Axis1.TargetStartMove = !Axis1.TargetStartMove;
Axis1.TargetPosition = (float)joints[0];

Axis2.TargetStartMove = !Axis2.TargetStartMove;
Axis2.TargetPosition = (float)joints[1] + 90;

Axis3.TargetStartMove = !Axis3.TargetStartMove;
Axis3.TargetPosition = (float)joints[2] - 90;

Axis4.TargetStartMove = !Axis4.TargetStartMove;
Axis4.TargetPosition = (float)joints[3];

Axis5.TargetStartMove = !Axis5.TargetStartMove;
Axis5.TargetPosition = (float)joints[4];

Axis6.TargetStartMove = !Axis6.TargetStartMove;
Axis6.TargetPosition = (float)joints[5];

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

}


public override void OpenInterface()
{

if (RDK == null) { RDK = new RoboDK(); }
base.OpenInterface();
}


public override void CloseInterface()
{
//if (!Check_RDK()) { ;}
// Force to stop and close RoboDK (optional)
// RDK.CloseAllStations(); // close all stations
// RDK.Save("path_to_save.rdk"); // save the project if desired
//RDK.CloseRoboDK();
RDK = null;

base.CloseInterface();
}

private void Update()
{
//Check_RDK();
/*if (Check_RDK()) { starting = false; }

if (!Check_RDK() && !starting)
{
RDK = new RoboDK();

}*/


}
}
}

Answer

Answer

Hi, I checked your example on my computer. It moves smoothly on my side´(RoboDK and G4A),

I think your started to implement your own RoboDK Interface because you did not purchased professional version - right?

It could save you some time to use G4A Professional. Please get in contact with me if you need an offer.

Answered

Normally it should be faster. Looks like your computer resources are limited but I am not sure if there is another problem.

To be able to check you would need to provide your project (RoboDK including G4A) to us.

Please send us your project by using https://game4automation.com/send 

Answer

Hi, I checked your example on my computer. It moves smoothly on my side´(RoboDK and G4A),

I think your started to implement your own RoboDK Interface because you did not purchased professional version - right?

It could save you some time to use G4A Professional. Please get in contact with me if you need an offer.