Giter Site home page Giter Site logo

Comments (3)

garciadelcastillo avatar garciadelcastillo commented on September 3, 2024 1

Hi @boundlessmaking!

Sorry for the confusion around CustomCode, it is an action that I used primarily for debugging, and its use is not very consistent.

The main use of CustomCode() is to insert custom lines on code on programs which cannot be directly generated through the use of regular actions. For example, Machina doesn't incorporate circular motion (yet), so calling

bot.CustomCode("movec(p[0.3,0.3,0.3,0,0,0], p[0.4,0.4,0.3,0,0,0], a=1.2, v=0.25, r=0.05, mode=1)");

would insert the following line of code in your program:

movec(p[0.3,0.3,0.3,0,0,0], p[0.4,0.4,0.3,0,0,0], a=1.2, v=0.25, r=0.05, mode=1)

This can also be used to call custom functions in external modules, remote procedures, etc.

CustomCode() was primarily designed for offline mode. Machina relies on custom drivers to receive instructions in online mode, and if the driver doesn't have instruction codes for that particular instruction, it cannot execute it. Additionally, most low-level robot programming languages (URScript, RAPID) do not support reflection, so sending the full custom code as a string does not work either. Hence the reasons why this action only works well in offline mode.

Now, over time, I found myself needing to debug a lot of low-level communication stuff in online mode, so started using this action to send custom instruction codes via TCP. On ABB robots, this works by sending a string with a custom buffer code, the way represented here. This means that if an user requests

bot.AxesTo(0, 0, 0, 0, 90, 0);

the driver receives a TCP string message with the CONST num INST_MOVEABSJ := 3; ! MoveAbsJ J1 J2 J3 J4 J5 J6 format, or in for the concrete action above

"@23 3 0 0 0 0 90 0;"

where 23 is the id number of that action. If you turn "Debug" mode on the Bridge, you can see all the back and forth of this kind of low-level communication protocol.

Due to certain limitations with the capacity for URScript to parse strings, for UR robots it works a little different, and communication is handled via a buffer of int32 values. Additionally (and this requires its own dedicated explanation as well), in order to be able to pass float values, these must be pre-inflated by a coefficient, rounded to integers, sent via the communication protocol, and deflated back into floats by dividing by the same coefficient. So, for the above action, and following the protocol, the values are converted to radians and inflated by a FACTOR_RAD of 10000.0, resulting in the following buffer:

[23,3,0,0,0,0,15707,0]

Confusing? I know! It is just a workaround to maximize compatibility with older UR operating systems.

So, I have been using this CustomCode() action to debug online communication by sending my own protocol-formatted instructions, as simple strings for ABB and as int32 buffers for UR. I forget why I deactivated this option at some point for URs, I assume that there was something not quite working there, or that it was giving me unstable results, I forget.

So... TL;DR! What is the summary:

  • CustomCode() is designed for adding custom code in offline mode.
  • It is not possible to replicate this identical functionality in online mode due to the lack of reflection on robot programming languages.
  • To make things clearer, I should probably add a new action like CustomBuffer(), and use this as my debug action for online mode.

You are probably wondering then, how can you send your own code to the robot in real time then? It would require forking the project and extending it to satisfy your needs. This could be done by:

  • Adding your custom instruction codes to your driver of choice.
  • Adding your own way of handling them at the end of the main instruction loop
  • Adding additional custom functions to the driver if you needed them.
  • Re-enabling the CustomCode() functionality for UR robots.
  • Sending your own buffer-formatted, pre-inflated integer sequences.

However, at this point, you have gone through so much effort that you are probably ready to just add your own custom actions to the framework! If they are general enough (nothing too specific to a particular project) and good implemented, I will be happy to merge them to the main project :)

WARNING: ALL OF THIS CAN BE DANGEROUS FOR YOU AND THE ROBOT. Sending your own low-level instructions in real-time is confusing and easily leads to error. Make sure you use all the caution in the world, and know what you are doing at every time. 🙏

from machina.net.

robin-gdwl avatar robin-gdwl commented on September 3, 2024

This is commented out in the [UR drivers ]
(

Logger.Verbose("Cannot stream action `" + _action + "`");
)
Screenshot 2019-05-21 at 11 02 53

but its not commented out in the Abb drivers

Screenshot 2019-05-21 at 11 04 30

from machina.net.

robin-gdwl avatar robin-gdwl commented on September 3, 2024

Thank you for the comprehensive answer! This helps a lot. I will see how I can achieve what I need with this knowledge.

from machina.net.

Related Issues (14)

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.