brake_test_executor_node_service_calls.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2019 Pilz GmbH & Co. KG
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8 
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU Lesser General Public License for more details.
13 
14  * You should have received a copy of the GNU Lesser General Public License
15  * along with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef BRAKE_TEST_EXECUTOR_NODE_SERVICE_CALLS_H
19 #define BRAKE_TEST_EXECUTOR_NODE_SERVICE_CALLS_H
20 
21 #include <ros/ros.h>
22 #include <std_srvs/Trigger.h>
23 
24 #include <prbt_hardware_support/BrakeTest.h>
25 #include <prbt_hardware_support/SendBrakeTestResult.h>
26 
27 namespace prbt_hardware_support
28 {
29 
30 template<class T>
31 static void triggerServiceCall(T& client)
32 {
33  ROS_DEBUG_STREAM("Calling service: " << client.getService() << ")");
34  std_srvs::Trigger srv;
35  if ( !client.call(srv) )
36  {
37  ROS_WARN_STREAM("Calling service " << client.getService() << " failed.");
38  return;
39  }
40 
41  if (!srv.response.success)
42  {
43  ROS_WARN_STREAM("Execution of service " << client.getService()
44  << " failed with error message\n:"
45  << srv.response.message);
46  }
47 }
48 
49 template<class T>
50 static BrakeTest::Response executeBrakeTestCall(T& client)
51 {
52  ROS_DEBUG_STREAM("Calling service: " << client.getService() << ")");
53  BrakeTest srv;
54  if ( !client.call(srv) )
55  {
56  ROS_WARN_STREAM("Calling service " << client.getService() << " failed.");
57  BrakeTest::Response res;
58  res.success = false;
59  res.error_msg = "Failed to trigger brake test via service " + client.getService();
60  res.error_code.value = BrakeTestErrorCodes::TRIGGER_BRAKETEST_SERVICE_FAILURE;
61  return res;
62  }
63  return srv.response;
64 }
65 
66 template<class T>
67 static bool sendBrakeTestResultCall(T& client,
68  const bool brake_test_result)
69 {
70  ROS_DEBUG_STREAM("Calling service: " << client.getService());
71  SendBrakeTestResult srv;
72  srv.request.result = brake_test_result;
73  return client.call(srv);
74 }
75 
76 }
77 
78 #endif // BRAKE_TEST_EXECUTOR_NODE_SERVICE_CALLS_H
static bool sendBrakeTestResultCall(T &client, const bool brake_test_result)
#define ROS_WARN_STREAM(args)
#define ROS_DEBUG_STREAM(args)
static BrakeTest::Response executeBrakeTestCall(T &client)


prbt_hardware_support
Author(s):
autogenerated on Thu Feb 13 2020 03:16:51