RelayNode.h
Go to the documentation of this file.
1 /*********************************************************************
2  * Software License Agreement (BSD License)
3  *
4  * Copyright (c) 2017, Dataspeed Inc.
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  *
11  * * Redistributions of source code must retain the above copyright
12  * notice, this list of conditions and the following disclaimer.
13  * * Redistributions in binary form must reproduce the above
14  * copyright notice, this list of conditions and the following
15  * disclaimer in the documentation and/or other materials provided
16  * with the distribution.
17  * * Neither the name of Dataspeed Inc. nor the names of its
18  * contributors may be used to endorse or promote products derived
19  * from this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32  * POSSIBILITY OF SUCH DAMAGE.
33  *********************************************************************/
34 
35 #ifndef _RELAY_NODE_H_
36 #define _RELAY_NODE_H_
37 
38 #include <ros/ros.h>
39 #include <std_msgs/Bool.h>
40 #include <std_msgs/Byte.h>
41 #include <std_msgs/String.h>
42 
43 struct ftdi_context;
44 
45 namespace sainsmart_relay_usb
46 {
47 
48 class RelayNode
49 {
50 public:
52  ~RelayNode();
53 
54 private:
55  void serviceDevice();
56  void timerCallback(const ros::WallTimerEvent& event);
57  void recv(const std_msgs::Byte::ConstPtr& msg);
58 
59  void publishReady(bool ready) {
60  std_msgs::Bool msg; msg.data = ready;
61  pub_ready_.publish(msg);
62  }
63  void publishSerial(const std::string &serial) {
64  std_msgs::String msg; msg.data = serial;
65  pub_serial_.publish(msg);
66  }
67 
68  // Parameters
69  std::string param_serial_; // Serial number
70  std::string param_desc_; // Description
71 
72  // Timer
74 
75  // FTDI context
76  ftdi_context *ctx_;
77 
78  // Subscribed topics
80 
81  // Published topics
84 
85  // Device serial number
86  std::string serial_live_;
87 
88  // Keep track if USB device is open
89  bool open_;
90 };
91 
92 } // namespace sainsmart_relay_usb
93 
94 #endif // _RELAY_NODE_H_
95 
ros::Publisher pub_serial_
Definition: RelayNode.h:83
void publish(const boost::shared_ptr< M > &message) const
void timerCallback(const ros::WallTimerEvent &event)
Definition: RelayNode.cpp:137
void recv(const std_msgs::Byte::ConstPtr &msg)
Definition: RelayNode.cpp:75
void publishSerial(const std::string &serial)
Definition: RelayNode.h:63
RelayNode(ros::NodeHandle &nh, ros::NodeHandle &nh_priv)
Definition: RelayNode.cpp:41
void publishReady(bool ready)
Definition: RelayNode.h:59


sainsmart_relay_usb
Author(s): Kevin Hallenbeck
autogenerated on Fri Feb 5 2021 03:33:42