# URScript Extensions

**URL:** <https://forum.universal-robots.com/t/urscript-extensions/1007>\
**Category:** URScript\
**Created:** [July 24, 2017, 7:46am UTC](https://forum.universal-robots.com/t/urscript-extensions/1007 "2017-07-24T07:46:11Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![anon84897680](https://avatars.discourse-cdn.com/v4/letter/a/bbce88/32.png) [@anon84897680](https://forum.universal-robots.com/u/anon84897680)\
**Post date:** [July 24, 2017, 7:46am UTC](https://forum.universal-robots.com/t/urscript-extensions/1007/1 "2017-07-24T07:46:11Z")

</div>

Hello,

I’m trying to connect a camera system from a UR5 robot via TCP/IP. The camera uses an asci protocol but  
I’m unable to parse the protocol on the robot with URScript (3.4.2) language. I haven’t found any string  
manipulation functions.

Is there any way to extend the URScript language on the robot to parse the camera protocol? Maybe by  
writing custom python modules or c++ libraries?

---

<div class="post-metadata">

**Author:** ![jbm](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.universal-robots.com/jbm/32/614_2.png) [@jbm](https://forum.universal-robots.com/u/jbm)\
**Post date:** [July 24, 2017, 8:01am UTC](https://forum.universal-robots.com/t/urscript-extensions/1007/2 "2017-07-24T08:01:25Z")

</div>

URScript does not natively support string handling functions, other than comparison,  
However if the camera is able to transmit a float value as ASCII in this format `"(1.23, 2.34, 3.45)"` it is possible directly to receive this, and convert to numerics by the function `data = socket_read_ascii_float(n)`.

However you might find XML-RPC useful, e.g. check out the XML-RPC Math example in the Samples topic.  
This implements an example of string functions.

Alternatively use a URCap to implement a daemon, to perform a handshake between the camera, and URScript.

---

<div class="post-metadata">

**Author:** ![anon84897680](https://avatars.discourse-cdn.com/v4/letter/a/bbce88/32.png) [@anon84897680](https://forum.universal-robots.com/u/anon84897680)\
**Post date:** [July 24, 2017, 8:33am UTC](https://forum.universal-robots.com/t/urscript-extensions/1007/3 "2017-07-24T08:33:06Z")

</div>

The camera protocol doesn’t transmit the values in form that is readable by URScript right now. This solution would require to modify the camera protocol.

For XML-RPC a special XML-RPC server is needed to proxy data between camera and URScript. URScript would act as a client to that server. No extra code on the robot would be needed but an XML-RPC server is needed and that has to run somewhere.

The URCap daemon solution sounds interesting. Could you please get a bit deeper into the details of this. Is it like URScript talks to URCap daemon (c++) on the robot and that daemon talks to the camera?

---

<div class="post-metadata">

**Author:** ![jbm](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.universal-robots.com/jbm/32/614_2.png) [@jbm](https://forum.universal-robots.com/u/jbm)\
**Post date:** [July 24, 2017, 8:49am UTC](https://forum.universal-robots.com/t/urscript-extensions/1007/4 "2017-07-24T08:49:55Z")

</div>

Yes, with the daemon contribution, this could act as a handshake between the URScript, and the camera. so the daemon can relay the information in the protocol desired.

The handshake towards URScript could e.g. be an XML-RPC server, or some other socket comminucation form, based on C++, Python 2.7, Java or another preferrence you yours.

E.g. take a look at the MyDaemon sample in the URCaps SDK, and the XML-RPC Math sample in the Samples topic.  
These both implement a daemon.

---

<div class="post-metadata">

**Author:** ![anon58863070](https://avatars.discourse-cdn.com/v4/letter/a/48db29/32.png) [@anon58863070](https://forum.universal-robots.com/u/anon58863070)\
**Post date:** [July 24, 2017, 3:01pm UTC](https://forum.universal-robots.com/t/urscript-extensions/1007/5 "2017-07-24T15:01:47Z")

</div>

Hi,  
Just to be sure, and to warn others peoples reading this, but we can’t use Python2.7 on our urcaps, were limited to the 2.5 version right? If we wan’t to use 2.7, we have to use another computer right ?  
(Tested it just about a minute ago to be sure, and I don’t work, maybe it’s fine if we manually install Py2.7 on the robot, but it won’t be installable as standard urcap )  
(I had to rewrite a full library because it wasn’t working on 2.5, it’s why I tilted at your post)

---

<div class="post-metadata">

**Author:** ![jbm](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.universal-robots.com/jbm/32/614_2.png) [@jbm](https://forum.universal-robots.com/u/jbm)\
**Post date:** [July 25, 2017, 7:13am UTC](https://forum.universal-robots.com/t/urscript-extensions/1007/6 "2017-07-25T07:13:42Z")

</div>

@anon58863070  
Be aware that the Python version is different, depending on the hardware version of the robot.  
[Namely between CB3.0 and CB3.1](http://forum.universal-robots.com/t/what-is-the-difference-between-cb3-1-and-cb3-0/129)

---

<div class="post-metadata">

**Author:** ![anon58863070](https://avatars.discourse-cdn.com/v4/letter/a/48db29/32.png) [@anon58863070](https://forum.universal-robots.com/u/anon58863070)\
**Post date:** [July 25, 2017, 8:08am UTC](https://forum.universal-robots.com/t/urscript-extensions/1007/7 "2017-07-25T08:08:11Z")

</div>

Thank you, I didnt know that CB3.1 was in Python2.7,  
It’s already a great thing, maybe we will get Python3 to the next one 😉  
(I’ll will make a detailed “feature request” post later on it)
