qnode.cpp
Go to the documentation of this file.
1 
9 /*****************************************************************************
10 ** Includes
11 *****************************************************************************/
12 
13 #include <ros/ros.h>
14 #include <ros/network.h>
15 #include <string>
16 #include "qnode.hpp"
17 #include <std_msgs/String.h>
18 #include <sstream>
19 
20 /*****************************************************************************
21 ** Implementation
22 *****************************************************************************/
23 
24 QNode::QNode(int argc, char** argv, const std::string &name ) :
25  init_argc(argc),
26  init_argv(argv),
27  node_name(name)
28  {}
29 
31  shutdown();
32 }
38  if(ros::isStarted()) {
39  ros::shutdown(); // explicitly needed since we use ros::start();
41  }
42  wait();
43 }
44 
47  if ( ! ros::master::check() ) {
48  return false;
49  }
50  ros::start(); // our node handles go out of scope, so we want to control shutdown explicitly.
52  start();
53  return true;
54 }
55 
56 bool QNode::on_init(const std::string &master_url, const std::string &host_url) {
57  std::map<std::string,std::string> remappings;
58  remappings["__master"] = master_url;
59  remappings["__hostname"] = host_url;
60  ros::init(remappings,node_name);
61  if ( ! ros::master::check() ) {
62  return false;
63  }
64  ros::start(); // our node handles go out of scope, so we want to control shutdown explicitly.
66  start();
67  return true;
68 }
69 
ROSCPP_DECL bool check()
ROSCPP_DECL void start()
QNode(int argc, char **argv, const std::string &name)
Definition: qnode.cpp:24
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
virtual void ros_comms_init()=0
const std::string node_name
Definition: qnode.hpp:55
bool on_init()
Definition: qnode.cpp:45
virtual ~QNode()
Definition: qnode.cpp:30
char ** init_argv
Definition: qnode.hpp:53
void shutdown()
Definition: qnode.cpp:37
ROSCPP_DECL bool isStarted()
ROSCPP_DECL void shutdown()
int init_argc
Definition: qnode.hpp:52
ROSCPP_DECL void waitForShutdown()


qt_tutorials
Author(s): Daniel Stonier
autogenerated on Wed Mar 11 2020 03:12:20