Forum Discussion
saqibvohra93
11 years agoHonored Guest
How to attach sensors with oculus rift and receive on unity
Hi, i want to attach few sensors like gyroscope, accelerometer, temperature sensor, vibration motors etc. I dont know how to attach them and receive their values on unity3d to process or send instruct...
sebjf
11 years agoHonored Guest
I have not used the Pi loads, but I think its powerful enough to run an almost fully complete Linux distro right?
saqibvohra93, the easiest way would be to connect the Pi to your network, and open a socket to it with the Mono equivalent of TCPClient.
You would need to write a server to run on the Pi to interact with your sensors and motor drivers. The nice thing about this is that you can use 3rd party libraries like Msgpack and Protobuf to serialize the data.
This will have high latency, though not as bad as some think if the connection is wired.
The other option is to swap out the tcp connection with serial-over-usb (note in this part, I am just assuming the Pi can act as a USB device as well as a host controller, since it can do everything else...)
Virtual COM port/serial-over-usb is typically how you talk to microcontrollers for hobbyist purposes. The device appears as a serial port on the PC, which can be opened and written to with OS APIs (see http://www.mono-project.com/HowToSystemIOPorts for how you'd do it Mono/Unity).
In addition to RS232-USB, you can buy converters for other protocols such as I2C which work in the same way (that is, appear as virtual com ports), and allow you to connect directly to your devices skipping the Pi if you wanted to.
In any case the procedure is the same. Stop thinking of Unity as 'Unity', and think of it as just another IDE: you have a device you want to talk to, so decide on your connection (ethernet, serial, etc), find out what OS APIs are used to open the socket or port, find the Mono class that wraps them, package your data using low level array operations and call send ;)
PS. In either case you will have to handle the resources to make the connection, and format the data yourself. If you were asking for a library or something that would do the above, then unfortunately I don't *think* there is one. If this (relatively) low-level stuff doesn't sound of any interest to you, I'd recommend DoZo1971's idea and get something like this:
http://whatweblog.com/kickstarter-project-the-drone-an-open-source-controller/
Or this: http://www.codeproject.com/Articles/492473/Using-XInput-to-access-an-Xbox-Controller-in-M
saqibvohra93, the easiest way would be to connect the Pi to your network, and open a socket to it with the Mono equivalent of TCPClient.
You would need to write a server to run on the Pi to interact with your sensors and motor drivers. The nice thing about this is that you can use 3rd party libraries like Msgpack and Protobuf to serialize the data.
This will have high latency, though not as bad as some think if the connection is wired.
The other option is to swap out the tcp connection with serial-over-usb (note in this part, I am just assuming the Pi can act as a USB device as well as a host controller, since it can do everything else...)
Virtual COM port/serial-over-usb is typically how you talk to microcontrollers for hobbyist purposes. The device appears as a serial port on the PC, which can be opened and written to with OS APIs (see http://www.mono-project.com/HowToSystemIOPorts for how you'd do it Mono/Unity).
In addition to RS232-USB, you can buy converters for other protocols such as I2C which work in the same way (that is, appear as virtual com ports), and allow you to connect directly to your devices skipping the Pi if you wanted to.
In any case the procedure is the same. Stop thinking of Unity as 'Unity', and think of it as just another IDE: you have a device you want to talk to, so decide on your connection (ethernet, serial, etc), find out what OS APIs are used to open the socket or port, find the Mono class that wraps them, package your data using low level array operations and call send ;)
PS. In either case you will have to handle the resources to make the connection, and format the data yourself. If you were asking for a library or something that would do the above, then unfortunately I don't *think* there is one. If this (relatively) low-level stuff doesn't sound of any interest to you, I'd recommend DoZo1971's idea and get something like this:
http://whatweblog.com/kickstarter-project-the-drone-an-open-source-controller/
Or this: http://www.codeproject.com/Articles/492473/Using-XInput-to-access-an-Xbox-Controller-in-M
Quick Links
- Horizon Developer Support
- Quest User Forums
- Troubleshooting Forum for problems with a game or app
- Quest Support for problems with your device
Other Meta Support
Related Content
- 1 year ago
- 7 months ago
- 3 months ago