Philips Hue integration with STK

Philips Hue integration with STK

Postby kmangame0 » 20 Sep 2015, 23:34

I am working on a project for school that integrates Philips Hue smart light bulbs into STK. The objective of this project is to use audio-to-visual replacement to allow players whom have hearing disabilities an equal playing advantage. IE: if there is a audio warning for being targeted by a weapon there would also be a visual cue via the smart bulbs. Right now I am working on a way to measure the distance of one kart to another and align that value with the brightness of a bulb (the closer the opponent the brighter the bulb). For reference I have very little experience in game programming and even less in c++, but I am wondering if anyone who has experience with this code base can tell me if the code already exists in the project to measure the distance between the karts or if I will have to write this logic myself.
kmangame0
 
Posts: 5
Joined: 20 Sep 2015, 22:31

Re: Philips Hue integration with STK

Postby hiker » 22 Sep 2015, 00:30

Hi,

kmangame0 {l Wrote}:I am working on a project for school that integrates Philips Hue smart light bulbs into STK. The objective of this project is to use audio-to-visual replacement to allow players whom have hearing disabilities an equal playing advantage. IE: if there is a audio warning for being targeted by a weapon there would also be a visual cue via the smart bulbs. Right now I am working on a way to measure the distance of one kart to another and align that value with the brightness of a bulb (the closer the opponent the brighter the bulb).

Sounds interesting!

For reference I have very little experience in game programming and even less in c++, but I am wondering if anyone who has experience with this code base can tell me if the code already exists in the project to measure the distance between the karts or if I will have to write this logic myself.

Not ideal circumstances, but the actual code change should be pretty simple: look at src/karts/controller/player_controller.cpp, find update() (which is called once per frame for each player kart) and add something like (note I didn't check that the code compiles, there might be a typo, or declaration missing):
{l Code}: {l Select All Code}
  for(unsigned int i=0; i<World::getWorld()->getNumKarts(); i++)
{
    const AbstractKart* kart = m_world->getKart(j);
    if(kart==m_kart) continue;   // skip player's kart
   float distance = (m_kart->getXYZ() - kart->getXYZ() ).length();
}


Then you can do what you want - probably determine the minimum distance to set the light brightness.

Hope that helps!

Cheers,
Joerg
hiker
 
Posts: 1435
Joined: 07 Dec 2009, 12:15
Location: Melbourne, Australia

Re: Philips Hue integration with STK

Postby kmangame0 » 27 Sep 2015, 18:45

Thanks so much for your help!
kmangame0
 
Posts: 5
Joined: 20 Sep 2015, 22:31

Re: Philips Hue integration with STK

Postby ArDanWol » 28 Sep 2015, 12:27

Cool project! Maybe we can integrate some kind of visual warning system into STK in the future!
I'm know pretty much everywhere else on the internet as "Kpenguin"
"Profanity is one language all computer users know" - Murphy's 50th Law of Computers
Software bugs are impossible to detect by anybody except the end user - Murphy's 31st law of software
Each computer code has five bugs, regardless of how many bugs have been already found - Murphy's 50th law of software
"That's not a bug, it's an undocumented feature!"
User avatar
ArDanWol
 
Posts: 181
Joined: 07 Nov 2014, 17:36
Location: Ohio, USA

Re: Philips Hue integration with STK

Postby hiker » 29 Sep 2015, 01:09

kmangame0 {l Wrote}:Thanks so much for your help!

Could you perhaps report back how it works? It's always interesting for us to see how stk is used!

Thanks!
Joerg
hiker
 
Posts: 1435
Joined: 07 Dec 2009, 12:15
Location: Melbourne, Australia

Re: Philips Hue integration with STK

Postby kmangame0 » 09 Oct 2015, 18:21

Yes I absolutely will!
kmangame0
 
Posts: 5
Joined: 20 Sep 2015, 22:31

Re: Philips Hue integration with STK

Postby kmangame0 » 13 Oct 2015, 21:54

Okay guys I have one more question. I am trying to use a python wrapper in order to scoop up the stdout of supertuxkart.app. To do this I have decided to use pythons popen but I am running into some weird behavior.

File "/var/root/Documents/dev/cmichDev/stk/stkReader.py", line 5, in <module>
stdin=subprocess.PIPE)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 710, in __init__
errread, errwrite)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 1335, in _execute_child
raise child_exception
OSError: [Errno 13] Permission denied

Have you guys ever tried to access the stdin or stdout of supertuxkart? If so, what was your method?
kmangame0
 
Posts: 5
Joined: 20 Sep 2015, 22:31

Re: Philips Hue integration with STK

Postby hiker » 14 Oct 2015, 04:03

kmangame0 {l Wrote}:Okay guys I have one more question. I am trying to use a python wrapper in order to scoop up the stdout of supertuxkart.app. To do this I have decided to use pythons popen but I am running into some weird behavior.

File "/var/root/Documents/dev/cmichDev/stk/stkReader.py", line 5, in <module>
stdin=subprocess.PIPE)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 710, in __init__
errread, errwrite)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 1335, in _execute_child
raise child_exception
OSError: [Errno 13] Permission denied

Have you guys ever tried to access the stdin or stdout of supertuxkart? If so, what was your method?


'Permission denied' would indicate that perhaps you are trying to start the wrong 'thing' (e.g. perhaps a directory instead of the binary?) Note that nearly all output of stk is also written to the log file in the user config directory. If you are adding output, just use the Log::verbose/warning/error/... functions, and you can see it there as well. Otherwise just copy&paste your code, and we can have a look. Also, on what platform are you on?

Cheers,
Joerg
hiker
 
Posts: 1435
Joined: 07 Dec 2009, 12:15
Location: Melbourne, Australia

Re: Philips Hue integration with STK

Postby konstin » 14 Oct 2015, 18:54

I tried

print(subprocess.Popen("SUPERTUXKART_DATADIR=/path/over/datapath /path/to/supertuxkart", shell=True, stdout=subprocess.PIPE).stdout.read())

on linux, and it worked, though the output formatting was wrong. I assume you have a permission problem (binary doesn't belong to you user, exutable bit not set, etc.). You can probably find a solution using google with "python OSError: [Errno 13] Permission denied ".
konstin
 
Posts: 37
Joined: 31 May 2014, 20:54

Re: Philips Hue integration with STK

Postby kmangame0 » 16 Oct 2015, 18:07

hiker {l Wrote}:'Permission denied' would indicate that perhaps you are trying to start the wrong 'thing' (e.g. perhaps a directory instead of the binary?)


You were absolutely correct. For whatever reason the Python library thought that proc = subprocess.Popen(['supertuxkart.app'],stdout=subprocess.PIPE, shell=False) was a directory.

hiker {l Wrote}:Otherwise just copy&paste your code, and we can have a look.

import subprocess
proc = subprocess.Popen(['open supertuxkart.app'],stdout=subprocess.PIPE, shell=True)
while True:
line = proc.stdout.readline()
if line != '':
print "test:", line.rstrip()

hiker {l Wrote}:Also, on what platform are you on?

I am running Mac OS X 10.11

hiker {l Wrote}:Note that nearly all output of stk is also written to the log file in the user config directory. If you are adding output, just use the Log::verbose/warning/error/... functions, and you can see it there as well.

This is extremely helpful! I still need to figure out more information about this popen business. I was under the impression that because it opened a sibling process that there was a "standard" out. Meaning to the cmd, terminal, ect. But apparently that's not the case.
kmangame0
 
Posts: 5
Joined: 20 Sep 2015, 22:31

Who is online

Users browsing this forum: No registered users and 1 guest