RAPP Platform  v0.6.0
RAPP Platform is a collection of ROS nodes and back-end processes that aim to deliver ready-to-use generic services to robots
 All Classes Namespaces Files Functions Variables Macros
hazard_detection.cpp
Go to the documentation of this file.
1 /******************************************************************************
2 Copyright 2015 RAPP
3 
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7 
8  http://www.apache.org/licenses/LICENSE-2.0
9 
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15 
16 ******************************************************************************/
17 
18 #include <hazard_detection/hazard_detection.hpp>
19 
20 
21 HazardDetection::HazardDetection(void)
22 {
23  // Fetching the service topic URI parameter
24  if(!nh_.getParam("/rapp_hazard_detection_light_check_topic", lightCheckTopic_))
25  {
26  ROS_ERROR("Light check topic param does not exist");
27  }
28 
29  // Creating the service server concerning the light_check functionality
30  lightCheckService_ = nh_.advertiseService(lightCheckTopic_,
31  &HazardDetection::lightCheckCallback, this);
32 
33  // Fetching the service topic URI parameter
34  if(!nh_.getParam("/rapp_hazard_detection_door_check_topic", doorCheckTopic_))
35  {
36  ROS_ERROR("Door check topic param does not exist");
37  }
38 
39  // Creating the service server concerning the door_check functionality
40  doorCheckService_ = nh_.advertiseService(doorCheckTopic_,
41  &HazardDetection::doorCheckCallback, this);
42 }
43 
44 bool HazardDetection::lightCheckCallback(
45  rapp_platform_ros_communications::LightCheckRosSrv::Request& req,
46  rapp_platform_ros_communications::LightCheckRosSrv::Response& res )
47 {
48  int light_level = light_check.process(req.imageFilename);
49  res.light_level = light_level;
50  return true;
51 }
52 
53 bool HazardDetection::doorCheckCallback(
54  rapp_platform_ros_communications::DoorCheckRosSrv::Request& req,
55  rapp_platform_ros_communications::DoorCheckRosSrv::Response& res )
56 {
57  int door_angle = door_check.process(req.imageFilename);
58  res.door_angle = door_angle;
59  return true;
60 }