ros/src/dirt_detection/src/dirt_detector.cpp
//For Subscribing to all the necessary topics
For Subscribing to all the necessary topics
For Subscribing to all the necessary topics
void DirtDetector::SubscribeToTopics()
{
    if (!robot_locations_topic.empty())
    {
        ROS_INFO("[%s]: Subscribing to topic '%s'", node_name_.c_str(), robot_locations_topic.c_str());
        locations_subscriber = node_.subscribe(robot_locations_topic, 10, &DirtDetector::locationsCallBack, this);
    }
    else
    {
        ROS_INFO("[%s]: Variable '%s' is Empty", node_name_.c_str(), robot_locations_topic.c_str());
    }
    if (!map_topic_.empty())
    {
        ROS_INFO("[%s]: Subscribing to topic '%s'", node_name_.c_str(), map_topic_.c_str());
        map_subscriber = node_.subscribe(map_topic_, 1, &DirtDetector::mapCallBack, this);
    }
    else
    {
        ROS_INFO("[%s]: Variable '%s' is Empty", node_name_.c_str(), map_topic_.c_str());
    }
    if (!scan_topic_.empty())
    {
        ROS_INFO("[%s]: Subscribing to topic '%s'", node_name_.c_str(), scan_topic_.c_str());
        scan_subscriber = node_.subscribe(scan_topic_, 1, &DirtDetector::scanCallBack, this);
    }
    else
    {
        ROS_INFO("[%s]: Variable '%s' is Empty", node_name_.c_str(), "scan_topic_");
    }
    if (!active_tasks_topic.empty())
    {
        ROS_INFO("[%s]: Subscribing to topic '%s'", node_name_.c_str(), active_tasks_topic.c_str());
        active_tasks_subscriber = node_.subscribe(active_tasks_topic, 1, &DirtDetector::tasksCallBack, this);
    }
    else
    {
        ROS_INFO("[%s]: Variable '%s' is Empty", node_name_.c_str(), "scan_topic_");
    }
}
void DirtDetector :: SubscribeToTopics ( ) { if ( ! robot_locations_topic . empty ( ) ) { ROS_INFO ( " " , node_name_ . c_str ( ) , robot_locations_topic . c_str ( ) ) ; locations_subscriber = node_ . subscribe ( robot_locations_topic , 10 , & DirtDetector :: locationsCallBack , this ) ; } else { ROS_INFO ( " " , node_name_ . c_str ( ) , robot_locations_topic . c_str ( ) ) ; } if ( ! map_topic_ . empty ( ) ) { ROS_INFO ( " " , node_name_ . c_str ( ) , map_topic_ . c_str ( ) ) ; map_subscriber = node_ . subscribe ( map_topic_ , 1 , & DirtDetector :: mapCallBack , this ) ; } else { ROS_INFO ( " " , node_name_ . c_str ( ) , map_topic_ . c_str ( ) ) ; } if ( ! scan_topic_ . empty ( ) ) { ROS_INFO ( " " , node_name_ . c_str ( ) , scan_topic_ . c_str ( ) ) ; scan_subscriber = node_ . subscribe ( scan_topic_ , 1 , & DirtDetector :: scanCallBack , this ) ; } else { ROS_INFO ( " " , node_name_ . c_str ( ) , " " ) ; } if ( ! active_tasks_topic . empty ( ) ) { ROS_INFO ( " " , node_name_ . c_str ( ) , active_tasks_topic . c_str ( ) ) ; active_tasks_subscriber = node_ . subscribe ( active_tasks_topic , 1 , & DirtDetector :: tasksCallBack , this ) ; } else { ROS_INFO ( " " , node_name_ . c_str ( ) , " " ) ; } }
For Subscribing to all the necessary topics
For Subscribing to all the necessary topics
// For Robot location //For Subscribing to "map" //For Subscribing to "modified_occ_grid" //if (!mod_occ_grid_topic_.empty()) //{ //    ROS_INFO("[%s]: Subscribing to topic '%s'", node_name_.c_str(), mod_occ_grid_topic_.c_str()); //   occ_grid_subscriber = node_.subscribe(mod_occ_grid_topic_, 1, &DirtDetector::occGridCallBack, this); //} //else //{ //    ROS_INFO("[%s]: Variable '%s' is Empty", node_name_.c_str(), mod_occ_grid_topic_.c_str()); //} //For Subscribing to "scan" //For Subscribing to "active_tasks"