Main Page
Classes
Files
File List
File Members
src
main.cpp
Go to the documentation of this file.
1
#include "
denso_ros_control/denso_hardware_interface.h
"
2
#include "
controller_manager/controller_manager.h
"
3
4
bool
g_shutdown
=
false
;
5
6
void
mySigintHandler
(
int
sig) {
7
ROS_INFO
(
"signal handler called"
);
8
g_shutdown
=
true
;
9
}
10
11
void
shutdown
(
boost::shared_ptr<DensoRobotHW>
robot,
boost::shared_ptr<ros::AsyncSpinner>
spinner)
12
{
13
if
(!!robot) {
14
robot.reset();
15
}
16
//if (!!spinner) {
17
// spinner->stop();
18
// spinner.reset();
19
//}
20
ros::shutdown
();
21
}
22
23
int
main
(
int
argc,
char
* argv[])
24
{
25
ros::init
(argc, argv,
"denso_ros_control"
,
ros::init_options::NoSigintHandler
);
26
ros::NodeHandle
nh;
27
28
boost::shared_ptr<DensoRobotHW>
robot;
29
boost::shared_ptr<ros::AsyncSpinner>
spinner
;
30
31
robot = boost::make_shared<DensoRobotHW>();
32
controller_manager::ControllerManager
cm(&(*(robot.get())), nh);
33
34
spinner = boost::make_shared<ros::AsyncSpinner>(1);
35
spinner->start();
36
37
ros::Rate
rate(1.0 / robot->getPeriod().toSec());
38
if
(!robot->init(nh,nh)) {
39
shutdown
(robot, spinner);
40
return
1;
41
}
42
43
signal(SIGINT,
mySigintHandler
);
44
signal(SIGTERM,
mySigintHandler
);
45
signal(SIGHUP,
mySigintHandler
);
46
while
(
ros::ok
() && !
g_shutdown
)
47
{
48
ros::Time
now = robot->getTime();
49
ros::Duration
dt = robot->getPeriod();
50
robot->read(now, dt);
51
cm.update(now, dt);
52
robot->write(now, dt);
53
rate.sleep();
54
}
55
shutdown
(robot, spinner);
56
return
0;
57
}
controller_manager::ControllerManager
ros::NodeHandle
ros::init_options::NoSigintHandler
NoSigintHandler
ros::Time
g_shutdown
bool g_shutdown
Definition:
main.cpp:4
ros::init
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
ros::Rate
shutdown
void shutdown(boost::shared_ptr< DensoRobotHW > robot, boost::shared_ptr< ros::AsyncSpinner > spinner)
Definition:
main.cpp:11
spinner
void spinner()
boost::shared_ptr
ROS_INFO
#define ROS_INFO(...)
ros::ok
ROSCPP_DECL bool ok()
mySigintHandler
void mySigintHandler(int sig)
Definition:
main.cpp:6
ros::Duration
controller_manager.h
ros::shutdown
ROSCPP_DECL void shutdown()
denso_hardware_interface.h
main
int main(int argc, char *argv[])
Definition:
main.cpp:23
denso_ros_control
Author(s):
autogenerated on Mon Jun 10 2019 13:13:14