PDA

View Full Version : node_server example



oesile
05-12-2015, 11:36 AM
Hi all,

I am trying to run the node_server example, everything looks ok. When a run node app.js a get this:

[email protected]:~/HROS1-Framework/Linux/project/node_server/src# node app.js
listening on port 2114
Page 4 has no action
successful robot init

In the client computer a can access through the IP and port, I get 5 buttons (stand,sit, wave, turn walk on and say something), but when I click any of the buttons nothing happens :confused:

Somebody has any idea how to run this example propertly?

bg404
05-12-2015, 03:57 PM
I've not had any luck with the node server, but it is most likely something on my side.

What URL did you access to see the server page?

I will flash/reinstall mine tonight, and see if I can deploy.

kgranat
05-12-2015, 04:23 PM
the node server code as it stands is based on some old code for the HR-OS5, and is a little wonky. I've got a working example that I'll try to push this week to a separate branch for those interested in helping test and refine it

bg404
05-13-2015, 12:05 AM
I know the node server is not complete, but I wanted to share my experience:

Here are my results tonight:

Fresh install of robot on Raspberry Pi.

history:
136 cd node_server/
138 ls
139 npm install
140 ls
141 cd src
142 ls
143 node app.js


Here is the output (This looks almost identical to my experience on Edison):

/home/pi/HROS1-Framework/Linux/project/node_server/src$ node app.js
/home/pi/HROS1-Framework/Linux/project/node_server/node_modules/ffi/lib/dynamic_library.js:74
throw new Error('Dynamic Linking Error: ' + err)
^
Error: Dynamic Linking Error: ../api_wrapper/apiwrapper.so: cannot open shared object file: No such file or directory
at new DynamicLibrary (/home/pi/HROS1-Framework/Linux/project/node_server/node_modules/ffi/lib/dynamic_library.js:74:11)
at Object.Library (/home/pi/HROS1-Framework/Linux/project/node_server/node_modules/ffi/lib/library.js:45:12)
at Object.<anonymous> (/home/pi/HROS1-Framework/Linux/project/node_server/src/app.js:62:19)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Function.Module.runMain (module.js:501:10)
at startup (node.js:129:16)
at node.js:814:3

oesile
05-13-2015, 12:49 AM
Hi bg404,

The error is because you didn't compile the api_wrapper (this step is not mentioned in the wiki).

To compile the api_wrapper just go to the folder api_wrapper inside node_server folder and run make:

$cd api_wrapper
$make

Once you have the wrapper compiled, you can run the example:

$node app.js

To access to your robot, you need to use the IP of him with the port 2114

for example:

http://192.168.1.20:2114


@Kyle:

I think it will be nice if you put that part in the wiki (compile wrapper and access to the folder src to run the example).

oesile
05-13-2015, 01:03 AM
the node server code as it stands is based on some old code for the HR-OS5, and is a little wonky. I've got a working example that I'll try to push this week to a separate branch for those interested in helping test and refine it


OK, in that case I will look the code. Please let us know when you push the code.

bg404
05-13-2015, 10:59 AM
Awesome! Now I can run the example.

Just following instructions...

Thanks for the help @oesile!

Piper
05-29-2015, 12:44 PM
Hey guys, were you able to get the entire example running? I was able to get the server running but the index.html page is kaput for me too. If you look in the code, it is referencing another source file that seems to contain data on the API for the 20th Century Robot. It's not present anywhere in my code or on the GitHub though. Was anyone able to use the API to perform commands/call commands through the web page?

jveejay
05-29-2015, 06:40 PM
Hey there,

I have been able to get it up and running, but only by writing the missing code in the app.js file. The app.js server file is incomplete, there are still pending functions that need to be written. I have been writing them, if you guys are interested I am happy to push the changes.

oesile
05-30-2015, 12:57 AM
Hey guys, were you able to get the entire example running? I was able to get the server running but the index.html page is kaput for me too. If you look in the code, it is referencing another source file that seems to contain data on the API for the 20th Century Robot. It's not present anywhere in my code or on the GitHub though. Was anyone able to use the API to perform commands/call commands through the web page?

Yes, you are right, there is missing a file, also I couldn't find the file even in the 20 century repo. That is why am waiting for Karl's example. He will push the code soon (I hope).

jveejay
05-30-2015, 10:45 AM
Yes, you are right, there is missing a file, also I couldn't find the file even in the 20 century repo. That is why am waiting for Karl's example. He will push the code soon (I hope).

I was in touch with them, and Andrew said that they won't be posting that because it shouldn't require that. He said he is going to look into it this evening. Apparently, that's some legacy code that's just floating around. I don't see how, but yeap -- a code check-in will fix it. In the mean time, however, you can still use the express.js calls directly. You might want to extend them a bit though.

Piper
06-01-2015, 09:57 AM
What changes would be needed in app.js to run the file properly? A list of all the commands that can be called? Where is express.js located in the code?

jveejay
06-03-2015, 01:01 PM
OK, I think I will just push my code changes sometime in the next day or two. Then you should be able to use the demo code. Sorry, I'd push right away but I just threw out my Edison and put in the Pi and started redoing everything.

To the community developers :: There are a lot of missing blanks in the code, and the Trossen guys are doing their best to keep up with us but I think the code is something we as a community can help the Trossen team with. So if we have code, I think it would be great if we could chip-in.

To the Trossen guys: Can we push changes, or do you want us to fork and create a branch for the changes?

DresnerRobotics
06-03-2015, 01:56 PM
I'd prefer a fork/branch rather than direct pushes.

FYI, there is some incorrect or unclear info being tossed around in this thread. The legacy code is there but it's not interfering with any functionality.

The node_server & hello_world demos work just fine on the backend without code modification, but do require Action Page remapping as they're a bit outdated. But in terms of the actual backend functionality, everything works fine.

The missing piece of the puzzle is the hello_world webpage demo code (currently on a private repo) that I only opened to those that were in the last Hangout.

I will be cleaning this up a bit and pushing a public repo this week, which should help people get started on it.

jveejay
06-04-2015, 12:28 AM
I hear ya, I'd make the same call.

IMHO, we should standardize the pages on app.js, instead of hardcoding it as it is right now.

For e.g., in my setup, I basically have the system populate its page-action entires by having the code figure out what pages are valid and invalid. To achieve this, there are some minimal app.js and its co-joined C api wrapper code to change a little bit. But at least the framework code itself doesn't have to be touched. The modified C wrapper code basically returns a list of valid page names, and their corresponding #s to app.js during app.js' initialize phase. This way, app.js doesn't have to be hardcoded with the list of valid pages and their associated page #s. The benefit of doing the above is that you can also call the system to just execute pages by names, instead of #s.

I'm tired, sorry if the above requires clarification. Ping me if anyone needs me to be more clear(er).


Cheers,
vj.

awill180
01-22-2016, 11:57 AM
Hi all,

I'm very much a beginner to Linux. I'm trying to get nodeserver installed and functional on an HR-OS1 but I keep running into this issue:

Fresh HR-OS1 Framework install on Raspberry Pi

cd node_server/
cd api_wrapper/
sudo make
cd ..
sudo npm install
node app.js

Output:
module.js:338
throw err;
^
Error: Cannot find module '/home/pi/HROS1-Framework/Linux/project/node_server/app.js'
at Function.Module._resolveFilename (module.js:336:15)
at Function.Module._load (module.js:278:25)
at Function.Module.runMain (module.js:501:10)
at startup (node.js:129:16)
at node.js:814:3

I also get this when attempting to run grunt
-bash: grunt: command not found

Thanks for any help!

r3n33
01-22-2016, 01:32 PM
Looking at the directory structure on git it looks like the app.js file is located in the ./src/ directory ( https://github.com/Interbotix/HROS1-Framework/blob/master/Linux/project/node_server/src/app.js )

What happens when you try:


cd /home/pi/HROS1-Framework/Linux/project/node_server/src/
node app.js

awill180
01-27-2016, 11:46 AM
Thank you for your reply!

the output is:

module.js:338
throw err;
^
Error: Cannot find module 'merge-descriptors'
at Function.Module._resolveFilename (module.js:336:15)
at Function.Module._load (module.js:278:25)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object.<anonymous> (/home/pi/HROS1-Framework/Linux/project/node_server/node_modules/express/lib/express.js:16:13)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)

Thanks again

r3n33
01-27-2016, 08:10 PM
Sounds like node is missing a required module. Have you tried to install merge-descriptors?



npm install merge-descriptors

DresnerRobotics
01-28-2016, 02:21 PM
Yeah, something changed with recent updates to node.js (I believe) that broke the current implementation of node server. Working on a fix.

awill180
02-01-2016, 12:26 PM
Sounds like node is missing a required module. Have you tried to install merge-descriptors?



npm install merge-descriptors


After repeating npm install [module] for the following modules:
merge-descriptors
express
ffi
socket.io
say

and re-compiling api_wrapper, I was able to successfully run node.js from the ../node_server/src directory

Thanks for all of your help!

r3n33
02-01-2016, 03:11 PM
You're welcome. Nice work on your part and thanks for reporting your success :)

DresnerRobotics
02-03-2016, 04:28 AM
After repeating npm install [module] for the following modules:
merge-descriptors
express
ffi
socket.io
say

and re-compiling api_wrapper, I was able to successfully run node.js from the ../node_server/src directory

Thanks for all of your help!

Thank you very much for the report back, glad to hear Renee got you up and running.

OldBotBuilder
01-30-2017, 05:29 PM
Thank you very much for the report back, glad to hear Renee got you up and running.

I have started working on my HR -OS1 again. (It has been a year.)

In the ~/HROS1-Framework/Linux/project/node_server/src directory, when I do: node app.js I get:
Listning on port 2114
Successful robot init

The 'bot rises, then settles to the sitting position.

On the web page 192.168.1.76:2114 I see the 5 buttons (Stand, Sit, Wave, Turn walk on, Say something).
When I click on any of the buttons there is no response.

BTW I have edited the app.js file to have:

/************************************
* Function calls to native code: *
* *
* *
************************************/
// these core actions must be updated
// to reflect the page builds
// on the rme editor (these are suggested
// page number selections)
function setCoreActions() {
actionList.stand = 2;
actionList.walk_rdy = 8;
actionList.sit = 16;
actionList.sitshtdown = 6;
actionList.test = 20;
actionList.yes = 23;
actionList.wow = 24;
actionList.wave = 25;
actionList.littlemac = 29;
actionList.brah = 30;
actionList.bow = 31;
actionList.whyyyy = 32;
actionList.poser = 33;
actionList.elainecarlton = 34;
actionList.affirmative = 37;
actionList.negatory = 38;
actionList.wave2 = 39;
actionList.clap = 40;
actionList.oops = 41;

Where can I go to look for a solution?

DresnerRobotics
02-02-2017, 07:26 PM
Make sure that you have actions on the pages that those buttons are linking to- the node_server demo app was put together by some folks at Intel for a show, so they had a bunch of custom animations programmed in.

OldBotBuilder
02-04-2017, 01:23 PM
I have edited the function setCoreActions section of the app.js file to be:

function setCoreActions() {
> actionList.stand = 2;
> actionList.walk_rdy = 8;
> actionList.sit = 16;
> actionList.test = 20;
> actionList.yes = 23;
> actionList.wow = 24;
> actionList.wave = 25;
> actionList.littlemac = 29;
> actionList.brah = 30;
> actionList.bow = 31;
> actionList.whyyyy = 32;
> actionList.poser = 33;
> actionList.elainecarlton = 34;
> actionList.affirmative = 37;
> actionList.negatory = 38;
> actionList.wave2 = 39;
> actionList.clap = 40;
> actionList.oops = 41;
> }

I still get no response from the action buttons on the website 192.168.1.76:2114.