Jump to content
  • Advertisement
Sign in to follow this  
Alternate_Reality

Programming Game Outputs to control physical objects

This topic is 849 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello!

 

Brand new to game development and still drinking from a firehose. I have scoured the far reaches of the internet and have not found an answer to my question. How hard would it be, if possible to program game outputs that can to a PLC or similar for controlling actual objects in the real world- Such as a light, or Turning on/off the Radio, etc. For what I'm looking to do I would need a variable signal as well.

 

Thanks for the help! 

Share this post


Link to post
Share on other sites
Advertisement
It's pretty much as easy as the device's drivers make it.


Many devices are designed to be PC-automated, and have simple protocols and APIs for talking to them from a computer. Some devices are not so convenient, and will require either manually writing a driver to talk to the hardware or building a translator of sorts to rig up between the PC and the device itself.

As for making a game that can talk to those devices... well, it's about as easy as making the game itself, plus the overhead of talking to the device :-)


I'd recommend looking for hardware that's easy to home-automate and working from there.


[edit] Afterthought - you can also look into working on a lower level like an Arduino or a Raspberry Pi. It depends on the game you want to make really. Edited by ApochPiQ

Share this post


Link to post
Share on other sites

Apoch, 

 

Thanks for your reply! It's great to know this can be done, which I figured. In reality this has nothing to do with home automation and everything to do with an augmented reality type game where the player effects actual change on the physical environment surrounding them. I really don't want to go into too much detail beyond that other than to say I need to be able to export in game events to create actual mechanical movements. 

 

With that said, what I am looking to do will require many different disciplines of engineering, most of which are well established. However the interaction of the VR world to the real world is not so much yet which is where I want to start. Any additional details, links, or advice are much appreciated!!  :ph34r:

Share this post


Link to post
Share on other sites

If your asking if its possible to have the game be on a pc and then control lights or other devices based on the pc game, yes it is possible. I would suggest, as mentioned above, looking in to getting a micro-controller and then either get a blue-tooth chip or wifi chip for it and have your game connect to the micro-controller through that. Wifi is probably the easiest - there are lots of microcontrollers that come with wifi built in (some arduinos, raspberri pis, intel edison, etc).

 

If using wifi you would connect the microcontroller to the network and then open up a socket on the microcontroller on some port of your choosing and connect to that from the pc game. Then come up with some data format so that you can send commands/information to the microcontroller through the open socket. The microcontroller would then control the physical devices based on those commands.

 

To open the socket and control physical devices from the microcontroller you would need to write code which will execute on the microcontroller. How to do this is highly dependent on the microcontroller - for arduino you can use the arduino IDE which will cross compile c++ code and transfer the executable to the arduino through a USB connection to the computer. Most microcontrollers will have some IDE of this nature - that allow you to develop on the PC, cross compile, and transfer the executable to the microcontroller. Many will even allow you to debug the executable remotely from your PC.

 

I hope this helps.

Share this post


Link to post
Share on other sites

You may want to look if some robot parts could be useful, as their physical  (sub-)systems often provide a full bridge between digital "1 and 0" and "move".

After all, robotics is just games on wheels :D

Share this post


Link to post
Share on other sites

Thank you all for your insight, Although I think Alberth may be closest. So let me elaborate a little. Say I want to build a FPS game, but in a large building with many rooms and floors. Hmm, yes, just like the games currently are. But I want to be able to track the Player's exact location in the space. On top of that, If a player shoots a door in the game, I want the Real door to open when the player shoots it. Or say an Elevator. If the Player pushes the "Up" button in the game, I want the elevator to go up. 

 

Now these are all On/Off examples. But what about if the shooter is almost out of ammo, shoots the door once? I want it to open about 1/4 the way. Can this be done?

 

This is all stuff I came up with off the top of my head, and does not represent my real ambitions. However, it would be fun to do. Imagine turning an old warehouse into Doom!!

 

That said, is this possible? And who would want to help me turn something like this into reality? 

Share this post


Link to post
Share on other sites

Right, Mythbusters style :)

 

It's definitely doable. I would try to let gravity do most of the work, so you only need to pull some things or let go of things.

Electronically, the place where you want to go is "relay". It's a magnetic coil that pulls another switch. Controlling the coil is easy to do from a computer 5V, The switch can handle anything from 12V to 220V. Relays are slow (order of 50msecs iirc), but quickly enough :)

 

The circuit with the magnetic coil is completely separate from the circuit of the switch, which is very good for not blowing up your computer.

Check out the electronics shops, near controlling devices or home automation (DIY rather than polished companies plug-it-in, although, if you never did any electronics, that may be a simpler but more expensive solution to you). Also, read forums/wikis about home automation.

 

As for making things move in the real world, electro-magnets would be one way, it's like normal magnets, but they have an on/off switch. Turn off the power (relay!), and no magnetism any more -> drops -> pulls rope + weight -> opens door, kind of stuff.

Shop in the electronics store, and see what they have. Make sure to put in over-voltage protection. Devices with coils (electro magnets, motors) produce big voltage peaks when switched on or off, and you don't want that near your relay contacts, it gives sparks, and burned contacts.

 

Last but not least, think safety! Elevators or electric winches, or any other physical device continues to move even if your arm, leg, or other body part is at the wrong place. Your clothes may get caught in the mechanics, you may get caught by a swinging rope in some way. All these devices are generally stronger than you, which means you will loose in a very unpleasant way. Have emergency switches everywhere that disconnect power, always have two or more persons in the room, increasing the odds of being able to reach an emergency switch in case something goes wrong. Remote-controlled means things may start to move at any moment (computer looses power or is badly programmed -> all devices trigger!, power-failure -> all devices trigger!)

 

As for help, I think you need to go to the classifieds, although in your case, it may be better to find someone with home automagication knowledge.

Edited by Alberth

Share this post


Link to post
Share on other sites

Thanks Alberth. I can see where I didn't make my question very clearly defined. The HW I'm solid with, it's the SW and coding that is mysterious to me. 

 

I'm an Electronics Technician by trade, and work with PLC's, Relay boards, I/O devices, drivers etc in my daily job. In fact I once had my own business (Dino Fuel Alternatives) where I created my own automation system. However, the one aspect that's always been a mystery to me and that I've never messed with is the writing of SW code. Everything I have done in the past the SW is already written, I'm just setting parameters and configurations for the desired result. 

 

Not sure why, but I thought VR programming was some mystical exotic type of code that is different from everything else. The more research I do though, I realize that most of it is some version of C++.  Thankfully I found THIS site that is walking me through step by step from Data lines, bits, nibbles etc,(mostly review) to how SW controls these items- All new. So I'm slowly peeling back the layers of mystery but know it will take quite some time before I write any code worthwhile, much less the ability to write a VR game.

 

That is why I'm openly soliciting for thoughts and ideas on way's to speed this up, or more insight into SW and VR programming to get to that point where I get a 5volt out, or an analog signal, if that's possible. Once I have that, I can do whatever with the HW. Again, always open to some temawork for developing some prototype "Proof-Of-Concepts" to take to a gaming conventions. Thanks for the feedback so far! 

Share this post


Link to post
Share on other sites

Well, that covers the electro-physical side then :)

 

From the SW side, a whole new world awaits you :D

 

If you want to investigate SW-HW interfacing more closely, buy a raspberry-pi. They cost next to nothing, and are well known, and used for experimenting a lot.

This is however more at the elementary bit level I think, but never checked it properly.

 

VR programming is a huge step from there. I haven't looked at it, but the helmet seems like two video screens, one for each eye. You measure position and orientation of the head of the player, compute what should be shown, draw that picture (opengl no doubt), and send the pictures to the video screens in the helmet. In a sense it's normal video display programming, except a sensor tells you the position and orientation of the user, instead of an internal variable.

Some electronics are involved, but it's either accurate measurements or a high bandwidth video signal. Likely, a VR device is a bunch of hardware with a connection to a computer,and a software library for accessing the device. My guess is that video is done directly from the normal video output (at least that seems like the simplest way to do it). At SW level, you may thus get positions and orientations from the library, and standard opengl for displaying whatever you show to the user. (As said, I haven't looked at these things, but this seems like a setup that might work at first sight).

 

Your signals more likely arrive from triggers in the game. In FPS, the game script that controls the story uses triggers like you entering an area to unleash the next bunch of monsters onto you. You could use the position and orientation of the VR device to make such decisions. Firing a weapon is just pressing a button.

 

Last but not least, you'll need to do some programming. I'd recommend to start with Python, an easy language, ideal for some simple experimenting. Runs at rasp-berries too. Don't under-estimate the language, it's a full-blown language with classes. You can learn lots of programming concepts in it.

 

C or C++ would be a next step. You'll feel more at home in C probably, but C++ is more powerful in writing complex programs (less lines of code to achieve something).

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!