TransportIface.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012-2015 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 #include <boost/bind.hpp>
21 #include <string>
22 #include <list>
23 #include <map>
24 
27 #include "gazebo/transport/Node.hh"
29 
30 namespace gazebo
31 {
32  namespace transport
33  {
37 
45  bool get_master_uri(std::string &_master_host, unsigned int &_master_port);
46 
56  bool init(const std::string &_masterHost = "",
57  unsigned int _masterPort = 0,
58  uint32_t _timeoutIterations = 30);
59 
64  void run();
65 
69  void get_topic_namespaces(std::list<std::string> &_namespaces);
70 
74  bool is_stopped();
75 
78  void stop();
79 
82  void fini();
83 
86  void clear_buffers();
87 
92  void pause_incoming(bool _pause);
93 
102  boost::shared_ptr<msgs::Response> request(const std::string &_worldName,
103  const std::string &_request,
104  const std::string &_data = "");
105 
113  void requestNoReply(const std::string &_worldName,
114  const std::string &_request,
115  const std::string &_data = "");
116 
123  void requestNoReply(NodePtr _node, const std::string &_request,
124  const std::string &_data = "");
125 
132  template<typename M>
133  void publish(const std::string &_topic,
134  const google::protobuf::Message &_message)
135  {
137  node->Init();
138  node->Publish<M>(_topic, _message);
139  }
140 
145  std::map<std::string, std::list<std::string> > getAdvertisedTopics();
146 
153  std::list<std::string> getAdvertisedTopics(const std::string &_msgType);
154 
159  std::string getTopicMsgType(const std::string &_topicName);
160 
164  void setMinimalComms(bool _enabled);
165 
169  bool getMinimalComms();
170 
175 
180  bool waitForNamespaces(const gazebo::common::Time &_maxWait);
182  }
183 }
184 #endif
GZ_TRANSPORT_VISIBLE void fini()
Cleanup the transport component.
GZ_TRANSPORT_VISIBLE void get_topic_namespaces(std::list< std::string > &_namespaces)
Return all the namespace (world names) on the master.
GZ_TRANSPORT_VISIBLE void requestNoReply(const std::string &_worldName, const std::string &_request, const std::string &_data="")
Send a request and don't wait for a response.
boost::shared_ptr< Connection > ConnectionPtr
Definition: Connection.hh:50
GZ_TRANSPORT_VISIBLE std::string getTopicMsgType(const std::string &_topicName)
Get the message typename that is published on the given topic.
Forward declarations for transport.
GZ_TRANSPORT_VISIBLE 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.
GZ_TRANSPORT_VISIBLE bool waitForNamespaces(const gazebo::common::Time &_maxWait)
Blocks while waiting for topic namespaces from the Master.
GZ_TRANSPORT_VISIBLE void clear_buffers()
Clear any remaining communication buffers.
GZ_TRANSPORT_VISIBLE void setMinimalComms(bool _enabled)
Set whether minimal comms should be used.
GZ_TRANSPORT_VISIBLE std::map< std::string, std::list< std::string > > getAdvertisedTopics()
Get a list of all the topics and their message types.
GZ_TRANSPORT_VISIBLE transport::ConnectionPtr connectToMaster()
Create a connection to master.
GZ_TRANSPORT_VISIBLE bool is_stopped()
Is the transport system stopped?
GZ_TRANSPORT_VISIBLE bool init(const std::string &_masterHost="", unsigned int _masterPort=0, uint32_t _timeoutIterations=30)
Initialize the transport system.
GZ_TRANSPORT_VISIBLE void pause_incoming(bool _pause)
Pause or unpause incoming messages.
A node can advertise and subscribe topics, publish on advertised topics and listen to subscribed topi...
Definition: Node.hh:77
GZ_TRANSPORT_VISIBLE bool getMinimalComms()
Get whether minimal comms has been enabled.
boost::shared_ptr< Node > NodePtr
Definition: TransportTypes.hh:57
GZ_TRANSPORT_VISIBLE boost::shared_ptr< msgs::Response > request(const std::string &_worldName, const std::string &_request, const std::string &_data="")
Send a request and receive a response.
#define GZ_TRANSPORT_VISIBLE
Definition: system.hh:166
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:133
GZ_TRANSPORT_VISIBLE void stop()
Stop the transport component from running.
GZ_TRANSPORT_VISIBLE void run()
Run the transport component.
A Time class, can be used to hold wall- or sim-time.
Definition: Time.hh:39