node_handle.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2009, Willow Garage, Inc.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are met:
6  * * Redistributions of source code must retain the above copyright notice,
7  * this list of conditions and the following disclaimer.
8  * * Redistributions in binary form must reproduce the above copyright
9  * notice, this list of conditions and the following disclaimer in the
10  * documentation and/or other materials provided with the distribution.
11  * * Neither the names of Stanford University or Willow Garage, Inc. nor the names of its
12  * contributors may be used to endorse or promote products derived from
13  * this software without specific prior written permission.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
19  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25  * POSSIBILITY OF SUCH DAMAGE.
26  */
27 
28 #include "ros/node_handle.h"
29 #include "ros/this_node.h"
30 #include "ros/service.h"
31 #include "ros/callback_queue.h"
32 
33 #include "ros/time.h"
34 #include "ros/rate.h"
35 #include "ros/timer.h"
36 #include "ros/wall_timer.h"
37 #include "ros/steady_timer.h"
38 
39 #include "ros/xmlrpc_manager.h"
40 #include "ros/topic_manager.h"
41 #include "ros/service_manager.h"
42 #include "ros/master.h"
43 #include "ros/param.h"
44 #include "ros/names.h"
45 #include "ros/init.h"
46 #include "ros/this_node.h"
47 #include "xmlrpcpp/XmlRpc.h"
48 
49 #include <boost/thread.hpp>
50 
51 namespace ros
52 {
53 
54 boost::mutex g_nh_refcount_mutex;
55 int32_t g_nh_refcount = 0;
56 bool g_node_started_by_nh = false;
57 
59 {
60 public:
61  typedef std::vector<Publisher::ImplWPtr> V_PubImpl;
62  typedef std::vector<ServiceServer::ImplWPtr> V_SrvImpl;
63  typedef std::vector<Subscriber::ImplWPtr> V_SubImpl;
64  typedef std::vector<ServiceClient::ImplWPtr> V_SrvCImpl;
65  V_PubImpl pubs_;
66  V_SrvImpl srvs_;
67  V_SubImpl subs_;
68  V_SrvCImpl srv_cs_;
69 
70  boost::mutex mutex_;
71 };
72 
73 NodeHandle::NodeHandle(const std::string& ns, const M_string& remappings)
74  : namespace_(this_node::getNamespace())
75  , callback_queue_(0)
76  , collection_(0)
77 {
78  std::string tilde_resolved_ns;
79  if (!ns.empty() && ns[0] == '~')// starts with tilde
80  tilde_resolved_ns = names::resolve(ns);
81  else
82  tilde_resolved_ns = ns;
83 
84  construct(tilde_resolved_ns, true);
85 
86  initRemappings(remappings);
87 }
88 
89 NodeHandle::NodeHandle(const NodeHandle& parent, const std::string& ns)
90 : collection_(0)
91 {
92  namespace_ = parent.getNamespace();
94 
95  remappings_ = parent.remappings_;
97 
98  construct(ns, false);
99 }
100 
101 NodeHandle::NodeHandle(const NodeHandle& parent, const std::string& ns, const M_string& remappings)
102 : collection_(0)
103 {
104  namespace_ = parent.getNamespace();
106 
107  remappings_ = parent.remappings_;
109 
110  construct(ns, false);
111 
112  initRemappings(remappings);
113 }
114 
116 : collection_(0)
117 {
119  remappings_ = rhs.remappings_;
121 
122  construct(rhs.namespace_, true);
123 
125 }
126 
128 {
129  destruct();
130 }
131 
133 {
135  namespace_ = rhs.namespace_;
137  remappings_ = rhs.remappings_;
139 
140  return *this;
141 }
142 
144 {
145  ros::spin();
146 }
147 
148 void NodeHandle::construct(const std::string& ns, bool validate_name)
149 {
150  if (!ros::isInitialized())
151  {
152  ROS_FATAL("You must call ros::init() before creating the first NodeHandle");
153  ROS_BREAK();
154  }
155 
158  // if callback_queue_ is nonnull, we are in a non-nullary constructor
159 
160  if (validate_name)
161  namespace_ = resolveName(ns, true);
162  else
163  {
164  namespace_ = resolveName(ns, true, no_validate());
165  // FIXME validate namespace_ now
166  }
167  ok_ = true;
168 
169  boost::mutex::scoped_lock lock(g_nh_refcount_mutex);
170 
171  if (g_nh_refcount == 0 && !ros::isStarted())
172  {
173  g_node_started_by_nh = true;
174  ros::start();
175  }
176 
177  ++g_nh_refcount;
178 }
179 
181 {
182  delete collection_;
183 
184  boost::mutex::scoped_lock lock(g_nh_refcount_mutex);
185 
186  --g_nh_refcount;
187 
188  if (g_nh_refcount == 0 && g_node_started_by_nh)
189  {
190  ros::shutdown();
191  }
192 }
193 
194 void NodeHandle::initRemappings(const M_string& remappings)
195 {
196  {
197  M_string::const_iterator it = remappings.begin();
198  M_string::const_iterator end = remappings.end();
199  for (; it != end; ++it)
200  {
201  const std::string& from = it->first;
202  const std::string& to = it->second;
203 
204  remappings_.insert(std::make_pair(resolveName(from, false), resolveName(to, false)));
205  unresolved_remappings_.insert(std::make_pair(from, to));
206  }
207  }
208 }
209 
211 {
212  callback_queue_ = queue;
213 }
214 
215 std::string NodeHandle::remapName(const std::string& name) const
216 {
217  std::string resolved = resolveName(name, false);
218 
219  // First search any remappings that were passed in specifically for this NodeHandle
220  M_string::const_iterator it = remappings_.find(resolved);
221  if (it != remappings_.end())
222  {
223  // ROSCPP_LOG_DEBUG("found 'local' remapping: %s", it->second.c_str());
224  return it->second;
225  }
226 
227  // If not in our local remappings, perhaps in the global ones
228  return names::remap(resolved);
229 }
230 
231 std::string NodeHandle::resolveName(const std::string& name, bool remap) const
232 {
233  // ROSCPP_LOG_DEBUG("resolveName(%s, %s)", name.c_str(), remap ? "true" : "false");
234  std::string error;
235  if (!names::validate(name, error))
236  {
237  throw InvalidNameException(error);
238  }
239 
240  return resolveName(name, remap, no_validate());
241 }
242 
243 std::string NodeHandle::resolveName(const std::string& name, bool remap, no_validate) const
244 {
245  if (name.empty())
246  {
247  return namespace_;
248  }
249 
250  std::string final = name;
251 
252  if (final[0] == '~')
253  {
254  std::stringstream ss;
255  ss << "Using ~ names with NodeHandle methods is not allowed. If you want to use private names with the NodeHandle ";
256  ss << "interface, construct a NodeHandle using a private name as its namespace. e.g. ";
257  ss << "ros::NodeHandle nh(\"~\"); ";
258  ss << "nh.getParam(\"my_private_name\");";
259  ss << " (name = [" << name << "])";
260  throw InvalidNameException(ss.str());
261  }
262  else if (final[0] == '/')
263  {
264  // do nothing
265  }
266  else if (!namespace_.empty())
267  {
268  // ROSCPP_LOG_DEBUG("Appending namespace_ (%s)", namespace_.c_str());
269  final = names::append(namespace_, final);
270  }
271 
272  // ROSCPP_LOG_DEBUG("resolveName, pre-clean: %s", final.c_str());
273  final = names::clean(final);
274  // ROSCPP_LOG_DEBUG("resolveName, post-clean: %s", final.c_str());
275 
276  if (remap)
277  {
278  final = remapName(final);
279  // ROSCPP_LOG_DEBUG("resolveName, remapped: %s", final.c_str());
280  }
281 
282  return names::resolve(final, false);
283 }
284 
286 {
287  ops.topic = resolveName(ops.topic);
288  if (ops.callback_queue == 0)
289  {
290  if (callback_queue_)
291  {
293  }
294  else
295  {
297  }
298  }
299 
300  SubscriberCallbacksPtr callbacks(boost::make_shared<SubscriberCallbacks>(ops.connect_cb, ops.disconnect_cb,
301  ops.tracked_object, ops.callback_queue));
302 
303  if (TopicManager::instance()->advertise(ops, callbacks))
304  {
305  Publisher pub(ops.topic, ops.md5sum, ops.datatype, *this, callbacks);
306 
307  {
308  boost::mutex::scoped_lock lock(collection_->mutex_);
309  collection_->pubs_.push_back(pub.impl_);
310  }
311 
312  return pub;
313  }
314 
315  return Publisher();
316 }
317 
319 {
320  ops.topic = resolveName(ops.topic);
321  if (ops.callback_queue == 0)
322  {
323  if (callback_queue_)
324  {
326  }
327  else
328  {
330  }
331  }
332 
333  if (TopicManager::instance()->subscribe(ops))
334  {
335  Subscriber sub(ops.topic, *this, ops.helper);
336 
337  {
338  boost::mutex::scoped_lock lock(collection_->mutex_);
339  collection_->subs_.push_back(sub.impl_);
340  }
341 
342  return sub;
343  }
344 
345  return Subscriber();
346 }
347 
349 {
350  ops.service = resolveName(ops.service);
351  if (ops.callback_queue == 0)
352  {
353  if (callback_queue_)
354  {
356  }
357  else
358  {
360  }
361  }
362 
364  {
365  ServiceServer srv(ops.service, *this);
366 
367  {
368  boost::mutex::scoped_lock lock(collection_->mutex_);
369  collection_->srvs_.push_back(srv.impl_);
370  }
371 
372  return srv;
373  }
374 
375  return ServiceServer();
376 }
377 
379 {
380  ops.service = resolveName(ops.service);
381  ServiceClient client(ops.service, ops.persistent, ops.header, ops.md5sum);
382 
383  if (client)
384  {
385  boost::mutex::scoped_lock lock(collection_->mutex_);
386  collection_->srv_cs_.push_back(client.impl_);
387  }
388 
389  return client;
390 }
391 
393  bool oneshot, bool autostart) const
394 {
395  TimerOptions ops;
396  ops.period = period;
397  ops.callback = callback;
398  ops.oneshot = oneshot;
399  ops.autostart = autostart;
400  return createTimer(ops);
401 }
402 
404 {
405  if (ops.callback_queue == 0)
406  {
407  if (callback_queue_)
408  {
410  }
411  else
412  {
414  }
415  }
416 
417  Timer timer(ops);
418  if (ops.autostart)
419  timer.start();
420  return timer;
421 }
422 
424  bool oneshot, bool autostart) const
425 {
426  WallTimerOptions ops;
427  ops.period = period;
428  ops.callback = callback;
429  ops.oneshot = oneshot;
430  ops.autostart = autostart;
431  return createWallTimer(ops);
432 }
433 
435 {
436  if (ops.callback_queue == 0)
437  {
438  if (callback_queue_)
439  {
441  }
442  else
443  {
445  }
446  }
447 
448  WallTimer timer(ops);
449  if (ops.autostart)
450  timer.start();
451  return timer;
452 }
453 
455  bool oneshot, bool autostart) const
456 {
457  SteadyTimerOptions ops;
458  ops.period = period;
459  ops.callback = callback;
460  ops.oneshot = oneshot;
461  ops.autostart = autostart;
462  return createSteadyTimer(ops);
463 }
464 
466 {
467  if (ops.callback_queue == 0)
468  {
469  if (callback_queue_)
470  {
472  }
473  else
474  {
476  }
477  }
478 
479  SteadyTimer timer(ops);
480  if (ops.autostart)
481  timer.start();
482  return timer;
483 }
484 
486 {
487  {
488  NodeHandleBackingCollection::V_SubImpl::iterator it = collection_->subs_.begin();
489  NodeHandleBackingCollection::V_SubImpl::iterator end = collection_->subs_.end();
490  for (; it != end; ++it)
491  {
492  Subscriber::ImplPtr impl = it->lock();
493 
494  if (impl)
495  {
496  impl->unsubscribe();
497  }
498  }
499  }
500 
501  {
502  NodeHandleBackingCollection::V_PubImpl::iterator it = collection_->pubs_.begin();
503  NodeHandleBackingCollection::V_PubImpl::iterator end = collection_->pubs_.end();
504  for (; it != end; ++it)
505  {
506  Publisher::ImplPtr impl = it->lock();
507 
508  if (impl)
509  {
510  impl->unadvertise();
511  }
512  }
513  }
514 
515  {
516  NodeHandleBackingCollection::V_SrvImpl::iterator it = collection_->srvs_.begin();
517  NodeHandleBackingCollection::V_SrvImpl::iterator end = collection_->srvs_.end();
518  for (; it != end; ++it)
519  {
520  ServiceServer::ImplPtr impl = it->lock();
521 
522  if (impl)
523  {
524  impl->unadvertise();
525  }
526  }
527  }
528 
529  {
530  NodeHandleBackingCollection::V_SrvCImpl::iterator it = collection_->srv_cs_.begin();
531  NodeHandleBackingCollection::V_SrvCImpl::iterator end = collection_->srv_cs_.end();
532  for (; it != end; ++it)
533  {
534  ServiceClient::ImplPtr impl = it->lock();
535 
536  if (impl)
537  {
538  impl->shutdown();
539  }
540  }
541  }
542 
543  ok_ = false;
544 }
545 
546 void NodeHandle::setParam(const std::string& key, const XmlRpc::XmlRpcValue& v) const
547 {
548  return param::set(resolveName(key), v);
549 }
550 
551 void NodeHandle::setParam(const std::string& key, const std::string& s) const
552 {
553  return param::set(resolveName(key), s);
554 }
555 
556 void NodeHandle::setParam(const std::string& key, const char* s) const
557 {
558  return param::set(resolveName(key), s);
559 }
560 
561 void NodeHandle::setParam(const std::string& key, double d) const
562 {
563  return param::set(resolveName(key), d);
564 }
565 
566 void NodeHandle::setParam(const std::string& key, int i) const
567 {
568  return param::set(resolveName(key), i);
569 }
570 
571 void NodeHandle::setParam(const std::string& key, bool b) const
572 {
573  return param::set(resolveName(key), b);
574 }
575 
576 void NodeHandle::setParam(const std::string& key, const std::vector<std::string>& vec) const
577 {
578  return param::set(resolveName(key), vec);
579 }
580 void NodeHandle::setParam(const std::string& key, const std::vector<double>& vec) const
581 {
582  return param::set(resolveName(key), vec);
583 }
584 void NodeHandle::setParam(const std::string& key, const std::vector<float>& vec) const
585 {
586  return param::set(resolveName(key), vec);
587 }
588 void NodeHandle::setParam(const std::string& key, const std::vector<int>& vec) const
589 {
590  return param::set(resolveName(key), vec);
591 }
592 void NodeHandle::setParam(const std::string& key, const std::vector<bool>& vec) const
593 {
594  return param::set(resolveName(key), vec);
595 }
596 
597 void NodeHandle::setParam(const std::string& key, const std::map<std::string, std::string>& map) const
598 {
599  return param::set(resolveName(key), map);
600 }
601 void NodeHandle::setParam(const std::string& key, const std::map<std::string, double>& map) const
602 {
603  return param::set(resolveName(key), map);
604 }
605 void NodeHandle::setParam(const std::string& key, const std::map<std::string, float>& map) const
606 {
607  return param::set(resolveName(key), map);
608 }
609 void NodeHandle::setParam(const std::string& key, const std::map<std::string, int>& map) const
610 {
611  return param::set(resolveName(key), map);
612 }
613 void NodeHandle::setParam(const std::string& key, const std::map<std::string, bool>& map) const
614 {
615  return param::set(resolveName(key), map);
616 }
617 
618 bool NodeHandle::hasParam(const std::string& key) const
619 {
620  return param::has(resolveName(key));
621 }
622 
623 bool NodeHandle::deleteParam(const std::string& key) const
624 {
625  return param::del(resolveName(key));
626 }
627 
628 bool NodeHandle::getParamNames(std::vector<std::string>& keys) const
629 {
630  return param::getParamNames(keys);
631 }
632 
633 bool NodeHandle::getParam(const std::string& key, XmlRpc::XmlRpcValue& v) const
634 {
635  return param::get(resolveName(key), v);
636 }
637 
638 bool NodeHandle::getParam(const std::string& key, std::string& s) const
639 {
640  return param::get(resolveName(key), s);
641 }
642 
643 bool NodeHandle::getParam(const std::string& key, double& d) const
644 {
645  return param::get(resolveName(key), d);
646 }
647 
648 bool NodeHandle::getParam(const std::string& key, float& f) const
649 {
650  return param::get(resolveName(key), f);
651 }
652 
653 bool NodeHandle::getParam(const std::string& key, int& i) const
654 {
655  return param::get(resolveName(key), i);
656 }
657 
658 bool NodeHandle::getParam(const std::string& key, bool& b) const
659 {
660  return param::get(resolveName(key), b);
661 }
662 
663 
664 bool NodeHandle::getParam(const std::string& key, std::vector<std::string>& vec) const
665 {
666  return param::get(resolveName(key), vec);
667 }
668 bool NodeHandle::getParam(const std::string& key, std::vector<double>& vec) const
669 {
670  return param::get(resolveName(key), vec);
671 }
672 bool NodeHandle::getParam(const std::string& key, std::vector<float>& vec) const
673 {
674  return param::get(resolveName(key), vec);
675 }
676 bool NodeHandle::getParam(const std::string& key, std::vector<int>& vec) const
677 {
678  return param::get(resolveName(key), vec);
679 }
680 bool NodeHandle::getParam(const std::string& key, std::vector<bool>& vec) const
681 {
682  return param::get(resolveName(key), vec);
683 }
684 
685 bool NodeHandle::getParam(const std::string& key, std::map<std::string, std::string>& map) const
686 {
687  return param::get(resolveName(key), map);
688 }
689 bool NodeHandle::getParam(const std::string& key, std::map<std::string, double>& map) const
690 {
691  return param::get(resolveName(key), map);
692 }
693 bool NodeHandle::getParam(const std::string& key, std::map<std::string, float>& map) const
694 {
695  return param::get(resolveName(key), map);
696 }
697 bool NodeHandle::getParam(const std::string& key, std::map<std::string, int>& map) const
698 {
699  return param::get(resolveName(key), map);
700 }
701 bool NodeHandle::getParam(const std::string& key, std::map<std::string, bool>& map) const
702 {
703  return param::get(resolveName(key), map);
704 }
705 
706 bool NodeHandle::getParamCached(const std::string& key, XmlRpc::XmlRpcValue& v) const
707 {
708  return param::getCached(resolveName(key), v);
709 }
710 
711 bool NodeHandle::getParamCached(const std::string& key, std::string& s) const
712 {
713  return param::getCached(resolveName(key), s);
714 }
715 
716 bool NodeHandle::getParamCached(const std::string& key, double& d) const
717 {
718  return param::getCached(resolveName(key), d);
719 }
720 
721 bool NodeHandle::getParamCached(const std::string& key, float& f) const
722 {
723  return param::getCached(resolveName(key), f);
724 }
725 
726 bool NodeHandle::getParamCached(const std::string& key, int& i) const
727 {
728  return param::getCached(resolveName(key), i);
729 }
730 
731 bool NodeHandle::getParamCached(const std::string& key, bool& b) const
732 {
733  return param::getCached(resolveName(key), b);
734 }
735 
736 bool NodeHandle::getParamCached(const std::string& key, std::vector<std::string>& vec) const
737 {
738  return param::getCached(resolveName(key), vec);
739 }
740 bool NodeHandle::getParamCached(const std::string& key, std::vector<double>& vec) const
741 {
742  return param::getCached(resolveName(key), vec);
743 }
744 bool NodeHandle::getParamCached(const std::string& key, std::vector<float>& vec) const
745 {
746  return param::getCached(resolveName(key), vec);
747 }
748 bool NodeHandle::getParamCached(const std::string& key, std::vector<int>& vec) const
749 {
750  return param::getCached(resolveName(key), vec);
751 }
752 bool NodeHandle::getParamCached(const std::string& key, std::vector<bool>& vec) const
753 {
754  return param::getCached(resolveName(key), vec);
755 }
756 
757 bool NodeHandle::getParamCached(const std::string& key, std::map<std::string, std::string>& map) const
758 {
759  return param::getCached(resolveName(key), map);
760 }
761 bool NodeHandle::getParamCached(const std::string& key, std::map<std::string, double>& map) const
762 {
763  return param::getCached(resolveName(key), map);
764 }
765 bool NodeHandle::getParamCached(const std::string& key, std::map<std::string, float>& map) const
766 {
767  return param::getCached(resolveName(key), map);
768 }
769 bool NodeHandle::getParamCached(const std::string& key, std::map<std::string, int>& map) const
770 {
771  return param::getCached(resolveName(key), map);
772 }
773 bool NodeHandle::getParamCached(const std::string& key, std::map<std::string, bool>& map) const
774 {
775  return param::getCached(resolveName(key), map);
776 }
777 
778 bool NodeHandle::searchParam(const std::string& key, std::string& result_out) const
779 {
780  // searchParam needs a separate form of remapping -- remapping on the unresolved name, rather than the
781  // resolved one.
782 
783  std::string remapped = key;
784  M_string::const_iterator it = unresolved_remappings_.find(key);
785  // First try our local remappings
786  if (it != unresolved_remappings_.end())
787  {
788  remapped = it->second;
789  }
790 
791  return param::search(resolveName(""), remapped, result_out);
792 }
793 
794 bool NodeHandle::ok() const
795 {
796  return ros::ok() && ok_;
797 }
798 
799 } // namespace ros
SubscriberStatusCallback connect_cb
The function to call when a subscriber connects to this topic.
CallbackQueueInterface * callback_queue
Queue to add callbacks to. If NULL, the global callback queue will be used.
ServiceClient serviceClient(const std::string &service_name, bool persistent=false, const M_string &header_values=M_string())
Create a client for a service, version templated on two message types.
Definition: node_handle.h:1240
ROSCPP_DECL bool getParamNames(std::vector< std::string > &keys)
Get the list of all the parameters in the server.
Definition: param.cpp:723
Manages an subscription callback on a specific topic.
Definition: subscriber.h:46
#define ROS_FATAL(...)
Encapsulates all options available for creating a ServiceClient.
void start()
Start the timer. Does nothing if the timer is already started.
NodeHandle & operator=(const NodeHandle &rhs)
ROSCPP_DECL void start()
Actually starts the internals of the node (spins up threads, starts the network polling and xmlrpc lo...
Definition: init.cpp:293
void spinThread()
std::vector< ServiceServer::ImplWPtr > V_SrvImpl
Definition: node_handle.cpp:62
std::string md5sum
Service md5sum.
SubscriberStatusCallback disconnect_cb
The function to call when a subscriber disconnects from this topic.
boost::function< void(const TimerEvent &)> TimerCallback
Definition: forwards.h:144
Subscriber subscribe(const std::string &topic, uint32_t queue_size, void(T::*fp)(M), T *obj, const TransportHints &transport_hints=TransportHints())
Subscribe to a topic, version for class member function with bare pointer.
Definition: node_handle.h:402
std::string namespace_
Definition: node_handle.h:2189
bool getParamCached(const std::string &key, std::string &s) const
Get a string value from the parameter server, with local caching.
NodeHandle(const std::string &ns=std::string(), const M_string &remappings=M_string())
Constructor.
Definition: node_handle.cpp:73
bool deleteParam(const std::string &key) const
Delete a parameter from the parameter server.
Encapsulates all options available for starting a timer.
std::string resolveName(const std::string &name, bool remap=true) const
Resolves a name into a fully-qualified name.
WallTimerCallback callback
The callback to call.
std::vector< ServiceClient::ImplWPtr > V_SrvCImpl
Definition: node_handle.cpp:64
ROSCPP_DECL bool isInitialized()
Returns whether or not ros::init() has been called.
Definition: init.cpp:110
std::vector< Publisher::ImplWPtr > V_PubImpl
Definition: node_handle.cpp:61
CallbackQueueInterface * callback_queue_
Definition: node_handle.h:2194
void construct(const std::string &ns, bool validate_name)
std::string unresolved_namespace_
Definition: node_handle.h:2190
void start()
Start the timer. Does nothing if the timer is already started.
Definition: timer.cpp:116
SteadyTimerCallback callback
The callback to call.
ROSCPP_DECL bool validate(const std::string &name, std::string &error)
Validate a name against the name spec.
Definition: names.cpp:66
CallbackQueueInterface * callback_queue
Queue to add callbacks to. If NULL, the global callback queue will be used.
Definition: timer_options.h:65
ROSCPP_DECL std::string resolve(const std::string &name, bool remap=true)
Resolve a graph resource name into a fully qualified graph resource name.
Definition: names.cpp:136
ROSCPP_DECL std::string clean(const std::string &name)
Cleans a graph resource name: removes double slashes, trailing slash.
Definition: names.cpp:99
Abstract interface for a queue used to handle all callbacks within roscpp.
Encapsulates all options available for creating a Publisher.
ServiceServer advertiseService(const std::string &service, bool(T::*srv_func)(MReq &, MRes &), T *obj)
Advertise a service, version for class member function with bare pointer.
Definition: node_handle.h:879
WallDuration period
The period to call the callback at.
static const ServiceManagerPtr & instance()
Encapsulates all options available for creating a ServiceServer.
ROSCPP_DECL CallbackQueue * getGlobalCallbackQueue()
Returns a pointer to the global default callback queue.
Definition: init.cpp:568
std::map< std::string, std::string > M_string
std::string service
Service to connect to.
ROSCPP_DECL void set(const std::string &key, const XmlRpc::XmlRpcValue &v)
Set an arbitrary XML/RPC value on the parameter server.
Definition: param.cpp:67
ROSCPP_DECL std::string remap(const std::string &name)
Apply remappings to a name.
Definition: names.cpp:123
void start()
Start the timer. Does nothing if the timer is already started.
Definition: wall_timer.cpp:111
SubscriptionCallbackHelperPtr helper
Helper object used to get create messages and call callbacks.
ROSCPP_DECL const std::string & getNamespace()
Returns the namespace of the current node.
Definition: this_node.cpp:86
SteadyTimer createSteadyTimer(WallDuration period, void(T::*callback)(const SteadyTimerEvent &), T *obj, bool oneshot=false, bool autostart=true) const
Create a timer which will call a callback at the specified rate, using wall time to determine when to...
Definition: node_handle.h:1489
VoidConstPtr tracked_object
An object whose destruction will prevent the callbacks associated with this advertisement from being ...
ImplPtr impl_
Definition: publisher.h:193
M_string unresolved_remappings_
Definition: node_handle.h:2192
ROSCPP_DECL bool get(const std::string &key, std::string &s)
Get a string value from the parameter server.
Definition: param.cpp:415
Encapsulates all options available for creating a Subscriber.
boost::mutex g_nh_refcount_mutex
Definition: node_handle.cpp:54
bool searchParam(const std::string &key, std::string &result) const
Search up the tree for a parameter with a given key.
bool persistent
Whether or not the connection should persist.
void setCallbackQueue(CallbackQueueInterface *queue)
Set the default callback queue to be used by this NodeHandle.
roscpp&#39;s interface for creating subscribers, publishers, etc.
Definition: node_handle.h:87
boost::function< void(const SteadyTimerEvent &)> SteadyTimerCallback
Definition: forwards.h:180
ROSCPP_DECL bool ok()
Check whether it&#39;s time to exit.
Definition: init.cpp:573
Timer createTimer(Rate r, Handler h, Obj o, bool oneshot=false, bool autostart=true) const
Create a timer which will call a callback at the specified rate. This variant takes a class member fu...
Definition: node_handle.h:1294
CallbackQueueInterface * callback_queue
Queue to add callbacks to. If NULL, the global callback queue will be used.
TimerCallback callback
The callback to call.
Definition: timer_options.h:63
const std::string & getNamespace() const
Returns the namespace associated with this NodeHandle.
Definition: node_handle.h:191
std::string datatype
The datatype of the message published on this topic (eg. "std_msgs/String")
Encapsulates all options available for starting a timer.
Definition: timer_options.h:40
WallTimer createWallTimer(WallDuration period, void(T::*callback)(const WallTimerEvent &), T *obj, bool oneshot=false, bool autostart=true) const
Create a timer which will call a callback at the specified rate, using wall time to determine when to...
Definition: node_handle.h:1410
WallDuration period
The period to call the callback at.
ROSCPP_DECL bool has(const std::string &key)
Check whether a parameter exists on the parameter server.
Definition: param.cpp:211
bool getParamNames(std::vector< std::string > &keys) const
Get the keys for all the parameters in the parameter server.
std::vector< Subscriber::ImplWPtr > V_SubImpl
Definition: node_handle.cpp:63
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
Advertise a topic, simple version.
Definition: node_handle.h:249
ROSCPP_DECL void spin()
Enter simple event loop.
Definition: init.cpp:544
Manages an advertisement on a specific topic.
Definition: publisher.h:47
ROSCPP_DECL bool getCached(const std::string &key, std::string &s)
Get a string value from the parameter server, with local caching.
Definition: param.cpp:445
~NodeHandle()
Destructor.
std::string md5sum
The md5sum of the message datatype published on this topic.
Manages a steady-clock timer callback.
Definition: steady_timer.h:46
int32_t g_nh_refcount
Definition: node_handle.cpp:55
void initRemappings(const M_string &remappings)
bool g_node_started_by_nh
Definition: node_handle.cpp:56
ROSCPP_DECL bool del(const std::string &key)
Delete a parameter from the parameter server.
Definition: param.cpp:228
boost::function< void(const WallTimerEvent &)> WallTimerCallback
Definition: forwards.h:162
ROSCPP_DECL bool isStarted()
Returns whether or not the node has been started through ros::start()
Definition: init.cpp:288
Manages an service advertisement.
Duration period
The period to call the callback at.
Definition: timer_options.h:62
Thrown when an invalid graph resource name is specified to any roscpp function.
Definition: exceptions.h:51
bool getParam(const std::string &key, std::string &s) const
Get a string value from the parameter server.
void shutdown()
Shutdown every handle created through this NodeHandle.
M_string remappings_
Definition: node_handle.h:2191
std::string topic
The topic to publish on.
ROSCPP_DECL std::string append(const std::string &left, const std::string &right)
Append one name to another.
Definition: names.cpp:118
Manages a timer callback.
Definition: timer.h:46
Provides a handle-based interface to service client connections.
ROSCPP_DECL void shutdown()
Disconnects everything and unregisters from the master. It is generally not necessary to call this fu...
Definition: init.cpp:578
bool ok() const
Check whether it&#39;s time to exit.
CallbackQueueInterface * callback_queue
Queue to add callbacks to. If NULL, the global callback queue will be used.
bool hasParam(const std::string &key) const
Check whether a parameter exists on the parameter server.
#define ROS_ASSERT(cond)
std::string topic
Topic to subscribe to.
CallbackQueueInterface * callback_queue
Queue to add callbacks to. If NULL, the global callback queue will be used.
ROSCPP_DECL bool search(const std::string &ns, const std::string &key, std::string &result)
Search up the tree for a parameter with a given key.
Definition: param.cpp:758
#define ROS_BREAK()
void setParam(const std::string &key, const XmlRpc::XmlRpcValue &v) const
Set an arbitrary XML/RPC value on the parameter server.
Manages a wall-clock timer callback.
Definition: wall_timer.h:46
std::string remapName(const std::string &name) const
CallbackQueueInterface * callback_queue
Queue to add callbacks to. If NULL, the global callback queue will be used.
NodeHandleBackingCollection * collection_
Definition: node_handle.h:2196
Encapsulates all options available for starting a timer.
M_string header
Extra key/value pairs to add to the connection header.
static const TopicManagerPtr & instance()


roscpp
Author(s): Morgan Quigley, Josh Faust, Brian Gerkey, Troy Straszheim
autogenerated on Sun Feb 3 2019 03:29:54