New Blender addOSC plugin for 2.80

Hi

I have ported the addOSC plugin to blender 2.8. It allows to receive OSC-messages and controlling attributes inside blender.

You can find it here:

it comes in two flavours:

inside the master branch you will find a pure python OSC - library

inside the pyliblo_experiment a C based OSC - library (currently only compiled for OSX)

It is not yet feature complete and once more information about the ‘everything - nodes’ are available, I would like to make it part of the node system. for the time being it will show up on the right hand side tabs of the 3d viewport.

Though at the moment I also fight with a crash in blender:

when the plugin receives the OSC message, it will execute the following codeline:

getattr(ob, idee)[:] = args[2+oscindex[0]], args[2+oscindex[1]], args[2+oscindex[2]]

where ob is something like bpy.data.objects[‘Cube’] and idee something like ‘location’ and args contains the data to be set.

while the plugin works for a few seconds, it will ultimately crash, and it seems to be this line that is responsible. So I wonder if there are some special care to be taken when to set attributes from another thread than the main blender thread…

any help would be appreciated.

6 Likes

Hi,

Well, what a surprise that someone has made a fork of my project. I am a little be busy currently but I have on my side the intent to merge AddOSC with AddMIDI while doing the update for 2.80

I will definitely have a look at your version. You definitely deserve some respect for that.

For the crash you experience, when a modal timer is used there is no other thread, so may be a remaining bug in the 2.80, as they said that improvements were made on the dependency graph.

Concerning integration with “everything nodes”, it should be the way to go, because currently Animation Nodes tend to be too slow after adding a few nodes (at least it was the case with 2.79).

2 Likes

Its not yet as functional as yours, some of your functionality wasn’t clear to me and I just wanted to have a proof of concept.

I redesigned some of the code to make it (theoretically) more performative, and more flexible in how to use income messages.

I also made an integration with another c-based osc-library, which I think is faster, but has the obvious disadvantage.

but the ultimate target would be everything nodes, I agree with you. but so far I wasn’t able to gather any infos about it.

1 Like

For future reference: I solved the problem of the crashes:

https://docs.blender.org/api/blender2.8/bpy.app.timers.html

it is unwise to modify data from a thread, unless it is the main, or a timer thread. in my case I use a Queue and a application-timer thread to set the data at an appropriate time.

Hi maybites, I tried to install the AddOSC 2.80 porting, it does not seem to work. I download from the master branch, then zip it and install it via preferences on Blender 2.80 but I am not seeing the addon… is there anything special I have to do?

Seems like renaming the ZIP from blender.AddOSC to AddOSC fixed it… but weird.

When using Keying Set etc, I keep getting error:

Traceback (most recent call last):
  File "/Users/jimmyg/Library/Application Support/Blender/2.80/scripts/addons/AddOSC-master/__init__.py", line 521, in execute
    bpy.ops.addosc.modal_timer_operator()
  File "/Users/jimmyg/Downloads/blender-2.80.0-git20190424.1b839e85e142-x86_64/blender.app/Contents/Resources/2.80/scripts/modules/bpy/ops.py", line 200, in __call__
    ret = op_call(self.idname_py(), None, kw)
RuntimeError: Error: Traceback (most recent call last):
  File "/Users/jimmyg/Library/Application Support/Blender/2.80/scripts/addons/AddOSC-master/__init__.py", line 391, in execute
    dataTuple = (eval(item.data_path), d_p, i_num, make_tuple(item.osc_index))
  File "/Users/jimmyg/Downloads/blender-2.80.0-git20190424.1b839e85e142-x86_64/blender.app/Contents/Resources/2.80/python/lib/python3.7/ast.py", line 91, in literal_eval
    return _convert(node_or_string)
  File "/Users/jimmyg/Downloads/blender-2.80.0-git20190424.1b839e85e142-x86_64/blender.app/Contents/Resources/2.80/python/lib/python3.7/ast.py", line 90, in _convert
    return _convert_signed_num(node)
  File "/Users/jimmyg/Downloads/blender-2.80.0-git20190424.1b839e85e142-x86_64/blender.app/Contents/Resources/2.80/python/lib/python3.7/ast.py", line 63, in _convert_signed_num
    return _convert_num(node)
  File "/Users/jimmyg/Downloads/blender-2.80.0-git20190424.1b839e85e142-x86_64/blender.app/Contents/Resources/2.80/python/lib/python3.7/ast.py", line 55, in _convert_num
    raise ValueError('malformed node or string: ' + repr(node))
ValueError: malformed node or string: <_ast.Name object at 0x1272f6a20>

location: /Users/jimmyg/Downloads/blender-2.80.0-git20190424.1b839e85e142-x86_64/blender.app/Contents/Resources/2.80/scripts/modules/bpy/ops.py:200



location: <unknown location>:-1

Seems like it would be better using the JSON Config file. So I did and seems to work and I don’t have the error like when I am simply loading the keying sets.

Also, I am experiencing a strange behaviour. I am sending data value from iPhone, using TouchOSC app. The value can transfer from Blender on my MacBookPro into TouchOSC, moving Fader slider, but when I am using Fader slider on iPhone, it does not move the Cube…

I tested using the official AddOSC on Blender 2.79 and my setup works both ways.

Is there in anyway I could “force update” so that the value from iPhone can transfer into Blender and controlling the Cube? I can see the value changing but not updating my Cube ID data.

UPDATE:
I am now using the Development version, where the panel of AddOSC is switched to the right side and seems to work.

Hi enzyme69, this library is indeed not yet totally solid. For me it was a proof of concept and a test on performance (not so happy) and stability (happy), but I postpone the development until we have more info about the “everything nodes” are released. We (the initial author and I) believe it should become part of the nodes system.

1 Like

Ah… so the development is on halt? Hmmm … that’s unfortunate.

I actually manage to get stream of OSC in and out of Blender via your ported AddOSC, I am using the development branch.

The issue is now when working with multiple values. I am hoping something like this would work, however somehow I am only getting 1 value.

{
   "/HT":{
      "data_path":"bpy.data.objects['Suzanne']",
      "id":"location[0]",
      "osc_type":"fff",
      "osc_index":"(0)"
   },
   "/HT":{
      "data_path":"bpy.data.objects['Suzanne']",
      "id":"location[1]",
      "osc_type":"fff",
      "osc_index":"(1)"
   },
   "/HT":{
      "data_path":"bpy.data.objects['Suzanne']",
      "id":"location[2]",
      "osc_type":"fff",
      "osc_index":"(2)"
   }
}

I am actually trying to make this setup to work with an iPhone X app called “FaceCap”.
http://www.bannaflak.com/face-cap/livemode.html

The data looks like below and currently giving me error message when using it with AddOSC:

Improper property received:: /HT (6.5071845054626465, 10.60898494720459, -47.3908576965332)

Improper property received:: /W (1, 0.25054770708084106)

Improper property received:: /W (2, 0.2511034905910492)

Improper property received:: /W (5, 0.0)

Improper property received:: /W (6, 0.0)

Improper property received:: /W (7, 0.0984167754650116)

Improper property received:: /W (8, 0.09855884313583374)

Improper property received:: /W (9, 0.14347192645072937)

Improper property received:: /W (12, 0.021188363432884216)

Improper property received:: /W (38, 0.0)

Improper property received:: /W (30, 0.002998529700562358)

Improper property received:: /HRQ (-0.017246998846530914, -0.36272484064102173, 0.9309450387954712, 0.03839980438351631)

Improper property received:: /HR (-42.5850944519043, 0.24378803372383118, 175.1809844970703)

Improper property received:: /HT (6.524552345275879, 10.669800758361816, -47.494041442871094)

Improper property received:: /W (31, 0.007664602715522051)

Improper property received:: /W (36, 0.023501969873905182)

Improper property received:: /W (37, 0.0)

Improper property received:: /W (39, 0.19889716804027557)

Improper property received:: /W (47, 0.03996654599905014)

From your documentation, I thought that this would work.

Or maybe there is a way to simply source all the data coming in into Animation Nodes, and then using Script node to parse the data as list? Although that would be kind of slow in performance?

Below is my latest config. Still unable to get multiple values from /HT for example, supposedly gives me a list, which can be filtered via index. But it does not work…

I will check your config example.

{
   "/HT":{
      "data_path":"bpy.data.objects['CubeA']",
      "id":"location[2]",
      "osc_type":"fff",
      "osc_index":"(0, 1, 2)"
   },
   "/HR":{
      "data_path":"bpy.data.objects['CubeB']",
      "id":"location[2]",
      "osc_type":"fff",
      "osc_index":"(0, 1, 2)"
   },
   "/W":{
      "data_path":"bpy.data.objects['Suzanne']",
      "id":"location[2]",
      "osc_type":"fff",
      "osc_index":"(0, 1, 2)"
   },
   "/HRQ":{
      "data_path":"bpy.data.objects['CubeC']",
      "id":"location[2]",
      "osc_type":"ffff",
      "osc_index":"(0, 1, 2, 3)"
   }
}

When trying to pass “rotation_euler” data, somewhat it complains about the data being inferred… It does not seem to be an issue with “rotation_quaternion”.

I guess my question should be:
In current development phase, can I pass arbitrary OSC message?

Sometimes the OSC data came like “x, y” for rotation X and Y
Sometimes the data is actually “integer, float” and this is for Blendshape index, and coefficient.

Can you specify what OSC messages you want to map to which data_path?

i.e.

/HC 1.34 4.564 4.23 (float float float)-> bpy.data.objects[‘Suzanne’].location

etc…

and I will see how to do it (I have to confess, I haven’t used it for 2 months and I already forgot…)

It’s looking something like below:

Improper content received: /W (29, 0.22661100327968597)

Improper content received: /W (33, 0.05188806354999542)

Improper content received: /W (37, 0.00034254894126206636)

/W 2 0.5 (int float)-> bpy.data.objects[‘Suzanne’].customAttributeOrProps

It’s basically (Integer, Float) value. I don’t know how to hook this into Blender Object with Custom Attributes. Because from your example, I can see you are plugging fff into Position, or ffff into rotation_quaternion… however, in this case the message is coming in as that value of integer and float.

Somewhat this config does not work…

  "/W":{
      "data_path":"bpy.data.objects['Suzanne']",
      "id": "[\"blah\"]",
      "osc_type":"ff",
      "osc_index":"(0, 1)"
   }

this looks right, but I haven’t got experience with custom properties. you might need to address each value with its own osc-message…

Yes, would be really nice to simply have a way to pass generic OSC message that Animation Nodes can see and process / decode.

Custom Properties does not work.

By the way, in configuration, I cannot seem to assign values from same address… like if address is /W I cannot use /W twice or more. Only one shows up.

And if I try using “ff” I don’t know where to plug it in to work properly. Location, Rotation_quaternion works, but rotation_euler does not work.

By the way, in configuration, I cannot seem to assign values from same address… like if address is /W I cannot use /W twice or more. Only one shows up.

thats correct, and a limitation of the OSC-library. Not much I can do here, though I think once we are in Node-land, this limitation can be remedied.

And if I try using “ff” I don’t know where to plug it in to work properly. Location, Rotation_quaternion works, but rotation_euler does not work.

it looks as if osc-type has no functionality at the moment. (its a residue from the previous implementation and I think to remember that I didn’t clean it up because I thought I might reuse it for something else…)

Thanks for your explanation… I think the AddOSC itself is pretty fast. The intermediate Animation Nodes Script node like suggested at AddOSC website is too slow for what I am trying to do (to get realtime feedback).

This is what I got so far…
https://youtu.be/2RWNKYpF91E​

Video link not found

Having trouble installing it as well, unfortunately your renaming trick didn’t work for me. I’m using the latest 2.80 build on Windows 10.

Thanks for porting this though (and thanks to the original addon author as well), can’t wait to play around with it once I get it to work