Forum Discussion
saqibvohra93
12 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 instruction to run motor using unity3d.
Is there anyway I can make the environment n unity3d and then attach all sensors and controller with raspberry pi. When i send input from raspberry pi, then function is performed in oculus rift, or if certain temperature is achieved, vibration motor is started..
I am new to Oculus rift.
I would be grateful to you if any one can help me..
Thank you :)
Is there anyway I can make the environment n unity3d and then attach all sensors and controller with raspberry pi. When i send input from raspberry pi, then function is performed in oculus rift, or if certain temperature is achieved, vibration motor is started..
I am new to Oculus rift.
I would be grateful to you if any one can help me..
Thank you :)
6 Replies
- DoZo1971ExplorerWhat?
Counterintuitively, I would like you to make your problem even bigger. What are you trying to make? - saqibvohra93Honored Guest
"DoZo1971" wrote:
What?
Counterintuitively, I would like you to make your problem even bigger. What are you trying to make?
in simple words..
I want to develop a game on unity3d for oculus rift. then want to build a controller with raspberry pi. then want to attach that controller to raspberry pi. controller will have few buttons and joystick attached to control the movement and a vibrator inside it. the vibrator will vibrate on certain actions like if person got killed etc. - DoZo1971ExplorerWhy do you want to use a Raspberry Pi in between? Why not attach some kind of rumbling game controller directly to your PC via USB or bluetooth?
- Freg9mHonored Guest
"DoZo1971" wrote:
Why do you want to use a Raspberry Pi in between? Why not attach some kind of rumbling game controller directly to your PC via USB or bluetooth?
And I am curious that is there any vibration motors or temperature sensor inside the oculus ,just like the asker mentioned ? In sdk 0.3.x I can see a sturct named "ovrSensorState_" has a Float called "Temperature",but In the PREVIEW 0.3.x I can not find the information about temperature sensor.As for the vibration motors , I can't find any things about it ......
thx~
Freg - sebjfHonored GuestI 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 - saqibvohra93Honored Guest
"sebjf" wrote:
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
thnx alot sebf for such an informative reply. Your reply really helped me :)
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
- 2 years ago
- 8 months ago
- 3 months ago