mb_publisher.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 
21 #include <industrial_msgs/RobotStatus.h>
22 #include <ros/ros.h>
23 #include <ur_msgs/Analog.h>
24 #include <ur_msgs/Digital.h>
25 #include <ur_msgs/IOStates.h>
26 #include <ur_msgs/MasterboardDataMsg.h>
27 #include <ur_msgs/RobotModeDataMsg.h>
28 
30 
31 using namespace ros;
32 
34 {
35 private:
41 
42  template <size_t N>
43  inline void appendDigital(std::vector<ur_msgs::Digital>& vec, std::bitset<N> bits)
44  {
45  for (size_t i = 0; i < N; i++)
46  {
47  ur_msgs::Digital digi;
48  digi.pin = static_cast<uint8_t>(i);
49  digi.state = bits.test(i);
50  vec.push_back(digi);
51  }
52  }
53 
54  void publishIOStates(ur_msgs::IOStates& io_msg, SharedMasterBoardData& data);
55 
56  void publishRobotStatus(industrial_msgs::RobotStatus& status, const SharedRobotModeData& data) const;
57  void publishRobotStatus(const RobotModeData_V1_X& data) const;
58  void publishRobotStatus(const RobotModeData_V3_0__1& data) const;
59 
60  // publish 1-to-1 copy of MasterBoardData as a ROS message
61  void publishMasterboardData(ur_msgs::MasterboardDataMsg& msg, const SharedMasterBoardData& data) const;
62  void publishMasterboardData(const MasterBoardData_V1_X& data) const;
63  void publishMasterboardData(const MasterBoardData_V3_0__1& data) const;
64 
65  // publish 1-to-1 copy of RobotModeData as a ROS message
66  void publishRobotModeData(ur_msgs::RobotModeDataMsg& msg, const SharedRobotModeData& data) const;
67  void publishRobotModeData(const RobotModeData_V1_X& data) const;
68  void publishRobotModeData(const RobotModeData_V3_0__1& data) const;
69 
70 public:
72  : io_pub_(nh_.advertise<ur_msgs::IOStates>("ur_driver/io_states", 1))
73  , status_pub_(nh_.advertise<industrial_msgs::RobotStatus>("ur_driver/robot_status", 1))
74  , masterboard_state_pub_(nh_.advertise<ur_msgs::MasterboardDataMsg>("ur_driver/masterboard_state", 1))
75  , robot_mode_state_pub_(nh_.advertise<ur_msgs::RobotModeDataMsg>("ur_driver/robot_mode_state", 1))
76  {
77  }
78 
79  virtual bool consume(MasterBoardData_V1_X& data);
80  virtual bool consume(MasterBoardData_V3_0__1& data);
81  virtual bool consume(MasterBoardData_V3_2& data);
82 
83  virtual bool consume(RobotModeData_V1_X& data);
84  virtual bool consume(RobotModeData_V3_0__1& data);
85  virtual bool consume(RobotModeData_V3_2& data);
86 
87  virtual void setupConsumer()
88  {
89  }
90  virtual void teardownConsumer()
91  {
92  }
93  virtual void stopConsumer()
94  {
95  }
96 };
virtual void teardownConsumer()
Definition: mb_publisher.h:90
virtual void setupConsumer()
Definition: mb_publisher.h:87
Publisher masterboard_state_pub_
Definition: mb_publisher.h:39
Publisher io_pub_
Definition: mb_publisher.h:37
virtual void stopConsumer()
Definition: mb_publisher.h:93
Publisher robot_mode_state_pub_
Definition: mb_publisher.h:40
void appendDigital(std::vector< ur_msgs::Digital > &vec, std::bitset< N > bits)
Definition: mb_publisher.h:43
Publisher status_pub_
Definition: mb_publisher.h:38
NodeHandle nh_
Definition: mb_publisher.h:36


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