What are Kalman filters ?

Why to use Kalman filter ?

The sensor measurements are not generally accurate, they usually have unpredictable, random and uncertain error/variation in their measurements. What does that mean ? Consider a thermometer which reads/measures room temperature, In a room with steady/constant temperature the sensor outputs a varying temperature measurement within a given range, the readings will be scattered around the actual room temperature, this is because the sensors generally have a degree of uncertainty in their measurement.

In the image below the marked X’s demonstrates the sensor readings over a period of time. You can see the though the actual temperature of the room is constant, the readings are distributed over a range of values around the actual temperature.

Screen Shot 2017-12-04 at 8.08.28 AM

 

If sensor measurements return uncertain measurements, how do we know the actual room temperature ?

We’ll, that’s where Kalman filters comes to your rescue. Kalman filter is an iterative mathematical approach which is used to quickly (with less number of actual readings and iterations) converge to a better estimation of the actual value (better than the sensor measurement itself). In this case using Kalman filter will quickly help us estimate the actual room temperature using the uncertain measurements. In the above you can see how Kalman filter technique helps to quickly approximate the actual room temperature by converging close to the actual value by making use of the uncertain sensor measurements.

The application of Kalman filters are wide, For example Similar issues too are found when Lidar or Radar measurements are used to object tracking in self driving cars, the right estimate of other vehicle on the road is critical for safe driving, Kalman filter are used here too for estimation the actual position and velocity of other vehicles on the road.

Advertisements

Parallelism Is Not Concurrency

Existential Type

In an earlier post I mentioned that one goal of the new introductory curriculum at Carnegie Mellon is to teach parallelism as the general case of computing, rather than an esoteric, specialized subject for advanced students.  Many people are incredulous when I tell them this, because it immediately conjures in their mind the myriad complexities of concurrency: locks, monitors, deadlock, dining philosophers, ….  And if you look at the recent research literature, you will see countless papers of the form (a) parallelism is important, so (b) let’s talk about concurrency.  The situation has gotten so bad that I think that most computer scientists cannot distinguish the two concepts.  (Or maybe they willfully confuse the two so as to justify funding for work on concurrency by appealing to the importance of parallelism.)

Given this state of affairs, I cannot explain what we are doing at Carnegie Mellon (to anyone who doesn’t…

View original post 1,830 more words

Cracking the Source: UnderStanding NodeJs Source Code -1

………!!!!…………!!!!!!!!……..!!!!!! Its time for some extreme engineering 😛
Welcome to the series Cracking source ..
This is the first post in the series of posts to come about understanding the source code of Node.JS .  Its been enough time since i’ve been using Node as the webserver for all my projects and its time to understand the source and making an attempt to contribute to its repo ! This blog cannot be considered as a step by step tutorials on understand the source of NodeJs , this is the place where i share my learning , experience and views in the course of journey in understanding the source code of NodeJS.

I stumbled upon this pull request on my mobile screen while i was travelling back home few days ago . The request on the this file called tls.js  from the lib folder of the nodejs source tree . This is how the i started exploring tls.js from the source

The tls module uses OpenSSL (uses the underlying OpenSSL executable installed on your system) to provide Transport Layer Security and/or Secure Socket Layer: encrypted stream communication.

So this post is about tls.js and how it works .

Here is the documentation of the TLS api http://nodejs.org/api/tls.html  . Lets get into details of the API tls.getCiphers()

Here is the code of the API tls.getCiphers() from its source

exports.getCiphers = function() {
  var names = process.binding('crypto').getSSLCiphers();
  // Drop all-caps names in favor of their lowercase aliases,
  var ctx = {};
  names.forEach(function(name) {
    if (/^[0-9A-Z\-]+$/.test(name))
        name = name.toLowerCase();
    ctx[name] = true;
  });
  return Object.getOwnPropertyNames(ctx).sort();
};

process.binding() is a Javascript interface for the C++ core of Node . So process.binding(‘crypto’).getSSLCiphers will result in execution of corresponding function from the c++ core of Node , here is the link to source of getSSLCiphers() from the c++ core https://github.com/joyent/node/blob/master/src/node_crypto.cc. We shall get into the C++ core in the further posts to come .
The C++ core returns an array contains all Cipher names .
Later the array of names are iterated using forEach() method of node . Each names are tested against the Regular Expression /^[0-9A-Z\-] ,Any string that begins/ends and containing digits (0-9) and alphabets in caps (A-Z) and another character ‘-‘ are matched and set as keys in the ctx{} object . And at the end the keys of the object ctx containing the names of the Cipher are returned as an array in sorted order using the following line of code

return Object.getOwnPropertyNames(ctx).sort();

Lets use this API from the tls library , and here is the code

var tls = require('tls');
var cipher = tls.getCiphers();
console.log(cipher);

Lets get into the C++ core in the posts to come in future , but thats it for now .Wait for more exciting posts to come in my journey through source of Node .
Till then happy Coding 😀

Intro to AngularJS and Client Server communication using nodeJS and AngularJS:Posting data to the Node-Express server using AngularJS

Hmmmm , its time for a new post !!! After the last post on Depth First Search in python , now you have a U-turn ahead and this post is on achieving client server communication using NodeJS server in the backend and AngularJS in the front end  !!!

If your curious on achieving client-server communication using backbone.JS and nodeJS , here is the link
In case you try the same using websockets and nodeJS , here is the link for the post .

And here is the github link for the codes posted in this blog !

Lets get started with how to achieve it using Angular and NodeJS as server .This might be a very simple task for a AngularJS developer ,but the blogs are not always meant for experts 😛  Since the blog is aimed at web developers who are starting to develop web applications by using NodeJs in the backend and AngularJS in the front end , ill try to keep the post as simple and easy as possible .

So , Lets get started ……….

Before we begin here are the basics of AngularJS ,

  • AngularJS provides a set of html attributes which starts with ng , example ng-app,ng-controller,ng-view,ng-click , these attributes are used to direct and communicate with angularJS .
  • ng-app attribute tells angularJS to bootstrap or start the application , usually this is associated with the html tag of the application , example 
<html ng-app>
     <head>
     </head>
     <body>
         <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.1/angular.min.js"></script>
     </body>
</html>

 controllers in AngularJS

  • Using controllers you can tell AngularJS ,which of javascript variables or primitives forms the Models data which will be used the views
  • Angular by default passes this object called $scope for every Angular controller
  • By assigning the data to this $scope object you’ll
    be telling angular that the assigned data are those which are supposed to be the used by views to render HTML , this is the model data

To brief , the controllers in angularJS have three responsibilities
1.Initializing the model variables
2.Give views the access to the models data by assigning them to the $scope variable
3.It provides the code and logic to execute while users interact with the various parts of the controllers

$http is another directive passed onto a controller and can be made use of to interact with server (make GET,POST requests etc…) , we’ll be using same directive in this post to interact with the server

One of the amazing feature of Angular which makes application development really easy is the ability of Angular’s controller to bind the data of an HTML element (like a input box , text box or any widget) with the models data and it also provides event handlers/methods to propagate the changes to the model data automatically  

Here is an simple example of how controller binds the data and the views , a angular controller is binded to the application by using ng-controller attribute  within a html element , the controller will be incharge of the application within the scope of that html tag,the explanation is given after the code example  

<html ng-app>
  <head>
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.1/angular.min.js"></script>
  </head>
    <body>
      <div ng-controller="firstController">
      <!--firstController is the name of the controller function, its scope expands within this div element -->
        <input ng-model="modelData" >
       <!--
      -->
      <p>{{modelData}}</p>
    </div> 

       <script>
         function firstController($scope){ //controller function
           $scope.modelData='';
 /*This is the same variable which is used in html,now the value is variable is binded the input box data*/
           $scope.$watch('modelData',function(newVal,oldval,scope){
             console.log("New: "+newVal);/*Watch the browser console*/
           },true);
           /*$scope.$watch listens to the changes in the modelData variable ,
             The value in the modelData variable is changed when the value in the input box is changed ,
             these are automatically bound together  using <input ng-model="modelData" > */
         }
       </script>
     </body>
</html>

ng-model=”modelData”, This is like a global declaration of the variable ‘modelData’ within the controllers scope(within div element in this case) without the need to declare it anywhere .This variable now can be accessed as model data inside the html to render by using it inside the double braces {{}}, this is how you can bind the data with the views . Now lets say you have some application logic to be performed using this data , so you need to be able to access the variable within the Javascript too , the variable `modelData` can be accessed only within the controller function (inside your javascript) which is incharge the current html scope , in this case the data is accessible through the firstController() , controller function (since this is the controller function for the input elements scope,that is, the input element inside the scope of the div with ng-controller=”firstController”).Now as i had already mentioned the model’s data can be accessed using the $scope object which is passed onto the controller,so this can be accessed using $scope.modelData inside the controller function of the Javscript
ng-model=”modelData suggests that the $scope.modelData is the controller variable with which this view is associated,and this is how angular easily brings in binding of the views and data with the help of the controller.
Now lets say you have used {{modelData}} at ten different places in your html to render the view , the change to the modelData is automatically propagated to all thee places in views so that the html with new data is rendered
Here is the screenshot on with the browsers console opened

Angular MVC
Angular MVC

Phew!!!!! 😯 Lets now start with the headline of the post …How to communicate to the server from angular ,and how to handle it using NodeJs-express server
Here is the code snippet ang2.html of where angular makes a POST request to the server when user clicks the submit ,

<html ng-app>
<body>
    <form ng-controller='appController' ng-submit="send()">
      <!--send() function from the controller is called on form submission -->
        <textarea ng-model='data.textdata'></textarea>
        <pre>{{data.textdata}}</pre>
        <input type="submit" ngClick="Submit">
        <div><pre>{{response.data}}</pre>
        </div>
        <ng-form>

    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.1/angular.min.js">
    </script>
    <script>
        function appController($scope, $http) {
            /*$http directive is used to communicate ot the server */
            $scope.data = {}
            $scope.response = {}

            $scope.send = function () {
                /*executed when submit is clicked*/
                console.log("inside click");
                console.log($scope.data.textdata);

                var posting = $http({
                    method: 'POST',
                    /*posting to /post */
                    url: '/post',
                    data: $scope.data,

                    processData: false
                })
                posting.success(function (response) {
                    /*executed when server responds back*/
                    console.log(response);
                    $scope.response.data = response;
                });
            }
        };
    </script>
</body>

</html>

Here is the server code app.js using node.js-express to handle the POST request from the AngularJS frontend script and respond back to it .

var express = require('express')
, http = require('http'), path = require('path');

var app = express();

app.use(express.static(path.join(__dirname, 'public')));
/*JS client side files has to be placed under a folder by name 'public' */
app.use(express.bodyParser());
/*to access the posted data from client using request body*/
app.post('/post', function (req, res) {
    /* Handling the AngularJS post request*/
    console.log(req.body);
    res.setHeader('Content-Type', 'application/json');
    /*response has to be in the form of a JSON*/
    req.body.serverMessage = "NodeJS replying to angular"
        /*adding a new field to send it to the angular Client */
    res.end(JSON.stringify(req.body));
    /*Sending the respone back to the angular Client */
});

http.createServer(app).listen(3000, function () {
    console.log("Express server listening on port 3000");
});

Create a folder called public and place ang2.html inside it
, Here is the link for the codes published in this post

Here are the screenshots from server and client side ,

Angular posting data
Angular posting data

server handling client angularJS request
server handling client angularJS request

fianlly !!!!!!!!!!!!!!!!thats the end of this post , i hope you guys found this post to be helpful in understanding how to use AngularJS to communicate to the server , will catch up soon with further exciting posts , till then Happy coding 😀

Obtaining user logs! (Task 1)

Good post!

Karthik Srivatsa

Out of a lot of options that we had, we opted for OpenCart ( http://www.opencart.com/ ) for our front end e-commerce solution. So the first step was to download and configure open cart over a locally running LAMP server. The steps for setting up the OpenCart site on your Apache server can be found here : ” http://docs.opencart.com/display/opencart/Installation ” .

 

                      Image

 

Apache provides a mod_usertrack ( “http://httpd.apache.org/docs/2.0/mod/mod_usertrack.html ” ) module for logging the user activity by using cookies and generates a ‘clickstream’ log. An enhanced version of the same module can be found here by the name mod_cookietrack : ” https://github.com/piykumar/modified_mod_cookietrack ” . This module requires apache-dev to be installed and perl. After that you install it using the command ‘sudo ./build.pl’.

 

NOTE : If you have errors saying that apxs file is not found in /usr/sbin/apxs try to look for it in the folder /usr/bin/apxs and…

View original post 465 more words

Simple CSS3 Transformations – transitions , translations and rotation

 W3C consortium was setup to standardize different browser interpreted languages , but different browser vendors wanted to provide support for experimental css3 features till they are standardized by W3C , such experimental and browser specific css3 features are to used with the prefix provided the vendor , -webkit-(chrome and safari),-o-(opera),-moz-(firefox),-ms-(IE), in the following code snippet i’ve just used -webkit- prefixes , so the code just works in Google chrome browser , to make it work in other browsers , just repeat the attributes with the vendor specific prefixes 

Image

<!DOCTYPE html>
<html>
<head>
<title>First Transform </title>
<style>
h1 {
text-align : center ;
font-family : Futura ;

}
h1:hover {

-webkit-transition :6s all steps(6,end);
-webkit-transform : translateX(600px);
/* the header (h1 ) moves on X-axis (translates) 600px to the right , but the transition(webkit-transition) effect in place
makes sure that this transition takes place over a time of 6 seconds and 6 steps on mouse hover */
}
img.tilt:hover {
-webkit-transform : rotate(9.0deg); /*Rotates the image by 9 degrees on mouse hover and transition makes the effect take place smoothly over a period of 5 seconds */
-webkit-transition : 5s all;
}
</style>
</head>
<body>
<h1>CSS3 Testing</h1>
<p><img src = “deb.jpg” style= “width:300px;height:200px; margin: 0 2em 2em 0;”class=”tilt” >Hi , this is Debian , Debian is a free Operating system , the kernel used by debian is the kernel written Linux torwals .Debian is a free and universal operating system where everything , i repeat , everything in the operating system is free , the source for every binary in DEBIAN is available, All the softwares for debian comes packaged in .deb(.debian) files where these are hosted in their official repositories </p>

</body>
</html>