Code Monkey home page Code Monkey logo

Comments (5)

piter123 avatar piter123 commented on July 24, 2024

On the same topic, it looks like the Log property in RemoteUR.cs is never assigned (unlike in RemoteABB.cs)

from robots.

visose avatar visose commented on July 24, 2024

Someone ask me this recently so I sent them this:

Although it's not exposed as a Grasshopper component, there is a class called URRealTime for this that you can use, if you know a bit of scripting. You can use it in a scripting component.

You would have to do the following: place a (for example) C# scripting component in the canvas, right click on it and add as an assembly reference 'Robots.dll'.
In the code, add a using statement to 'Robots': using Robots; Create a new object of this class: var urData = URRealTime(string IP); This will connect to the controller, you can use this object to start reading data from it. 'urData' has a property with a list of all the feedback you can read on the UR realtime interface (urData.FeedbackData). Each element in this list has the following public properties:
string Meaning
string Notes
double[] Value

Use Meaning and Notes to see what the data type really is, and then the values array will have the actual values you want to use. For example, if "Meaning" is "joint positions" the values array will be 6 numbers that correspond to the joint positions in radians.
Call the method ' UpdateFeedback();' to update this list with new data from the controller. If you want this data to be continuously updated, you have to call this method in a loop (a simple way would be to use a grasshopper timer). But make sure the object initialization only happens once.

You can also use the method ' Send(string message)' to send commands to the controller using the real time interface.

from robots.

visose avatar visose commented on July 24, 2024

On the same topic, it looks like the Log property in RemoteUR.cs is never assigned (unlike in RemoteABB.cs)

What do you mean exactly with Log not being assigned?
The log output does not mirror the UR controller's log, it's just messages regarding what the Remote component is doing or issues with it. But the ABB one is the same.

from robots.

visose avatar visose commented on July 24, 2024

I assume this issue was confusion regarding the Log property and can be considered resolved.

from robots.

robin-gdwl avatar robin-gdwl commented on July 24, 2024

For Reference: I wrote a script for realtime logging from UR with the Robots-plugin. It's based on the comment above.
I am new to C# so it might be done badly with the Multithreading procedure and Expiration call. Use at your own risk.
Find more in this repository:
https://github.com/robin-gdwl/GH_Robots_URRealtimeFeedback

using System;
using System.Collections;
using System.Collections.Generic;

using Rhino;
using Rhino.Geometry;

using Grasshopper;
using Grasshopper.Kernel;
using Grasshopper.Kernel.Data;
using Grasshopper.Kernel.Types;
using Grasshopper.Kernel.Special;
using Robots;
/// <summary>
/// This class will be instantiated on demand by the Script component.
/// </summary>
public class Script_Instance : GH_ScriptInstance
{
#region Utility functions
  /// <summary>Print a String to the [Out] Parameter of the Script component.</summary>
  /// <param name="text">String to print.</param>
  private void Print(string text) { /* Implementation hidden. */ }
  /// <summary>Print a formatted String to the [Out] Parameter of the Script component.</summary>
  /// <param name="format">String format.</param>
  /// <param name="args">Formatting parameters.</param>
  private void Print(string format, params object[] args) { /* Implementation hidden. */ }
  /// <summary>Print useful information about an object instance to the [Out] Parameter of the Script component. </summary>
  /// <param name="obj">Object instance to parse.</param>
  private void Reflect(object obj) { /* Implementation hidden. */ }
  /// <summary>Print the signatures of all the overloads of a specific method to the [Out] Parameter of the Script component. </summary>
  /// <param name="obj">Object instance to parse.</param>
  private void Reflect(object obj, string method_name) { /* Implementation hidden. */ }
#endregion

#region Members
  /// <summary>Gets the current Rhino document.</summary>
  private readonly RhinoDoc RhinoDocument;
  /// <summary>Gets the Grasshopper document that owns this script.</summary>
  private readonly GH_Document GrasshopperDocument;
  /// <summary>Gets the Grasshopper script component that owns this script.</summary>
  private readonly IGH_Component Component;
  /// <summary>
  /// Gets the current iteration count. The first call to RunScript() is associated with Iteration==0.
  /// Any subsequent call within the same solution will increment the Iteration count.
  /// </summary>
  private readonly int Iteration;
#endregion

  /// <summary>
  /// This procedure contains the user code. Input parameters are provided as regular arguments,
  /// Output parameters as ref arguments. You don't have to assign output parameters,
  /// they will have a default value.
  /// </summary>
  private void RunScript(bool AutoUpdate, string IP, ref object RobotData)
  {
    datapack = new List<double>();

    if (RobotConnection == null)
    {
      RobotAddress = IP;
      RobotConnection = new URRealTime(RobotAddress);
      Feedbackdata = RobotConnection.FeedbackData;
    }
    if (DataAsTree == null)
    {
      DataAsTree = new DataTree<double>();
    }
    if (task == null || task.IsCompleted)
    {
      task = System.Threading.Tasks.Task.Run(() => getDataFromRobot());
    }
    RobotData = DataAsTree;
    
    if (AutoUpdate == true)
    {
      Component.ExpireSolution(true);
    }

  }
  // <Custom additional code> 
  System.Threading.Tasks.Task task = null;
  URRealTime RobotConnection;
  String RobotAddress;
  DataTree<double> DataAsTree;
  List<double> datapack;
  List<FeedbackType> Feedbackdata;
  GH_Path path;

  void getDataFromRobot()
  {
    RobotConnection.UpdateFeedback();
    Feedbackdata = RobotConnection.FeedbackData;

    for (var j = 0; j < Feedbackdata.Count; j++)
    {
      datapack = new List<double>();
      for (var k = 0; k < Feedbackdata[j].Value.Length; k++)
      {
        datapack.Add(Feedbackdata[j].Value[k]);
      }
      path = new GH_Path(j);
      DataAsTree.RemovePath(j);
      DataAsTree.AddRange(datapack, path);
      DataAsTree.TrimExcess();
    }
  }


  // </Custom additional code> 
}

from robots.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.