Openhybrid Raspberry pi - inteface and library


#21

I believe that this should not be a problem of the hardwareInterface but rather a problem in python. You will most likely find solutions for this problem in the PI/python communities.
For the hardwareInterface you basically want to extend the new hardwareInterface in to the python environment.

In python one should den be able to:

  1. Add new IO points within a setup and go function.
  2. Have some sort of listener or callback for when data from the IO points is coming in
  3. Write data to the IO points
  4. Allow to flip developer functions on and off.

#22

I have some materials , and is researching on ways to interrface nodejs and python,while the new API is getting ready @KevinOrtman
The gpio using python is not ready yet , there are nodejs GPIO methods available as Carsten mentioned
but you can add the objects to hybrid object server and connect to the reality editor
if you are intrrested you can play around with making AR elements like line graph,bar graph etc for the reality editor :slight_smile:


#23

Steps for running hybridobject server on Raspberry pi

NOTE : It will be better to update your raspberry pi before beginning the process

                  # sudo apt-get update
                  # sudo apt-get upgrade

Requirements :

1. Raspberrry pi ( server should work on any model , please report if any issues)
2. internet connection on the pi ( to use the vuforia portal ) , you can use a wifi adapter or directly connecct via LAN cable
3  iOS 7 or above device for reality editor

Steps :

1 .install nodejs on raspberry pi -->

// Getting the nodejs 4.0.0

wget https://nodejs.org/dist/v4.0.0/node-v4.0.0-linux-armv6l.tar.gz

tar -xvf node-v4.0.0-linux-armv6l.tar.gz

cd node-v4.0.0-linux-armv6l

sudo cp -R * /usr/local/

// updating it with node-arm files needed

wget http://node-arm.herokuapp.com/node_latest_armhf.deb

sudo dpkg -i node_latest_armhf.deb

2 download the object folder from --> https://github.com/openhybrid/object as zip
OR you can also clone it to your pi directly using git clone

3 extract the zip file if you downloaded zip

4 go to the object folder from terminal

5 type npm install to install all required dependencies

6 after all dependencies are installed do node server.js or nodejs server,js to start the server

7 go to http://localhost:8080 from the PI’s browser , to access the hybrid-object interface

8 add objects and AR interfaces as given in http://openhybrid.org/first-steps.html

9 install reality editor on iOS device and connect to same network as the pi


#24

Works like a charm. Thanks, @V_Mohammed_Ibrahim

Wonder if we should put those instructions in it’s own thread, or possibly the github README.md or wiki so it’s easier for other folks to find…


#25

@KevinOrtman Thats a good Idea, I will add it to the open hybrid install guide on the webpage.
@V_Mohammed_Ibrahim is the guide above finished or should we add some more things before its added to the page?

I will also generate a drop down menu on the install page. By now we have a lot of guides.

Do you have some good sources for wiki systems that would allow use to rebuild the open hybrid webpage as a wiki? That would allow us to have more people involved in taking care of the webpage content.


#26

@KevinOrtman did you have any difficulty during npm install ?

if there were no problems then the guide is is perfect , i had some doubts on weather npm would work ,
should we add any pics or will this be clear enough? @valentin


#27

We do not need images If it is all command line.
Maybe you can add what a user would need. Similar we did it with the other install guides.

Do you think it will work with the RASPBERRY PI ZERO as well?


#28

it should , ZERO has processing power and almost same features , the server should work , ZERO is not available here yet
@valentin the guide is finished :smile:


#29

The Pi install guide is online and I have structured the Install Menu items in to sub-menus:


#30

Sorry for the delay in getting back with you. I wanted to make 100% sure that the steps were accurate.
So, I re-imaged my sd card to try from scratch (base OS only) and tried multiple variations on the install steps. The install/restore process takes quite a long time, thus the delay.

@V_Mohammed_Ibrahim I found that following the exact steps outlined above failed to install serialport. In my case, the default nodejs instance need to be uninstalled first, and the install via node-arm was a bit flakey. I had a better install experience simply uninstalling the default nodejs then installing v0.12 via nodesource (https://github.com/nodesource/distributions).

Here’s what I ended up with:

How to install on a Raspberry Pi

  1. Use NOOBS to install the base Raspian image.

  2. Update the system software.

    sudo apt-get update
    sudo apt-get upgrade -y
    
  3. Remove the default nodejs instance and replace it with v0.12 or higher (more details on nodesource github)

    sudo apt-get remove nodejs
    curl -sL https://deb.nodesource.com/setup_0.12 | sudo -E bash -
    sudo apt-get install -y nodejs
    
  4. Get the latest OpenHybrid Object code and download dependencies

    git clone https://github.com/openhybrid/object.git
    cd object
    npm install
    
  5. Run the OpenHybrid Object code

    node server.js
    

A this point, you should be able to navigate to port 8080 on your device and find the Object dashboard.


#31

@KevinOrtman could you also your methods with the following branch?
https://github.com/openhybrid/object/tree/beta_hardwareInterfaces

It will become the master branch next week once we debugged it. A lot has changed.
It might be possible that the default nodejs version is working with this branch.

@Carsten worked on a new hardwareInterfaces that allows you to easily communicate with your hardware with nodejs.


#32

@KevinOrtman @valentin
my node version is 4.0.0 , old nodejs versions might cause problems,
you can update to node 4.0.0 using this
i have updated the instructions above with getting node 4.0.0, but that is too many instructions for a new user ,
we should update the guide in the site with @KevinOrtman instructions


#33

Certainly.

The method works in that npm install completes successfully.
Server execution fails, however, with the following output. I’m in the process of debugging.

    pi@raspberrypi:~/object $ nodejs server.js
    got it started
    Loading template: base
    Starting System:
    Enter loadHybridObjects
    TempFolderName: null
    object Light1 has no marker yet
    TempFolderName: null
    object Light2 has no marker yet
    TempFolderName: null
    object test has no marker yet
    socket.io started
    Createing folder: /home/pi/object/objects/Light1/
    AddIO objectID: null   philipsHue
    Createing folder: /home/pi/object/objects/Light1/
    AddIO objectID: null   philipsHue
    it's all cleared
    Createing folder: /home/pi/object/objects/Light2/
    AddIO objectID: null   philipsHue
    Createing folder: /home/pi/object/objects/Light2/
    AddIO objectID: null   philipsHue
    it's all cleared
    found 1 internal server
    starting internal Server.
    webserver + socket.io is listening on port: 8080
    UDP listening on port: 52316
    base loaded !
    Loading template: documentation
    documentation loaded !
    Loading template: header
    header loaded !
    Loading template: home-object
    home-object loaded !
    Loading template: home-object-add
    home-object-add loaded !
    Loading template: interface
    interface loaded !
    Loading template: interface-rowitem
    interface-rowitem loaded !
    Loading template: monitor
    monitor loaded !
    Loading template: sidebar
    sidebar loaded !
    Loading template: target
    target loaded !
    events.js:85
        throw er; // Unhandled 'error' event
                ^
    Error: connect ECONNREFUSED
        at exports._errnoException (util.js:746:11)
        at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1012:19)

@V_Mohammed_Ibrahim do you get the same output when running the code in the beta branch on your Pi?


#34

I should point out that master works without execption.

    pi@raspberrypi:~/object $ git checkout master
    Switched to branch 'master'
    Your branch is up-to-date with 'origin/master'.
    pi@raspberrypi:~/object $ nodejs server.js
    got it started
    Loading template: base
    object null has no marker yet
    object null has no marker yet
    object null has no marker yet
    socket.io started
    opneserial
    no problem
    found 2 internal server
    starting internal Server.
    webserver + socket.io is listening on port: 8080
    UDP listening on port: 52316
    Serial port error [Error: Cannot open /dev/ttyATH0]
    base loaded !
    Loading template: documentation
    documentation loaded !
    Loading template: header
    header loaded !
    Loading template: home-object
    home-object loaded !
    Loading template: home-object-add
    home-object-add loaded !
    Loading template: interface
    interface loaded !
    Loading template: interface-rowitem
    interface-rowitem loaded !
    Loading template: monitor
    monitor loaded !
    Loading template: sidebar
    sidebar loaded !
    Loading template: target
    target loaded !

#35

@Carsten @valentin @V_Mohammed_Ibrahim

I was seeing that error because the philipsHue interface was enabled and trying to send an http request to a pH device. Should we set the exports.enabled flag to false by default?

I also ran across a few other minor items that could be improved while working through the code. I’ll submit a PR for your review.


#36

i haven’t tried the beta branch, will try and tell


#37

Yes we should set the flag to false by default. The hue interface is very beta. It doesn’t have any error handling at all so far. At the moment it’s main purpose is to illustrate the use of the new API. I should have mentioned that in the comments.


#38

Thanks for the confirmation, Carsten.
I did set the flag to false in my PR.


#39

I decided to focus on Pi <-> Hue comms before debugging my RE <-> Pi comms. I can load objects into my phone and see overlays, so I know I’m not too far away on the RE side.

It took me some time to get the Hue interface working, mostly because I’m barely competent, but it more or less works!

  • I learned enough curl to build Hue REST messages by hand. This was all new to me. Turns out the trickiest part is getting a valid username, and once I did that manually I just added that to the URL template so it’s still ugly, but functional. Getting IP address was pretty easy…lots of ways to do that, but from my phone app was easiest.
  • Took me awhile to figure out little things like the right ports. It’s 80 on mine, not 8000.
  • I added a level set to go with the state on/off. I re-learned vi a bit after a 20 year hiatus. Slow but steady progress…
  • Since I don’t have host comms working yet, I hacked in a level staircase that reads the level, adds a bit, writes the level, waits a while, and repeats. Sorta llike the generator loop I see in there to send to RE, only facing the lights instead.
  • It’s still a polling loop, reading the light state and trying to send it up to RE. I didn’t add change filtering yet.

It was cool for about 30 seconds. A light that ramps continually gets old pretty fast!

Thanks for the help!
Peter


#40

Hi @psomdecerff have you checked out what @Carsten did with the Hue Light interface?

https://github.com/openhybrid/object/tree/beta_hardwareInterfaces/hardwareInterfaces/philipsHue