Main Page
Classes
Class List
Class Members
All
b
c
d
g
i
k
l
n
p
r
s
u
w
x
y
z
~
Functions
Variables
Files
File List
File Members
All
Functions
Macros
src
dbus_node.cpp
Go to the documentation of this file.
1
/*******************************************************************************
2
* BSD 3-Clause License
3
*
4
* Copyright (c) 2021, Qiayuan Liao
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 are met:
9
*
10
* * Redistributions of source code must retain the above copyright notice, this
11
* list of conditions and the following disclaimer.
12
*
13
* * Redistributions in binary form must reproduce the above copyright notice,
14
* this list of conditions and the following disclaimer in the documentation
15
* and/or other materials provided with the distribution.
16
*
17
* * Neither the name of the copyright holder nor the names of its
18
* contributors may be used to endorse or promote products derived from
19
* this software without specific prior written permission.
20
*
21
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24
* ARE
25
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
26
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
28
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32
*******************************************************************************/
33
34
//
35
// Created by qiayuan on 2019/10/30.
36
//
37
38
#include "
rm_dbus/dbus_node.h
"
39
40
int
main
(
int
argc,
char
** argv)
41
{
42
ros::init
(argc, argv,
"rm_dbus"
);
43
DBusNode
dbus_node;
44
ros::Rate
loop_rate(60);
45
while
(
ros::ok
())
46
{
47
dbus_node.
run
();
48
loop_rate.
sleep
();
49
}
50
return
0;
51
}
52
53
DBusNode::DBusNode
()
54
{
55
dbus_pub_
=
nh_
.
advertise
<rm_msgs::DbusData>(
"dbus_data"
, 1);
56
nh_
.
param
<std::string>(
"serial_port"
,
serial_port_
,
"/dev/usbDbus"
);
57
dbus_
.
init
(
serial_port_
.data());
58
}
59
60
void
DBusNode::run
()
61
{
62
dbus_
.
read
();
63
dbus_
.
getData
(
dbus_cmd_
);
64
dbus_pub_
.
publish
(
dbus_cmd_
);
65
}
DBusNode::dbus_
DBus dbus_
Definition:
dbus_node.h:81
main
int main(int argc, char **argv)
Definition:
dbus_node.cpp:40
ros::init
ROSCPP_DECL void init(const M_string &remappings, const std::string &name, uint32_t options=0)
DBusNode::nh_
ros::NodeHandle nh_
Definition:
dbus_node.h:77
DBusNode::dbus_pub_
ros::Publisher dbus_pub_
Definition:
dbus_node.h:78
DBusNode::dbus_cmd_
rm_msgs::DbusData dbus_cmd_
Definition:
dbus_node.h:80
ros::Publisher::publish
void publish(const boost::shared_ptr< M > &message) const
ros::NodeHandle::advertise
Publisher advertise(AdvertiseOptions &ops)
DBus::init
void init(const char *serial)
Definition:
dbus.cpp:55
ros::ok
ROSCPP_DECL bool ok()
DBus::getData
void getData(rm_msgs::DbusData &d_bus_data) const
Definition:
dbus.cpp:171
DBusNode
Definition:
dbus_node.h:43
DBusNode::serial_port_
std::string serial_port_
Definition:
dbus_node.h:79
dbus_node.h
ros::Rate::sleep
bool sleep()
DBusNode::run
void run()
Definition:
dbus_node.cpp:60
ros::NodeHandle::param
T param(const std::string ¶m_name, const T &default_val) const
DBus::read
void read()
Definition:
dbus.cpp:96
ros::Rate
DBusNode::DBusNode
DBusNode()
Definition:
dbus_node.cpp:53
rm_dbus
Author(s): Qiayuan Liao
autogenerated on Thu Apr 24 2025 02:21:21