Introduction: Video With Sensorial Effects Using NCL and Galileo

These materials and the information contained in this instructable are provided by students enrolled at Software of Places (www.softwareofplaces.com)
Class at PUC-Rio University. The content represented here is the student’s final project for class evaluation purpose published by the student and is solely the responsibility of the page author. Statements made and opinions expressed are strictly those of the author and not of PUC-Rio University.

Our project goal in this project is to develop video-based application using light, air flow and smell actuators to increase the user experience, similar to the 4D sensorial cinema rooms.

  • The sensorial actuators application is writted in NodeJS for the Intel Galileo using a Grouve kit.
  • The video-based application is writted in NCL(Nested Context Language). NCL is the declarative language for the development of interactive applications for Brazilian Digital TV and an ITU-T Recommendation for IPTV services.

To help evaluate our approach, presents a usage scenario using videos that are related with the proposed actuators.

Requirements Basic

Bill of Materials

Step 1: Galileo Coding

In order to develop the sensorial actuators application we use the Intel XDK IoT edition. Our Galileo use a Seeed Grouve Kit to use connect the actuators. Then we create NodeJS to use the actuators.

The code is annex.

Step 2: Coding Fan Control

To control the fan, we use a GrouveRelay from the MRAA library in port Grouve digital port #3. The code is like what follows:

var myRelay2 = new groveSensor.GroveRelay(3);
myRelay2.off(); 
var airStatus = 0; 

We support the controle of the air by a toggle function (toggleAir). The code is similar to:

function toggleAir() {
    airStatus = !airStatus; airStatus ? myRelay2.on() : myRelay2.off();
}

Step 3: Coding Lamp Control

To control the lamp, we use a GrouveRelay from the MRAA library in port Grouve digital port #6. The code is similar to:

var myRelay = new groveSensor.GroveRelay(6);
var lightStatus = 0;
myRelay.off(); 

We support the controle of the light by a toggle function (toggleLight). The code is similar to:

function toggleLight() {
    console.log('light changed');
    lightStatus = !lightStatus;
    lightStatus ? myRelay.on() : myRelay.off();
};

Step 4: Coding Smell Control

To emit smell sensorial effect we use a Air Wick Freshmac.

It use two 1,5V battery. Then we can use it in a IO port of the GrouveSystem as we can see in the figure.

In the NodeJS code, we use a GrouveRelay from the MRAA library in port Grouve digital port #3. The code is similar to:

var myEnergy = new mraa.Gpio(8);
myEnergy.dir(mraa.DIR_OUT);
myEnergy.write(0); 

We support the controle of the smell by a toggle function (toogleSmell). The code is similar to:

var smellLevel = 1;
function startSmell() {
    if(myEnergy.read()) return;
    myEnergy.write(1);
    setTimeout(function () {
        myEnergy.write(0);
    }, 200*smellLevel);
}

var smellInterval;
var smellStatus = 0;
function toggleSmell() {
   if(smellStatus == 0){
      startSmell();
      smellInterval = setInterval(startSmell, 6000);
      smellStatus = 1;
    }else{
     clearInterval(smellInterval);
      myEnergy.write(0);
      smellStatus = 0;
   }
};

Step 5: Coding Actuators HTTP Service

Toe enable the remote call of the actuators, we use web server using the express library. The code is similar to:

var app = express();
var root = path.join(__dirname, './');
app.use(express.static(path.join(root, '/client')));
app.set('views', path.join(root, '/views')); 
app.set('view engine', 'ejs'); 
app.use(bodyParser.urlencoded({ extended: true })); 
app.use(bodyParser.json());

The default root to the "Sensorial galileo control" page is define like what follow.

var router = express.Router(); 
router.get('/', function(req, res) {res.render('index'); });
app.use('/', router);

The light REST API to control de actuators is define like what follow:

var api1 = express.Router(); 
api1.get('/light', function(req, res) { res.json({ message: lightStatus }).end(); });
api1.put('/light', function(req, res) { toggleLight();res.json({ message: lightStatus }).end(); });
app.use('/api', api1);

The light REST API to control the air is define like what follow:

var api2 = express.Router();
api2.get('/air', function(req, res) {res.json({ message: airStatus }).end(); }); 
api2.put('/air', function(req, res) {toggleAir();res.json({ message: airStatus }).end();});
app.use('/api', api2);

The light REST API to control de smell is define like what follow:

var api3 = express.Router();
api3.get('/smell', function(req, res) {res.json({ message: smellStatus }).end(); });
api3.put('/smell', function(req, res) { toggleSmell(); res.json({ message: smellStatus }).end(); });
app.use('/api', api3);

Step 6: Coding NCL Application

To develop the NCL application with use the NCL Composer authoring tool.

The Picture illustrate the structural view of the application. At the begin the use must selection between two images to informs its position(close of far to screen).

We use a NClua code to performs the call for the REST API of the Galileo. The code is similar to.

local api_uri = 'http://139.82.95.37:8080/api/'
local function actuator_request( uri )
    local headers = {}
    local body = ''
    local status, code, headers, body = http.put(uri, headers, body)
end

Three videos are presented in the NCL application.

  1. The first video presents the run rising in a city. At the moment of video presentation, the light of the lamp is turned on.
  2. The send video presents a overflight in lavender fields. At the moment of video presentation, the freshener dispenser with lavender sent in turned on.
  3. The third video presents a parachute jump. At the moment of video presentation, the air fan is turned on.

Comments

author
seamster (author)2016-06-28

Nicely done, thanks for sharing!

About This Instructable

201views

0favorites

License:

More by alanlivio:Video with sensorial effects using NCL and Galileo
Add instructable to: