PDA

View Full Version : Sending Wiimote OSC Data Over Local Network



SIzukhan
12-07-2010, 02:18 AM
hey there, i've got a (hopefully) quick question.

i have this unity project i'm working on; i'm using osculator/oscumote with it. thing is that i'm going to use at least 10 wiimotes in this project, so i need more than one computer to sync all of the wiimotes. that's all fine and dandy. the problem is that i need all of the computers to see all 10 wiimotes, not just the four connected to each one.

i've done a little looking, and it seems like i can route all of the wiimote data over the local network (that all of the computers are on) thereby allowing each computer to see all 10 wiimotes at once. first of all, is this possible to do, or is there some limitation i'm overlooking (number of incoming/outgoing OSC messages or something)? secondly, i'm having trouble finding out exactly how to do this.

i've found a few things online (including the osculator help), but i can't seem to get it working (though it's entirely possible i'm not setting things up right). in order to do this i set the event type to "OSC routing" and the value to.... what exactly...? then within the value parameters, i assume i set the "host: port" to something like "255.255.255.255:[some port number]". do i need to do anything for the rewrite address/arguments?

then doing this will send the OSC messages to any/all computers on the network? though i suppose they have to have some sort or OSC client running to receive the messages (such as another instance of osculator), right? so my unity project (running oscumote) couldn't just pick up the OSC messages by itself, right? it'd need an actual OSC client picking up the OSC messages from the network then, in turn, sending them to unity/oscumote?

thanks for the help!

SIzukhan
12-07-2010, 06:45 AM
so i just did some testing with duplicating the signals... right now i have one computer that the wiimote is synced to. i'm sending the OSC data to another computer. the second computer is receiving the data fine. i duplicated all of the signals on the second computer. i was sending the first (original) signal to a third computer and the duplicated signal back to the second computer (localhost:8876 for oscumote to pick up). the third looked like it was receiving the signals in osculator. however, i didnt know what to put for some of the values (the blank ones in the image below).

18

at first i tried sending them to the second computer (local host). when i did that, unity/oscumote detected the wiimote on the second computer, but not on the third. then i tried changing those values to the third computer; the exact opposite happened. the third computer's unity/oscumote detected the wiimote, but the second's didn't. again, it seemed as though both computers (second and third) were receiving the signal. but perhaps it seemed that way because the second computer was just receiving the signal from the first one and not itself.

so i guess the question here is, is duplicating signals a possibility for what im triying to do? and if so, what am i doing wrong? :confused:

camille
12-07-2010, 11:30 AM
Hey SIzukhan,

The duplicate function is not best suited to your problem here. The problem is that due to the way OSCulator works right now it is not possible to duplicate a whole message with all of its arguments (/wii/1/accel/pry {pitch} {roll} {yaw} {accel}). You can only duplicate arguments of a message (pitch or roll, individually).

You could use the broadcast trick, but I fear it will yield feedback loops on the network. The other problem is that I think sending 10 Wiimotes messages on broadcast message will totally saturate the network.

If you want to try anyway, open the Wiimote to Max.oscd file from the Samples Library, and customize it to change the target to 255.255.255.255:[port number]. You will notice that 1. this example only routes the entire messages, and not its arguments, 2. nothing is set in the rewrite address, because we just want to route the messages without changing them. All of this is explained in the OSC Routing documentation (http://www.osculator.net/doc/manual:osc_routing) (a bit old, but covers the important topics).

There is another problem I am thinking about:
If you have more than 8 Wiimotes, some IDs will overlap. This could be easily changed with some tweaking in OSCulator to allow addressing more than 8 Wiimotes, but then I am wondering if that many Wiimotes in a single space could cause Bluteooth interferences problems…

Now, what solution do you have?
It really depends on how you can arrange your network of Wiimotes. I would recommend that you send all of them to only one destination computer if that is all possible. It will greatly simplify you configuration issues.

If routing the Wiimote's messages to all computers is really not an option, I can help you writing a small command-line program that will copy the incoming messages to multiple destinations.


Best,
Cam

SIzukhan
12-07-2010, 08:28 PM
so i've opened the Wiimote to Max.oscd file, and i changed the target (i think in the right place), but my second computer is not seeing any signal. i only have to change the IP/port in OSCulator, right; i don't have to change anything in max? here's what i have:

19

20

is this correct? do i need to do any port forwarding or something with my router or something with a firewall (don't think i have one up though...)?

also, i noticed that this file doesn't have any motionplus data, and that's really, perhaps the only, data that i need to be sending/receiving.

i did actually read over the routing doc before i posted originally. thing is though that i don't really understand a lot of it... >_> for example, i don't really get the rewrite addresses/arguments or the difference between the whole message and its arguments (pry vs pitch, roll, yaw, accel).

one more thing. i'm going to have multiple (probably) six instances of my unity app running, one on each computer, and they each need to see all of the wiimotes so that the transforms (controlled by the motionplus data) is all the same on each instance of the app :-/

thanks again for your help!

camille
12-07-2010, 11:46 PM
so i've opened the Wiimote to Max.oscd file, and i changed the target (i think in the right place), but my second computer is not seeing any signal. i only have to change the IP/port in OSCulator, right; i don't have to change anything in max? here's what i have:

is this correct? do i need to do any port forwarding or something with my router or something with a firewall (don't think i have one up though...)?


The first screenshot shows that it is correctly configured.
However, as you can see the second screenshot shows red status lights, meaning that the OSC message can't be sent.

I've made a test, and saw that it was not possible to send data to the universal broadcast address (255.255.255.255), for some reason it doesn't work. However, using a subnet broadcast address works (if your subnet is for example 192.168.0.0, the subnet broadcast address is 192.168.0.255).



also, i noticed that this file doesn't have any motionplus data, and that's really, perhaps the only, data that i need to be sending/receiving.


It can be easily added to the file, just add the OSC Routing to a /wii/1/motion/... message.



i did actually read over the routing doc before i posted originally. thing is though that i don't really understand a lot of it... >_> for example, i don't really get the rewrite addresses/arguments or the difference between the whole message and its arguments (pry vs pitch, roll, yaw, accel).


This is due to the nature of OSC messages.
An OSC message can have many arguments. In this case, the /wii/1/accel/pry message has 4 arguments. In OSCulator, you can choose to route the whole message along with its arguments, or only a single argument, depending on where you put the OSC Routing event.

When a message is routed, you can also choose to change the address to which it is sent, hence the rewrite address. When the rewrite address is not specified, OSCulator will route to the same address if the whole message is routed, or if only an argument is routed, it will route to the argument's message address with the argument's index appended at the end of the address (for example if you route the roll argument of /wii/1/accel/pry, the resulting address will be /wii/1/accel/pry/1).



one more thing. i'm going to have multiple (probably) six instances of my unity app running, one on each computer, and they each need to see all of the wiimotes so that the transforms (controlled by the motionplus data) is all the same on each instance of the app :-/


Then OSCulator will perhaps not be the best tool for doing this.
Just for fun, I wrote a little command line tool that allows to route every received message to one or several targets.

Here is the usage:


usage: oscbroadcast [-s <server_port>] -t <target_url> [-t <target_url> ...]


Listens to OSC messages on <server_port> (defaults to 9000) and copies
received messages to one or many <target_url>

A <target_url> is specified as osc.<proto>://<host>:<port>
Where: <proto> is udp or tcp.
<host> is an IP address or a hostname.
<port> is the target port.
Valid URL example: osc.udp://192.168.0.1:8002

Usage example:
oscbroadcast -s 9001 -t osc.udp://192.168.0.1:8002 -t osc.tcp://10.0.0.1:9001


The idea is that you simply run oscbroadcast on a given port (9000 for example), and add every other computers as targets
Then from OSCulator, route all the Wiimote's message you need to the port on which oscbroadcast listens. Those messages will be therefore sent to every target computers.

I think I will add it to the next release as a side tool.


Best,
Cam

SIzukhan
12-08-2010, 12:22 AM
I've made a test, and saw that it was not possible to send data to the universal broadcast address (255.255.255.255), for some reason it doesn't work. However, using a subnet broadcast address works (if your subnet is for example 192.168.0.0, the subnet broadcast address is 192.168.0.255).

i've tried this a few times, and it hasn't worked... :-/ i'll try it again i suppose, but just to make sure... it would be set up the same as the first image in my previous post except instead of 255.255.255.255:8000 it would be 192.168.0.255:8000 (assuming 192.168.0.0 is my subnet)? i feel like some things in the router (network security, firewalls, etc.) would get in the way of this, yeah?


It can be easily added to the file, just add the OSC Routing to a /wii/1/motion/... message.

good to know.


Then OSCulator will perhaps not be the best tool for doing this.
Just for fun, I wrote a little command line tool that allows to route every received message to one or several targets.

Here is the usage:


usage: oscbroadcast [-s <server_port>] -t <target_url> [-t <target_url> ...]


Listens to OSC messages on <server_port> (defaults to 9000) and copies
received messages to one or many <target_url>

A <target_url> is specified as osc.<proto>://<host>:<port>
Where: <proto> is udp or tcp.
<host> is an IP address or a hostname.
<port> is the target port.
Valid URL example: osc.udp://192.168.0.1:8002

Usage example:
oscbroadcast -s 9001 -t osc.udp://192.168.0.1:8002 -t osc.tcp://10.0.0.1:9001
The idea is that you simply run oscbroadcast on a given port (9000 for example), and add every other computers as targets
Then from OSCulator, route all the Wiimote's message you need to the port on which oscbroadcast listens. Those messages will be therefore sent to every target computers.

i really appreciate this, but i am very unfamiliar with running command line code. in terminal, i tried going to the directory where the executable unzipped and typing:

oscbroadcast -s 9000 -t osc.udp://<local computer1 IP>:9000 -tosc.tcp://<local computer1 IP>:9000 -t osc.udp://<local computer2 IP>:9000 -t osc.tcp://<local computer2 IP>:9000

and got:

-bash: oscbroadcast: command not found

where <local computerX IP> is of course the computers' ip on the local network.

do i have to edit the .exe somehow, or am i just not running it correctly?

then, just to make sure, in OSCulator, i would route everything to port 9000 (i assume), but what IP would i route it to?

camille
12-08-2010, 09:55 AM
i feel like some things in the router (network security, firewalls, etc.) would get in the way of this, yeah?

I don't know, but I've spotted a bug in the current version where the red light indicator would keep being be red although the event is fired ok.



oscbroadcast -s 9000 -t osc.udp://<local computer1 IP>:9000 -tosc.tcp://<local computer1 IP>:9000 -t osc.udp://<local computer2 IP>:9000 -t osc.tcp://<local computer2 IP>:9000

and got:

-bash: oscbroadcast: command not found


That was almost that.
In the Terminal, you must specify the full path of the executable you want to launch if it the path is not in a special variable called PATH. What you need to do is simply prefix the executable name with "./". "." is the current directory.

Just launch the executable with
./oscbroadcaster

On most Unix system you can just cd to the directory, type ./o, and hit the Tab key, that will auto-complete the rest of the name.


then, just to make sure, in OSCulator, i would route everything to port 9000 (i assume), but what IP would i route it to?

If you want to send data to the current computer, use localhost or 127.0.0.1.

SIzukhan
12-08-2010, 07:37 PM
That was almost that.
In the Terminal, you must specify the full path of the executable you want to launch if it the path is not in a special variable called PATH. What you need to do is simply prefix the executable name with "./". "." is the current directory.

Just launch the executable with
./oscbroadcasterOn most Unix system you can just cd to the directory, type ./o, and hit the Tab key, that will auto-complete the rest of the name.

i tried a few different things... i tried typing in the full path:

/MyDir/AnotherDir/oscbroadcast

i tried doing that but adding the commands at the end:

/MyDir/AnotherDir/oscbroadcast -s 9000 -t osc.udp://<local computer1 IP>:9000 -tosc.tcp://<local computer1 IP>:9000 -t osc.udp://<local computer2 IP>:9000 -t osc.tcp://<local computer2 IP>:9000

i tried navingating to the directory the files in and typing:

./oscbroadcast

as well as

./oscbroadcast -s 9000 -t osc.udp://<local computer1 IP>:9000 -tosc.tcp://<local computer1 IP>:9000 -t osc.udp://<local computer2 IP>:9000 -t osc.tcp://<local computer2 IP>:9000

all of which gave me:

OSC broadcast tool
Camille Troillard <camille@osculator.net>

usage: oscbroadcast [-s <server_port>] -t <target_url> [-t <target_url> ...]


Listens to OSC messages on <server_port> (defaults to 9000) and copies
received messages to one or many <target_url>

A <target_url> is specified as osc.<proto>://<host>:<port>
Where: <proto> is udp or tcp.
<host> is an IP address or a hostname.
<port> is the target port.
Valid URL example: osc.udp://192.168.0.1:8002

Usage example:
oscbroadcast -s 9001 -t osc.udp://192.168.0.1:8002 -t osc.tcp://10.0.0.1:9001


does that mean it's running? because i'm still not getting any signals on the second comp. again though, i'm sure im doing something wrong :P


If you want to send data to the current computer, use localhost or 127.0.0.1.

will this send it to both oscumote (assuming oscumote is looking for data sent over the port specified in OSCulator) and the command line program (in turn sending data out to targets specified in the command)?

camille
12-08-2010, 07:47 PM
In this command line :


./oscbroadcast -s 9000 -t osc.udp://<local computer1 IP>:9000 -tosc.tcp://<local computer1 IP>:9000 -t osc.udp://<local computer2 IP>:9000 -t osc.tcp://<local computer2 IP>:9000

There is no space between the second -t and osc.tcp, which explains why the parameters are not parsed properly. You should use udp all the way, tcp has no meaning in your case. I agree that the example is a bit confusing.
Therefore the correct command for you would be something like:

./oscbroadcast -s 9000 -t osc.udp://<local computer1 IP> -t osc.udp://<local computer2 IP>:9000

As you can notice, there must be only one -t option per target.

I am not exactly sure how oscumote works, and have not been able to download it, so I can't help you on that side. But I believe that if it is listening on a given port you should add it as a target in the command line list.

Best,
Cam

SIzukhan
12-09-2010, 07:30 AM
ok, i must be doing something wrong... no matter what i do in terminal, it always gives me:


OSC broadcast tool
Camille Troillard <camille@osculator.net>

usage: oscbroadcast [-s <server_port>] -t <target_url> [-t <target_url> ...]


Listens to OSC messages on <server_port> (defaults to 9000) and copies
received messages to one or many <target_url>

A <target_url> is specified as osc.<proto>://<host>:<port>
Where: <proto> is udp or tcp.
<host> is an IP address or a hostname.
<port> is the target port.
Valid URL example: osc.udp://192.168.0.1:8002

Usage example:
oscbroadcast -s 9001 -t osc.udp://192.168.0.1:8002 -t osc.tcp://10.0.0.1:9001EXCEPT for when i use my comp's name given to me from Settings>Sharing>File Sharing (the name, not the IP), but not the local network name (computer-name.local).

so what happens when i type in:


./oscbroadcast -s 9000 -t osc.udp://Sizu's MacBook Pro:8000is that i just get a greater than sign:


>and then just sits there until i close terminal. any keystrokes i input appear in terminal next to the > but don't do anything; when i hit enter it just prints a new line with the >.

this makes me think that it's possibly working. is it/how can i tell that it's working? this made me think that perhaps i should try using computer names rather than IPs, but if i use any other computer name (for example the name of the second computer), it just gives me the above dialog again (as does using IPs or any other input) :-/

also, when i do finally get this to work, i just want to be sure. the number after -s is the port that the executable in terminal is receiving on? the number after the target IP/hostname is the port the specified computer is receiving on? and then in order for the executable (running in terminal) to receive any information, i route the OSC data (from OSCulator) on the computer running the executable to itself (localhost) on the port being received by the executable (the number after -s)? and i'm supposed to be using the computers' network IPs or their network names, right?

camille
12-09-2010, 12:37 PM
Hi,

Please read a bit of documentation about the Terminal, and you will understand how to use it. I think it is obvious that if the program gives the usage sheet, that means that you are not using it the way it should. I have given you the syntax to use, but if you don't follow that syntax, it will not work.



also, when i do finally get this to work, i just want to be sure. the number after -s is the port that the executable in terminal is receiving on? the number after the target IP/hostname is the port the specified computer is receiving on? and then in order for the executable (running in terminal) to receive any information, i route the OSC data (from OSCulator) on the computer running the executable to itself (localhost) on the port being received by the executable (the number after -s)? and i'm supposed to be using the computers' network IPs or their network names, right?

That is correct.


Cam

SIzukhan
12-09-2010, 07:54 PM
ok, so i finally got it to work. the problem was that it didn't like me having the server port stuff along with the targets; i had to run them separately.


./oscbroadcast -s 9000or


./oscbroadcast -t osc.udp://<computer1 IP>:8000 -t osc.udp://<computer2 IP>:8000so now its working (yay!). the problem is now that the signal is incredibly sporadic. not only does it take a little time for the signal to show up (watching in the quick look), but it is also jumping everywhere (not a smooth curve). i think this was one of your concerns in the beginning, yeah? any suggestions on how i can minimize/get rid of this? i already tried hooking the computers up directly to the router and using the ethernet IPs (as opposed to wireless), but that didn't provide any better results :-/

edit:

just tried hooking the computers up directly via cat5, and that didn't improve things either...