00001 /* 00002 * uos_freespace 00003 * Author: Marat "Peter" Purnyn 00004 * Created 11/8/2015 (based on earlier work uos-freespace.cc) 00005 */ 00006 #include <ros/ros.h> 00007 #include <sensor_msgs/LaserScan.h> 00008 #include "tf/transform_listener.h" 00009 00010 class FreeSpace { 00011 public: 00012 FreeSpace(); 00013 private: 00014 //variables 00015 double max_vel_x_, max_rotational_vel_; //max velocity of robot 00016 double turn_omega_; //this is used to keep track of the turning angle of the robot when turn_state_ = 1; 00017 int turn_state_; //if robot gets too close to an object in front, it switches to turn mode 00018 //it keeps turning until there is no more obstacle and switches out of turn mode. 00019 int scanner_orientation_; //0 for initial, 1 for right side up, -1 for upside-down laserscanner 00020 //node 00021 ros::NodeHandle nh_; 00022 ros::NodeHandle private_nh_; 00023 //publishers 00024 ros::Publisher vel_pub_; 00025 //subscribers 00026 ros::Subscriber laser_sub_; 00027 //others 00028 tf::TransformListener tf_; 00029 00030 //functions 00031 void autonomousBehaviour(const sensor_msgs::LaserScan::ConstPtr &laserscan); 00032 double calcFreespace(const sensor_msgs::LaserScan::ConstPtr &laserscan); 00033 int isInvertedScannerCheck(const sensor_msgs::LaserScan::ConstPtr &laserscan); 00034 int checkRange( 00035 const sensor_msgs::LaserScan::ConstPtr &laserscan, 00036 double xregion, double yregion, 00037 int *indexToObstacle, 00038 double *distanceToObstacle); 00039 };