service_stopper.h
Go to the documentation of this file.
1 /*
2  * Copyright 2017, 2018 Simon Rasmussen (refactor)
3  *
4  * Copyright 2015, 2016 Thomas Timm Andersen (original version)
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */
18 
19 #pragma once
20 #include <ros/ros.h>
21 #include <std_srvs/Empty.h>
22 #include "ur_modern_driver/log.h"
24 
25 enum class RobotState
26 {
27  Running,
28  Error,
31 };
32 
33 enum class ActivationMode
34 {
35  Never,
36  Always,
37  OnStartup
38 };
39 
40 class Service
41 {
42 public:
43  virtual void onRobotStateChange(RobotState state) = 0;
44 };
45 
47 {
48 private:
51  std::vector<Service*> services_;
54 
55  void notify_all(RobotState state);
56  bool handle(SharedRobotModeData& data, bool error);
57  bool enableCallback(std_srvs::EmptyRequest& req, std_srvs::EmptyResponse& resp);
58 
59 public:
60  ServiceStopper(std::vector<Service*> services);
61 
62  virtual bool consume(RobotModeData_V1_X& data)
63  {
64  return handle(data, data.robot_mode != robot_mode_V1_X::ROBOT_RUNNING_MODE);
65  }
66  virtual bool consume(RobotModeData_V3_0__1& data)
67  {
68  return handle(data, data.robot_mode != robot_mode_V3_X::RUNNING);
69  }
70  virtual bool consume(RobotModeData_V3_2& data)
71  {
72  return handle(data, data.robot_mode != robot_mode_V3_X::RUNNING);
73  }
74 
75  // unused
76  virtual bool consume(MasterBoardData_V1_X& data)
77  {
78  return true;
79  }
80  virtual bool consume(MasterBoardData_V3_0__1& data)
81  {
82  return true;
83  }
84  virtual bool consume(MasterBoardData_V3_2& data)
85  {
86  return true;
87  }
88 };
ActivationMode activation_mode_
ros::ServiceServer enable_service_
robot_mode_V3_X robot_mode
Definition: robot_mode.h:100
virtual bool consume(MasterBoardData_V1_X &data)
virtual bool consume(MasterBoardData_V3_0__1 &data)
virtual bool consume(RobotModeData_V3_0__1 &data)
virtual bool consume(RobotModeData_V3_2 &data)
virtual bool consume(RobotModeData_V1_X &data)
robot_mode_V1_X robot_mode
Definition: robot_mode.h:65
RobotState last_state_
virtual bool consume(MasterBoardData_V3_2 &data)
ros::NodeHandle nh_
std::vector< Service * > services_
RobotState
ActivationMode


ur_modern_driver
Author(s): Thomas Timm Andersen, Simon Rasmussen
autogenerated on Fri Jun 26 2020 03:37:00