Skip to content
This repository was archived by the owner on Jul 22, 2021. It is now read-only.

node_server

Daniel Alner edited this page Aug 11, 2015 · 5 revisions

Overview of node_server

Node.js API Server for HR-OSX Humanoid Robots

This project allows the use of a Node.js API Server. This node_server project connects to the HR-OSX-Framework libraries via Linux/build/api_wrapper/api_wrapper.so The api_wrapper.so has basic high-level functions of the robot exposed to the node_server API, allowing users to send high-level commands such as "walk on/off, walk forward/back X speed, Turn left/right Y degree/sec, play action page X, etc"

It uses a socket server connection over IP to communicate with a Hello World app on a remote device (Android Tablet, etc).

Getting Started

Ensure these are installed via root user or sudo.

node_server dependencies & install

Dependencies: (installed via package.json file)

Change Directory to your node_server project folder:

$ cd path/to/HROSXFramework/Linux/project/node_server

Install dependencies via npm install, using package.json file within node_server:

$ npm install

This installs socket.io, ffi, node-gyp, and grunt.

To launch the node_server app.js program:

$ node app.js

Socket requests

You can use the socket.io npm module to send requests to the node server.

See client side javascript API

See client side javascript API hello world

Basic syntax:

socket.emit('command', parameter)

Command options (Client->Server)

socket.emit('initialize')
Sets core actions, initializes the servos and sits the robot

socket.emit('servoshutdown')
Sits robot and turns off servos

socket.emit('disconnect')
Safely disconnect from server (sits robot)

socket.emit('action', integer/string)
Calls page number from rme, or string name from list of core actions

socket.emit('walktoggle', bool)
Turns on or off walking engine (first plays the walking stance action)

socket.emit('walking', {x:x, y:y})
Takes json element in x an y integer coords and sends them to the walking engine (-255,255)

Command options (Server->Client)

socket.on('batterylevel', batteryLevel) Gives client current battery level (currently implemented but unsure of results meaning)

Optional:

If you would like to build a minimal version of the node server, dev dependencies are required:

$ npm install --dev

Lint node.js install:

$ grunt

To launch the minimized node_server app.js program:

$ node node-app.min.js

node_server start on boot

  • HR-OS5 Humanoid Research Robot

    • Use upstart to start node server
  • HR-OS1 Humanoid Robot

    • Use init.d to start node server

node_server & Android App 'Hello World' walkthrough

References

Clone this wiki locally