Wrote ros::init before declaring a NodeHandle which was earlier wrong.