##

TransportIface.hh
Go to the documentation of this file.
/*
* Copyright (C) 2012 Open Source Robotics Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#ifndef _GAZEBO_TRANSPORTIFACE_HH_
#define _GAZEBO_TRANSPORTIFACE_HH_
#include <boost/bind.hpp>
#include <string>
#include <list>
#include <map>
#include "gazebo/transport/TransportTypes.hh"
#include "gazebo/transport/SubscribeOptions.hh"
#include "gazebo/transport/Node.hh"
#include "gazebo/transport/TopicManager.hh"
namespace gazebo
{
namespace transport
{
GZ_TRANSPORT_VISIBLE
bool get_master_uri(std::string &_master_host, unsigned int &_master_port);
GZ_TRANSPORT_VISIBLE
bool init(const std::string &_masterHost = "",
unsigned int _masterPort = 0,
uint32_t _timeoutIterations = 30);
GZ_TRANSPORT_VISIBLE
void run();
GZ_TRANSPORT_VISIBLE
void get_topic_namespaces(std::list<std::string> &_namespaces);
GZ_TRANSPORT_VISIBLE
bool is_stopped();
GZ_TRANSPORT_VISIBLE
void stop();
GZ_TRANSPORT_VISIBLE
void fini();
GZ_TRANSPORT_VISIBLE
void clear_buffers();
GZ_TRANSPORT_VISIBLE
void pause_incoming(bool _pause);
GZ_TRANSPORT_VISIBLE
boost::shared_ptr<msgs::Response> request(const std::string &_worldName,
const std::string &_request,
const std::string &_data = "");
GZ_TRANSPORT_VISIBLE
void requestNoReply(const std::string &_worldName,
const std::string &_request,
const std::string &_data = "");
GZ_TRANSPORT_VISIBLE
void requestNoReply(NodePtr _node, const std::string &_request,
const std::string &_data = "");
template<typename M>
void publish(const std::string &_topic,
const google::protobuf::Message &_message)
{
transport::NodePtr node = transport::NodePtr(new transport::Node());
node->Init();
node->Publish<M>(_topic, _message);
}
GZ_TRANSPORT_VISIBLE
std::map<std::string, std::list<std::string> > getAdvertisedTopics();
GZ_TRANSPORT_VISIBLE
std::list<std::string> getAdvertisedTopics(const std::string &_msgType);
GZ_TRANSPORT_VISIBLE
std::string getTopicMsgType(const std::string &_topicName);
GZ_TRANSPORT_VISIBLE
void setMinimalComms(bool _enabled);
GZ_TRANSPORT_VISIBLE
bool getMinimalComms();
GZ_TRANSPORT_VISIBLE
transport::ConnectionPtr connectToMaster();
GZ_TRANSPORT_VISIBLE
bool waitForNamespaces(const gazebo::common::Time &_maxWait);
}
}
#endif
gazebo::transport::stop
void stop()
Stop the transport component from running.
gazebo::transport::publish
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
gazebo::transport::connectToMaster
transport::ConnectionPtr connectToMaster()
Create a connection to master.
gazebo
Forward declarations for the common classes.
Definition: Animation.hh:26
TopicManager.hh
gazebo::common::Time
A Time class, can be used to hold wall- or sim-time. stored as sec and nano-sec.
Definition: Time.hh:47
TransportTypes.hh
Forward declarations for transport.
gazebo::transport::init
bool init(const std::string &_masterHost="", unsigned int _masterPort=0, uint32_t _timeoutIterations=30)
Initialize the transport system.
gazebo::transport::setMinimalComms
void setMinimalComms(bool _enabled)
Set whether minimal comms should be used.
gazebo::transport::NodePtr
boost::shared_ptr< Node > NodePtr
Definition: TransportTypes.hh:57
gazebo::transport::is_stopped
bool is_stopped()
Is the transport system stopped?
gazebo::transport::get_master_uri
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.
Node.hh
gazebo::transport::clear_buffers
void clear_buffers()
Clear any remaining communication buffers.
gazebo::transport::run
void run()
Run the transport component.
gazebo::transport::Node
A node can advertise and subscribe topics, publish on advertised topics and listen to subscribed topi...
Definition: Node.hh:78
gazebo::transport::fini
void fini()
Cleanup the transport component.
gazebo::transport::ConnectionPtr
boost::shared_ptr< Connection > ConnectionPtr
Definition: Connection.hh:50
gazebo::transport::request
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.
transport
transport
Definition: ConnectionManager.hh:35
gazebo::transport::getAdvertisedTopics
std::map< std::string, std::list< std::string > > getAdvertisedTopics()
Get a list of all the topics and their message types.
gazebo::transport::waitForNamespaces
bool waitForNamespaces(const gazebo::common::Time &_maxWait)
Blocks while waiting for topic namespaces from the Master.
gazebo::transport::getMinimalComms
bool getMinimalComms()
Get whether minimal comms has been enabled.
SubscribeOptions.hh
gazebo::transport::get_topic_namespaces
void get_topic_namespaces(std::list< std::string > &_namespaces)
Return all the namespace (world names) on the master.
gazebo::transport::getTopicMsgType
std::string getTopicMsgType(const std::string &_topicName)
Get the message typename that is published on the given topic.
gazebo::transport::requestNoReply
void requestNoReply(const std::string &_worldName, const std::string &_request, const std::string &_data="")
Send a request and don't wait for a response.
gazebo::transport::pause_incoming
void pause_incoming(bool _pause)
Pause or unpause incoming messages.