TransportIface.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012 Open Source Robotics Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16 */
17 #ifndef _GAZEBO_TRANSPORTIFACE_HH_
18 #define _GAZEBO_TRANSPORTIFACE_HH_
19 
20 // This fixes compiler warnings, see #3147 and #3160
21 #ifndef BOOST_BIND_GLOBAL_PLACEHOLDERS
22 #define BOOST_BIND_GLOBAL_PLACEHOLDERS
23 #endif
24 #include <boost/bind.hpp>
25 #include <string>
26 #include <list>
27 #include <map>
28 
31 #include "gazebo/transport/Node.hh"
33 
34 namespace gazebo
35 {
36  namespace transport
37  {
41 
48  GZ_TRANSPORT_VISIBLE
49  bool get_master_uri(std::string &_master_host, unsigned int &_master_port);
50 
59  GZ_TRANSPORT_VISIBLE
60  bool init(const std::string &_masterHost = "",
61  unsigned int _masterPort = 0,
62  uint32_t _timeoutIterations = 30);
63 
67  GZ_TRANSPORT_VISIBLE
68  void run();
69 
72  GZ_TRANSPORT_VISIBLE
73  void get_topic_namespaces(std::list<std::string> &_namespaces);
74 
77  GZ_TRANSPORT_VISIBLE
78  bool is_stopped();
79 
81  GZ_TRANSPORT_VISIBLE
82  void stop();
83 
85  GZ_TRANSPORT_VISIBLE
86  void fini();
87 
89  GZ_TRANSPORT_VISIBLE
90  void clear_buffers();
91 
95  GZ_TRANSPORT_VISIBLE
96  void pause_incoming(bool _pause);
97 
107  GZ_TRANSPORT_VISIBLE
108  boost::shared_ptr<msgs::Response> request(const std::string &_worldName,
109  const std::string &_request,
110  const std::string &_data = "",
111  const common::Time &_timeout = -1);
112 
113 
120  GZ_TRANSPORT_VISIBLE
121  void requestNoReply(const std::string &_worldName,
122  const std::string &_request,
123  const std::string &_data = "");
124 
130  GZ_TRANSPORT_VISIBLE
131  void requestNoReply(NodePtr _node, const std::string &_request,
132  const std::string &_data = "");
133 
140  template<typename M>
141  void publish(const std::string &_topic,
142  const google::protobuf::Message &_message)
143  {
145  node->Init();
146  node->Publish<M>(_topic, _message);
147  }
148 
152  GZ_TRANSPORT_VISIBLE
153  std::map<std::string, std::list<std::string> > getAdvertisedTopics();
154 
160  GZ_TRANSPORT_VISIBLE
161  std::list<std::string> getAdvertisedTopics(const std::string &_msgType);
162 
166  GZ_TRANSPORT_VISIBLE
167  std::string getTopicMsgType(const std::string &_topicName);
168 
171  GZ_TRANSPORT_VISIBLE
172  void setMinimalComms(bool _enabled);
173 
176  GZ_TRANSPORT_VISIBLE
178 
181  GZ_TRANSPORT_VISIBLE
183 
187  GZ_TRANSPORT_VISIBLE
190  }
191 }
192 #endif
transport
Definition: ConnectionManager.hh:38
Forward declarations for transport.
A Time class, can be used to hold wall- or sim-time.
Definition: Time.hh:48
A node can advertise and subscribe topics, publish on advertised topics and listen to subscribed topi...
Definition: Node.hh:104
void get_topic_namespaces(std::list< std::string > &_namespaces)
Return all the namespace (world names) on the master.
void run()
Run the transport component.
void requestNoReply(const std::string &_worldName, const std::string &_request, const std::string &_data="")
Send a request and don't wait for a response.
void pause_incoming(bool _pause)
Pause or unpause incoming messages.
bool waitForNamespaces(const gazebo::common::Time &_maxWait)
Blocks while waiting for topic namespaces from the Master.
void stop()
Stop the transport component from running.
bool getMinimalComms()
Get whether minimal comms has been enabled.
void setMinimalComms(bool _enabled)
Set whether minimal comms should be used.
void publish(const std::string &_topic, const google::protobuf::Message &_message)
A convenience function for a one-time publication of a message.
Definition: TransportIface.hh:141
void fini()
Cleanup the transport component.
std::string getTopicMsgType(const std::string &_topicName)
Get the message typename that is published on the given topic.
std::map< std::string, std::list< std::string > > getAdvertisedTopics()
Get a list of all the topics and their message types.
void clear_buffers()
Clear any remaining communication buffers.
transport::ConnectionPtr connectToMaster()
Create a connection to master.
bool init(const std::string &_masterHost="", unsigned int _masterPort=0, uint32_t _timeoutIterations=30)
Initialize the transport system.
bool is_stopped()
Is the transport system stopped?
bool get_master_uri(std::string &_master_host, unsigned int &_master_port)
Get the hostname and port of the master from the GAZEBO_MASTER_URI environment variable.
boost::shared_ptr< msgs::Response > request(const std::string &_worldName, const std::string &_request, const std::string &_data="", const common::Time &_timeout=-1)
Send a request and receive a response.
boost::shared_ptr< Connection > ConnectionPtr
Definition: Connection.hh:67
boost::shared_ptr< Node > NodePtr
Definition: TransportTypes.hh:57
Forward declarations for the common classes.
Definition: Animation.hh:27