src/walker.cpp
walker::walker(ros::NodeHandle nh, ros::Subscriber subs, ros::Publisher pub) {
  linearVel = 0.5;
  angularVel = 1.0;
  pub = nh.advertise<geometry_msgs::Twist>("/mobile_base/commands/velocity",
                                           1000);
  subs = nh.subscribe<sensor_msgs::LaserScan>("/scan", 100,
                                              &walker::laserScanCallback, this);
  ros::Rate loopRate(5);
  while (ros::ok()) {
    // Object to get linear and angular velocity
    geometry_msgs::Twist twist;

    // Initialize twist
    twist.linear.x = 0;
    twist.linear.y = 0;
    twist.linear.z = 0;
    twist.angular.x = 0;
    twist.angular.y = 0;
    twist.angular.z = 0;
    if (obstacleInRange() == true) {
      ROS_INFO_STREAM("The obstacle is in the range, Turning...");
      twist.angular.z = angularVel;
    } else {
      ROS_INFO_STREAM("Moving forward, No obstacle present");
      twist.linear.x = linearVel;
    }
    pub.publish(twist);
    ros::spinOnce();
    loopRate.sleep();
  }
}
/*
 * @brief: Implementation of the walker constructor which will be used to help the turtlebot
 *         move forward and avoid obstacles
 * @param: nh is the node handler declared for creating publisher and subscriber
 * @param: subs is the subscriber to the topic generated by the turtlebot simulation
 * @param: pub is the publisher used to publish velocity data
 */
@brief: Implementation of the walker constructor which will be used to help the turtlebot
move forward and avoid obstacles
@param: nh is the node handler declared for creating publisher and subscriber
@param: subs is the subscriber to the topic generated by the turtlebot simulation
@param: pub is the publisher used to publish velocity data
@brief : Implementation of the walker constructor which will be used to help the turtlebot move forward and avoid obstacles @param : nh is the node handler declared for creating publisher and subscriber @param : subs is the subscriber to the topic generated by the turtlebot simulation @param : pub is the publisher used to publish velocity data
walker::walker(ros::NodeHandle nh, ros::Subscriber subs, ros::Publisher pub) {
  linearVel = 0.5;
  angularVel = 1.0;
  pub = nh.advertise<geometry_msgs::Twist>("/mobile_base/commands/velocity",
                                           1000);
  subs = nh.subscribe<sensor_msgs::LaserScan>("/scan", 100,
                                              &walker::laserScanCallback, this);
  ros::Rate loopRate(5);
  while (ros::ok()) {
    geometry_msgs::Twist twist;
    twist.linear.x = 0;
    twist.linear.y = 0;
    twist.linear.z = 0;
    twist.angular.x = 0;
    twist.angular.y = 0;
    twist.angular.z = 0;
    if (obstacleInRange() == true) {
      ROS_INFO_STREAM("The obstacle is in the range, Turning...");
      twist.angular.z = angularVel;
    } else {
      ROS_INFO_STREAM("Moving forward, No obstacle present");
      twist.linear.x = linearVel;
    }
    pub.publish(twist);
    ros::spinOnce();
    loopRate.sleep();
  }
}
walker :: walker ( ros :: NodeHandle nh , ros :: Subscriber subs , ros :: Publisher pub ) { linearVel = 0.5 ; angularVel = 1.0 ; pub = nh . advertise < geometry_msgs :: Twist > ( " " , 1000 ) ; subs = nh . subscribe < sensor_msgs :: LaserScan > ( " " , 100 , & walker :: laserScanCallback , this ) ; ros :: Rate loopRate ( 5 ) ; while ( ros :: ok ( ) ) { geometry_msgs :: Twist twist ; twist . linear . x = 0 ; twist . linear . y = 0 ; twist . linear . z = 0 ; twist . angular . x = 0 ; twist . angular . y = 0 ; twist . angular . z = 0 ; if ( obstacleInRange ( ) == true ) { ROS_INFO_STREAM ( " " ) ; twist . angular . z = angularVel ; } else { ROS_INFO_STREAM ( " " ) ; twist . linear . x = linearVel ; } pub . publish ( twist ) ; ros :: spinOnce ( ) ; loopRate . sleep ( ) ; } }
@brief: Implementation of the walker constructor which will be used to help the turtlebot
         move forward and avoid obstacles
 @param: nh is the node handler declared for creating publisher and subscriber
 @param: subs is the subscriber to the topic generated by the turtlebot simulation
 @param: pub is the publisher used to publish velocity data
@brief : Implementation of the walker constructor which will be used to help the turtlebot move forward and avoid obstacles @param : nh is the node handler declared for creating publisher and subscriber @param : subs is the subscriber to the topic generated by the turtlebot simulation @param : pub is the publisher used to publish velocity data
// Object to get linear and angular velocity // Initialize twist